Merge branch 'jc/strcasecmp-pure-inline'
authorJonathan Nieder <jrnieder@gmail.com>
Wed, 25 Sep 2013 06:28:13 +0000 (23:28 -0700)
committerJonathan Nieder <jrnieder@gmail.com>
Wed, 25 Sep 2013 06:28:13 +0000 (23:28 -0700)
* jc/strcasecmp-pure-inline:
mailmap: work around implementations with pure inline strcasecmp

1  2 
mailmap.c
diff --combined mailmap.c
index a7969c4c2e45df4f139c0bc85520f3bbc34da619,91a7532506328ff5d65c049d32a9e23a6d849b8b..81890a6680029ec1d369a7eef11a4ec112847fb7
+++ b/mailmap.c
@@@ -52,6 -52,20 +52,20 @@@ static void free_mailmap_entry(void *p
        string_list_clear_func(&me->namemap, free_mailmap_info);
  }
  
+ /*
+  * 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.  This is
+  * here as a workaround---do not assign strcasecmp directly to
+  * namemap.cmp until we know no systems that matter have such an
+  * "unusual" string.h.
+  */
+ static int namemap_cmp(const char *a, const char *b)
+ {
+       return strcasecmp(a, b);
+ }
  static void add_mapping(struct string_list *map,
                        char *new_name, char *new_email,
                        char *old_name, char *old_email)
@@@ -75,7 -89,7 +89,7 @@@
                item = string_list_insert_at_index(map, index, old_email);
                me = xcalloc(1, sizeof(struct mailmap_entry));
                me->namemap.strdup_strings = 1;
-               me->namemap.cmp = strcasecmp;
+               me->namemap.cmp = namemap_cmp;
                item->util = me;
        }
  
@@@ -153,7 -167,8 +167,7 @@@ static void read_mailmap_line(struct st
                if (!strncmp(buffer, abbrev, abblen)) {
                        char *cp;
  
 -                      if (repo_abbrev)
 -                              free(*repo_abbrev);
 +                      free(*repo_abbrev);
                        *repo_abbrev = xmalloc(len);
  
                        for (cp = buffer + abblen; isspace(*cp); cp++)
@@@ -192,17 -207,20 +206,17 @@@ static int read_mailmap_file(struct str
        return 0;
  }
  
 -static void read_mailmap_buf(struct string_list *map,
 -                           const char *buf, unsigned long len,
 -                           char **repo_abbrev)
 +static void read_mailmap_string(struct string_list *map, char *buf,
 +                              char **repo_abbrev)
  {
 -      while (len) {
 -              const char *end = strchrnul(buf, '\n');
 -              unsigned long linelen = end - buf + 1;
 -              char *line = xmemdupz(buf, linelen);
 +      while (*buf) {
 +              char *end = strchrnul(buf, '\n');
  
 -              read_mailmap_line(map, line, repo_abbrev);
 +              if (*end)
 +                      *end++ = '\0';
  
 -              free(line);
 -              buf += linelen;
 -              len -= linelen;
 +              read_mailmap_line(map, buf, repo_abbrev);
 +              buf = end;
        }
  }
  
@@@ -226,7 -244,7 +240,7 @@@ static int read_mailmap_blob(struct str
        if (type != OBJ_BLOB)
                return error("mailmap is not a blob: %s", name);
  
 -      read_mailmap_buf(map, buf, size, repo_abbrev);
 +      read_mailmap_string(map, buf, repo_abbrev);
  
        free(buf);
        return 0;
@@@ -237,7 -255,7 +251,7 @@@ int read_mailmap(struct string_list *ma
        int err = 0;
  
        map->strdup_strings = 1;
-       map->cmp = strcasecmp;
+       map->cmp = namemap_cmp;
  
        if (!git_mailmap_blob && is_bare_repository())
                git_mailmap_blob = "HEAD:.mailmap";