Code

get_author_initials: various fixes
[tig.git] / tig.h
diff --git a/tig.h b/tig.h
index e6cd9a19e5c8ffc312cbea2bc5493f7cef9a34d5..7baf8241b53680eeb9ad61a7216b125a081ef95f 100644 (file)
--- a/tig.h
+++ b/tig.h
 #define SIZEOF_REV     41      /* Holds a SHA-1 and an ending NUL. */
 #define SIZEOF_ARG     32      /* Default argument array size. */
 
-/* Revision graph */
-
-#define REVGRAPH_INIT  'I'
-#define REVGRAPH_MERGE 'M'
-#define REVGRAPH_BRANCH        '+'
-#define REVGRAPH_COMMIT        '*'
-#define REVGRAPH_BOUND '^'
-
-#define SIZEOF_REVGRAPH        19      /* Size of revision ancestry graphics. */
-
 /* This color name can be used to refer to the default term colors. */
 #define COLOR_DEFAULT  (-1)
 
@@ -142,6 +132,22 @@ name(type **mem, size_t size, size_t increase)                                     \
 #define prefixcmp(str1, str2) \
        strncmp(str1, str2, STRING_SIZE(str2))
 
+static inline int
+ascii_toupper(int c)
+{
+       if (c >= 'a' && c <= 'z')
+               c &= ~0x20;
+       return c;
+}
+
+static inline int
+ascii_tolower(int c)
+{
+       if (c >= 'A' && c <= 'Z')
+               c |= 0x20;
+       return c;
+}
+
 static inline int
 suffixcmp(const char *str, int slen, const char *suffix)
 {
@@ -246,6 +252,13 @@ struct enum_map {
 
 #define ENUM_MAP(name, value) { name, STRING_SIZE(name), value }
 
+#define ENUM_SYM_MACRO(prefix, name)   prefix##_##name
+#define ENUM_MAP_MACRO(prefix, name)   ENUM_MAP(#name, ENUM_SYM_MACRO(prefix, name))
+
+#define DEFINE_ENUM(name, info) \
+       enum name { info(ENUM_SYM_MACRO) }; \
+       static const struct enum_map name##_map[] = { info(ENUM_MAP_MACRO) }
+
 static inline int
 string_enum_compare(const char *str1, const char *str2, int len)
 {
@@ -255,7 +268,7 @@ string_enum_compare(const char *str1, const char *str2, int len)
 
        /* Diff-Header == DIFF_HEADER */
        for (i = 0; i < len; i++) {
-               if (toupper(str1[i]) == toupper(str2[i]))
+               if (ascii_toupper(str1[i]) == ascii_toupper(str2[i]))
                        continue;
 
                if (string_enum_sep(str1[i]) &&
@@ -278,7 +291,7 @@ enum_map_name(const char *name, size_t namelen)
        int bufpos;
 
        for (bufpos = 0; bufpos <= namelen; bufpos++) {
-               buf[bufpos] = tolower(name[bufpos]);
+               buf[bufpos] = ascii_tolower(name[bufpos]);
                if (buf[bufpos] == '_')
                        buf[bufpos] = '-';
        }