Skip to content

Commit 72631c9

Browse files
gitstersschuberth
authored andcommitted
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>
1 parent 296f510 commit 72631c9

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

mailmap.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ static void free_mailmap_entry(void *p, const char *s)
5252
string_list_clear_func(&me->namemap, free_mailmap_info);
5353
}
5454

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+
5569
static void add_mapping(struct string_list *map,
5670
char *new_name, char *new_email,
5771
char *old_name, char *old_email)
@@ -75,7 +89,7 @@ static void add_mapping(struct string_list *map,
7589
item = string_list_insert_at_index(map, index, old_email);
7690
me = xcalloc(1, sizeof(struct mailmap_entry));
7791
me->namemap.strdup_strings = 1;
78-
me->namemap.cmp = strcasecmp;
92+
me->namemap.cmp = namemap_cmp;
7993
item->util = me;
8094
}
8195

@@ -241,7 +255,7 @@ int read_mailmap(struct string_list *map, char **repo_abbrev)
241255
int err = 0;
242256

243257
map->strdup_strings = 1;
244-
map->cmp = strcasecmp;
258+
map->cmp = namemap_cmp;
245259

246260
if (!git_mailmap_blob && is_bare_repository())
247261
git_mailmap_blob = "HEAD:.mailmap";

0 commit comments

Comments
 (0)