mailmap: work around implementations with pure inline strcasecmp

On some systems (e.g. MinGW 4.0), string.h has only inline definition of strcasecmp and no non-inline implementation is supplied anywhere, which is, eh, "unusual". We cannot take an address of such a function to store it in namemap.cmp. Work it around by introducing our own level of indirection. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Sep 12, 2013 at 08:37 UTC de2f95ebed260b5fb31942d6315994829fb6fc63
1 file changed +16 -2
mailmap.c
+16 -2
@@ -52,6 +52,20 @@ static void free_mailmap_entry(void *p, const char *s)
52 string_list_clear_func(&me->namemap, free_mailmap_info);
53 }
54
55 +/*
56 + * On some systems (e.g. MinGW 4.0), string.h has _only_ inline
57 + * definition of strcasecmp and no non-inline implementation is
58 + * supplied anywhere, which is, eh, "unusual"; we cannot take an
59 + * address of such a function to store it in namemap.cmp. This is
60 + * here as a workaround---do not assign strcasecmp directly to
61 + * namemap.cmp until we know no systems that matter have such an
62 + * "unusual" string.h.
63 + */
64 +static int namemap_cmp(const char *a, const char *b)
65 +{
66 + return strcasecmp(a, b);
67 +}
68 +
69 static void add_mapping(struct string_list *map,
70 char *new_name, char *new_email,
71 char *old_name, char *old_email)
@@ -75,7 +89,7 @@ static void add_mapping(struct string_list *map,
89 item = string_list_insert_at_index(map, index, old_email);
90 me = xcalloc(1, sizeof(struct mailmap_entry));
91 me->namemap.strdup_strings = 1;
78 - me->namemap.cmp = strcasecmp;
92 + me->namemap.cmp = namemap_cmp;
93 item->util = me;
94 }
95
@@ -241,7 +255,7 @@ int read_mailmap(struct string_list *map, char **repo_abbrev)
255 int err = 0;
256
257 map->strdup_strings = 1;
244 - map->cmp = strcasecmp;
258 + map->cmp = namemap_cmp;
259
260 if (!git_mailmap_blob && is_bare_repository())
261 git_mailmap_blob = "HEAD:.mailmap";