{"thread":{"id":"35876","subject":"[PATCH 0/4] Good bye fnmatch","startedAt":"2014-02-15T02:01:45Z","lastAt":"2014-02-18T19:28:06Z","messageCount":9,"participants":["Nguyễn Thái Ngọc Duy","David Kastrup","Duy Nguyen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"234836","messageId":"1392429709-9237-1-git-send-email-pclouds@gmail.com","threadId":"35876","inReplyTo":null,"subject":"[PATCH 0/4] Good bye fnmatch","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2014-02-15T02:01:45Z","receivedAt":"2014-02-15T02:01:45Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Long story short, we wanted globbing wildcard \"**\" so I ripped\nwildmatch library from rsync to do it. And it opened a possibility\nto replace fnmatch completely, which would provide consistent behavior\nacross platforms (native fnmatch behaves differently on many corner\ncases), and some performance gains. I started fnmatch replacement with\n4917e1e (Makefile: promote wildmatch to be the default fnmatch\nimplementation - 2013-05-30). This is the final step.\n\nNguyễn Thái Ngọc Duy (4):\n  Use wildmatch() directly without fnmatch() wrapper\n  Revert \"test-wildmatch: add \"perf\" command to compare wildmatch and fnmatch\"\n  Stop using fnmatch (either native or compat)\n  Actually remove compat fnmatch source code\n\n Makefile                        |  22 --\n builtin/apply.c                 |   2 +-\n builtin/branch.c                |   2 +-\n builtin/describe.c              |   2 +-\n builtin/for-each-ref.c          |   2 +-\n builtin/ls-remote.c             |   2 +-\n builtin/name-rev.c              |   2 +-\n builtin/reflog.c                |   2 +-\n builtin/replace.c               |   2 +-\n builtin/show-branch.c           |   2 +-\n builtin/tag.c                   |   2 +-\n compat/fnmatch/fnmatch.c (gone) | 494 ----------------------------------------\n compat/fnmatch/fnmatch.h (gone) |  84 -------\n config.mak.uname                |  10 -\n configure.ac                    |  28 ---\n diffcore-order.c                |   2 +-\n dir.c                           |  11 +-\n git-compat-util.h               |  12 -\n refs.c                          |   2 +-\n revision.c                      |   2 +-\n t/t3070-wildmatch.sh            |  13 --\n test-wildmatch.c                |  79 -------\n 22 files changed, 20 insertions(+), 759 deletions(-)\n\n-- \n1.8.5.2.240.g8478abd\n"},{"id":"234838","messageId":"1392429709-9237-2-git-send-email-pclouds@gmail.com","threadId":"35876","inReplyTo":"1392429709-9237-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 1/4] Use wildmatch() directly without fnmatch() wrapper","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2014-02-15T02:01:46Z","receivedAt":"2014-02-15T02:01:46Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Make it clear that we don't use fnmatch() anymore.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/apply.c        |  2 +-\n builtin/branch.c       |  2 +-\n builtin/describe.c     |  2 +-\n builtin/for-each-ref.c |  2 +-\n builtin/ls-remote.c    |  2 +-\n builtin/name-rev.c     |  2 +-\n builtin/reflog.c       |  2 +-\n builtin/replace.c      |  2 +-\n builtin/show-branch.c  |  2 +-\n builtin/tag.c          |  2 +-\n diffcore-order.c       |  2 +-\n dir.c                  | 11 +++++++----\n refs.c                 |  2 +-\n revision.c             |  2 +-\n 14 files changed, 20 insertions(+), 17 deletions(-)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex b0d0986..66e2eed 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -4152,7 +4152,7 @@ static int use_patch(struct patch *p)\n \t/* See if it matches any of exclude/include rule */\n \tfor (i = 0; i < limit_by_name.nr; i++) {\n \t\tstruct string_list_item *it = &limit_by_name.items[i];\n-\t\tif (!fnmatch(it->string, pathname, 0))\n+\t\tif (!wildmatch(it->string, pathname, 0, NULL))\n \t\t\treturn (it->util != NULL);\n \t}\n \ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex b4d7716..652b1d2 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -315,7 +315,7 @@ static int match_patterns(const char **pattern, const char *refname)\n \tif (!*pattern)\n \t\treturn 1; /* no pattern always matches */\n \twhile (*pattern) {\n-\t\tif (!fnmatch(*pattern, refname, 0))\n+\t\tif (!wildmatch(*pattern, refname, 0, NULL))\n \t\t\treturn 1;\n \t\tpattern++;\n \t}\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 7db43da..848acdf 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -150,7 +150,7 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void\n \t\treturn 0;\n \n \t/* Accept only tags that match the pattern, if given */\n-\tif (pattern && (!is_tag || fnmatch(pattern, path + 10, 0)))\n+\tif (pattern && (!is_tag || wildmatch(pattern, path + 10, 0, NULL)))\n \t\treturn 0;\n \n \t/* Is it annotated? */\ndiff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\nindex 51798b4..3e1d5c3 100644\n--- a/builtin/for-each-ref.c\n+++ b/builtin/for-each-ref.c\n@@ -864,7 +864,7 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f\n \t\t\t     refname[plen] == '/' ||\n \t\t\t     p[plen-1] == '/'))\n \t\t\t\tbreak;\n-\t\t\tif (!fnmatch(p, refname, FNM_PATHNAME))\n+\t\t\tif (!wildmatch(p, refname, WM_PATHNAME, NULL))\n \t\t\t\tbreak;\n \t\t}\n \t\tif (!*pattern)\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 39e5144..3e9eefb 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -22,7 +22,7 @@ static int tail_match(const char **pattern, const char *path)\n \tif (snprintf(pathbuf, sizeof(pathbuf), \"/%s\", path) > sizeof(pathbuf))\n \t\treturn error(\"insanely long ref %.*s...\", 20, path);\n \twhile ((p = *(pattern++)) != NULL) {\n-\t\tif (!fnmatch(p, pathbuf, 0))\n+\t\tif (!wildmatch(p, pathbuf, 0, NULL))\n \t\t\treturn 1;\n \t}\n \treturn 0;\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 0b21d7e..c824d4e 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -87,7 +87,7 @@ static int subpath_matches(const char *path, const char *filter)\n \tconst char *subpath = path;\n \n \twhile (subpath) {\n-\t\tif (!fnmatch(filter, subpath, 0))\n+\t\tif (!wildmatch(filter, subpath, 0, NULL))\n \t\t\treturn subpath - path;\n \t\tsubpath = strchr(subpath, '/');\n \t\tif (subpath)\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 852cff6..c12a9784 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -561,7 +561,7 @@ static void set_reflog_expiry_param(struct cmd_reflog_expire_cb *cb, int slot, c\n \t\treturn; /* both given explicitly -- nothing to tweak */\n \n \tfor (ent = reflog_expire_cfg; ent; ent = ent->next) {\n-\t\tif (!fnmatch(ent->pattern, ref, 0)) {\n+\t\tif (!wildmatch(ent->pattern, ref, 0, NULL)) {\n \t\t\tif (!(slot & EXPIRE_TOTAL))\n \t\t\t\tcb->expire_total = ent->expire_total;\n \t\t\tif (!(slot & EXPIRE_UNREACH))\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 2336325..80b152a 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -36,7 +36,7 @@ static int show_reference(const char *refname, const unsigned char *sha1,\n {\n \tstruct show_data *data = cb_data;\n \n-\tif (!fnmatch(data->pattern, refname, 0)) {\n+\tif (!wildmatch(data->pattern, refname, 0, NULL)) {\n \t\tif (data->format == REPLACE_FORMAT_SHORT)\n \t\t\tprintf(\"%s\\n\", refname);\n \t\telse if (data->format == REPLACE_FORMAT_MEDIUM)\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex d9217ce..d873172 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -450,7 +450,7 @@ static int append_matching_ref(const char *refname, const unsigned char *sha1, i\n \t\t\tslash--;\n \tif (!*tail)\n \t\treturn 0;\n-\tif (fnmatch(match_ref_pattern, tail, 0))\n+\tif (wildmatch(match_ref_pattern, tail, 0, NULL))\n \t\treturn 0;\n \tif (starts_with(refname, \"refs/heads/\"))\n \t\treturn append_head_ref(refname, sha1, flag, cb_data);\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 74d3780..169c676 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -42,7 +42,7 @@ static int match_pattern(const char **patterns, const char *ref)\n \tif (!*patterns)\n \t\treturn 1;\n \tfor (; *patterns; patterns++)\n-\t\tif (!fnmatch(*patterns, ref, 0))\n+\t\tif (!wildmatch(*patterns, ref, 0, NULL))\n \t\t\treturn 1;\n \treturn 0;\n }\ndiff --git a/diffcore-order.c b/diffcore-order.c\nindex fe7f1f4..53ea4d1 100644\n--- a/diffcore-order.c\n+++ b/diffcore-order.c\n@@ -73,7 +73,7 @@ static int match_order(const char *path)\n \t\tstrbuf_addstr(&p, path);\n \t\twhile (p.buf[0]) {\n \t\t\tchar *cp;\n-\t\t\tif (!fnmatch(order[i], p.buf, 0))\n+\t\t\tif (!wildmatch(order[i], p.buf, 0, NULL))\n \t\t\t\treturn i;\n \t\t\tcp = strrchr(p.buf, '/');\n \t\t\tif (!cp)\ndiff --git a/dir.c b/dir.c\nindex b35b633..59ccb52 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -49,7 +49,9 @@ int strncmp_icase(const char *a, const char *b, size_t count)\n \n int fnmatch_icase(const char *pattern, const char *string, int flags)\n {\n-\treturn fnmatch(pattern, string, flags | (ignore_case ? FNM_CASEFOLD : 0));\n+\treturn wildmatch(pattern, string,\n+\t\t\t flags | (ignore_case ? WM_CASEFOLD : 0),\n+\t\t\t NULL);\n }\n \n inline int git_fnmatch(const struct pathspec_item *item,\n@@ -58,7 +60,7 @@ inline int git_fnmatch(const struct pathspec_item *item,\n {\n \tif (prefix > 0) {\n \t\tif (ps_strncmp(item, pattern, string, prefix))\n-\t\t\treturn FNM_NOMATCH;\n+\t\t\treturn WM_NOMATCH;\n \t\tpattern += prefix;\n \t\tstring += prefix;\n \t}\n@@ -76,8 +78,9 @@ inline int git_fnmatch(const struct pathspec_item *item,\n \t\t\t\t NULL);\n \telse\n \t\t/* wildmatch has not learned no FNM_PATHNAME mode yet */\n-\t\treturn fnmatch(pattern, string,\n-\t\t\t       item->magic & PATHSPEC_ICASE ? FNM_CASEFOLD : 0);\n+\t\treturn wildmatch(pattern, string,\n+\t\t\t\t item->magic & PATHSPEC_ICASE ? WM_CASEFOLD : 0,\n+\t\t\t\t NULL);\n }\n \n static int fnmatch_icase_mem(const char *pattern, int patternlen,\ndiff --git a/refs.c b/refs.c\nindex 89228e2..f89d589 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1477,7 +1477,7 @@ static int filter_refs(const char *refname, const unsigned char *sha1, int flags\n \t\t       void *data)\n {\n \tstruct ref_filter *filter = (struct ref_filter *)data;\n-\tif (fnmatch(filter->pattern, refname, 0))\n+\tif (wildmatch(filter->pattern, refname, 0, NULL))\n \t\treturn 0;\n \treturn filter->fn(refname, sha1, flags, filter->cb_data);\n }\ndiff --git a/revision.c b/revision.c\nindex a0df72f..6addff1 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1191,7 +1191,7 @@ int ref_excluded(struct string_list *ref_excludes, const char *path)\n \tif (!ref_excludes)\n \t\treturn 0;\n \tfor_each_string_list_item(item, ref_excludes) {\n-\t\tif (!fnmatch(item->string, path, 0))\n+\t\tif (!wildmatch(item->string, path, 0, NULL))\n \t\t\treturn 1;\n \t}\n \treturn 0;\n-- \n1.8.5.2.240.g8478abd\n"},{"id":"234837","messageId":"1392429709-9237-3-git-send-email-pclouds@gmail.com","threadId":"35876","inReplyTo":"1392429709-9237-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 2/4] Revert \"test-wildmatch: add \"perf\" command to compare wildmatch and fnmatch\"","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2014-02-15T02:01:47Z","receivedAt":"2014-02-15T02:01:47Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This reverts commit 1b25892636d2f250eb2163301440ee8c8c1ac944. compat\nfnmatch will be removed soon and we can't rely on fnmatch() available\neverywhere.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n test-wildmatch.c | 73 --------------------------------------------------------\n 1 file changed, 73 deletions(-)\n\ndiff --git a/test-wildmatch.c b/test-wildmatch.c\nindex a3e2643..1564bd5 100644\n--- a/test-wildmatch.c\n+++ b/test-wildmatch.c\n@@ -4,82 +4,9 @@\n #include \"cache.h\"\n #include \"wildmatch.h\"\n \n-static int perf(int ac, char **av)\n-{\n-\tstruct timeval tv1, tv2;\n-\tstruct stat st;\n-\tint fd, i, n, flags1 = 0, flags2 = 0;\n-\tchar *buffer, *p;\n-\tuint32_t usec1, usec2;\n-\tconst char *lang;\n-\tconst char *file = av[0];\n-\tconst char *pattern = av[1];\n-\n-\tlang = getenv(\"LANG\");\n-\tif (lang && strcmp(lang, \"C\"))\n-\t\tdie(\"Please test it on C locale.\");\n-\n-\tif ((fd = open(file, O_RDONLY)) == -1 || fstat(fd, &st))\n-\t\tdie_errno(\"file open\");\n-\n-\tbuffer = xmalloc(st.st_size + 2);\n-\tif (read(fd, buffer, st.st_size) != st.st_size)\n-\t\tdie_errno(\"read\");\n-\n-\tbuffer[st.st_size] = '\\0';\n-\tbuffer[st.st_size + 1] = '\\0';\n-\tfor (i = 0; i < st.st_size; i++)\n-\t\tif (buffer[i] == '\\n')\n-\t\t\tbuffer[i] = '\\0';\n-\n-\tn = atoi(av[2]);\n-\tif (av[3] && !strcmp(av[3], \"pathname\")) {\n-\t\tflags1 = WM_PATHNAME;\n-\t\tflags2 = FNM_PATHNAME;\n-\t}\n-\n-\tgettimeofday(&tv1, NULL);\n-\tfor (i = 0; i < n; i++) {\n-\t\tfor (p = buffer; *p; p += strlen(p) + 1)\n-\t\t\twildmatch(pattern, p, flags1, NULL);\n-\t}\n-\tgettimeofday(&tv2, NULL);\n-\n-\tusec1 = (uint32_t)tv2.tv_sec * 1000000 + tv2.tv_usec;\n-\tusec1 -= (uint32_t)tv1.tv_sec * 1000000 + tv1.tv_usec;\n-\tprintf(\"wildmatch %ds %dus\\n\",\n-\t       (int)(usec1 / 1000000),\n-\t       (int)(usec1 % 1000000));\n-\n-\tgettimeofday(&tv1, NULL);\n-\tfor (i = 0; i < n; i++) {\n-\t\tfor (p = buffer; *p; p += strlen(p) + 1)\n-\t\t\tfnmatch(pattern, p, flags2);\n-\t}\n-\tgettimeofday(&tv2, NULL);\n-\n-\tusec2 = (uint32_t)tv2.tv_sec * 1000000 + tv2.tv_usec;\n-\tusec2 -= (uint32_t)tv1.tv_sec * 1000000 + tv1.tv_usec;\n-\tif (usec2 > usec1)\n-\t\tprintf(\"fnmatch   %ds %dus or %.2f%% slower\\n\",\n-\t\t       (int)((usec2 - usec1) / 1000000),\n-\t\t       (int)((usec2 - usec1) % 1000000),\n-\t\t       (float)(usec2 - usec1) / usec1 * 100);\n-\telse\n-\t\tprintf(\"fnmatch   %ds %dus or %.2f%% faster\\n\",\n-\t\t       (int)((usec1 - usec2) / 1000000),\n-\t\t       (int)((usec1 - usec2) % 1000000),\n-\t\t       (float)(usec1 - usec2) / usec1 * 100);\n-\treturn 0;\n-}\n-\n int main(int argc, char **argv)\n {\n \tint i;\n-\n-\tif (!strcmp(argv[1], \"perf\"))\n-\t\treturn perf(argc - 2, argv + 2);\n-\n \tfor (i = 2; i < argc; i++) {\n \t\tif (argv[i][0] == '/')\n \t\t\tdie(\"Forward slash is not allowed at the beginning of the\\n\"\n-- \n1.8.5.2.240.g8478abd\n"},{"id":"234840","messageId":"1392429709-9237-4-git-send-email-pclouds@gmail.com","threadId":"35876","inReplyTo":"1392429709-9237-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 3/4] Stop using fnmatch (either native or compat)","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2014-02-15T02:01:48Z","receivedAt":"2014-02-15T02:01:48Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Since v1.8.4 (about six months ago) wildmatch is used as default\nreplacement for fnmatch. We have seen only one fix since so wildmatch\nprobably has done a good job as fnmatch replacement. This concludes\nthe fnmatch->wildmatch transition by no longer relying on fnmatch.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Makefile             | 22 ----------------------\n config.mak.uname     | 10 ----------\n configure.ac         | 28 ----------------------------\n git-compat-util.h    | 12 ------------\n t/t3070-wildmatch.sh | 13 -------------\n test-wildmatch.c     |  6 ------\n 6 files changed, 91 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex dddaf4f..ca38f99 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -101,14 +101,6 @@ all::\n #\n # Define NO_MKSTEMPS if you don't have mkstemps in the C library.\n #\n-# Define NO_FNMATCH if you don't have fnmatch in the C library.\n-#\n-# Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the\n-# FNM_CASEFOLD GNU extension.\n-#\n-# Define NO_WILDMATCH if you do not want to use Git's wildmatch\n-# implementation as fnmatch\n-#\n # Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd\n # in the C library.\n #\n@@ -1271,20 +1263,6 @@ endif\n ifdef NO_STRTOULL\n \tCOMPAT_CFLAGS += -DNO_STRTOULL\n endif\n-ifdef NO_FNMATCH\n-\tCOMPAT_CFLAGS += -Icompat/fnmatch\n-\tCOMPAT_CFLAGS += -DNO_FNMATCH\n-\tCOMPAT_OBJS += compat/fnmatch/fnmatch.o\n-else\n-ifdef NO_FNMATCH_CASEFOLD\n-\tCOMPAT_CFLAGS += -Icompat/fnmatch\n-\tCOMPAT_CFLAGS += -DNO_FNMATCH_CASEFOLD\n-\tCOMPAT_OBJS += compat/fnmatch/fnmatch.o\n-endif\n-endif\n-ifndef NO_WILDMATCH\n-\tCOMPAT_CFLAGS += -DUSE_WILDMATCH\n-endif\n ifdef NO_SETENV\n \tCOMPAT_CFLAGS += -DNO_SETENV\n \tCOMPAT_OBJS += compat/setenv.o\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 7d31fad..6069a44 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -108,7 +108,6 @@ ifeq ($(uname_S),SunOS)\n \tNO_MKDTEMP = YesPlease\n \tNO_MKSTEMPS = YesPlease\n \tNO_REGEX = YesPlease\n-\tNO_FNMATCH_CASEFOLD = YesPlease\n \tNO_MSGFMT_EXTENDED_OPTIONS = YesPlease\n \tHAVE_DEV_TTY = YesPlease\n \tifeq ($(uname_R),5.6)\n@@ -259,7 +258,6 @@ ifeq ($(uname_S),IRIX)\n \t# issue, comment out the NO_MMAP statement.\n \tNO_MMAP = YesPlease\n \tNO_REGEX = YesPlease\n-\tNO_FNMATCH_CASEFOLD = YesPlease\n \tSNPRINTF_RETURNS_BOGUS = YesPlease\n \tSHELL_PATH = /usr/gnu/bin/bash\n \tNEEDS_LIBGEN = YesPlease\n@@ -279,7 +277,6 @@ ifeq ($(uname_S),IRIX64)\n \t# issue, comment out the NO_MMAP statement.\n \tNO_MMAP = YesPlease\n \tNO_REGEX = YesPlease\n-\tNO_FNMATCH_CASEFOLD = YesPlease\n \tSNPRINTF_RETURNS_BOGUS = YesPlease\n \tSHELL_PATH = /usr/gnu/bin/bash\n \tNEEDS_LIBGEN = YesPlease\n@@ -296,7 +293,6 @@ ifeq ($(uname_S),HP-UX)\n \tNO_UNSETENV = YesPlease\n \tNO_HSTRERROR = YesPlease\n \tNO_SYS_SELECT_H = YesPlease\n-\tNO_FNMATCH_CASEFOLD = YesPlease\n \tSNPRINTF_RETURNS_BOGUS = YesPlease\n \tNO_NSEC = YesPlease\n \tifeq ($(uname_R),B.11.00)\n@@ -327,7 +323,6 @@ ifeq ($(uname_S),Windows)\n \tNO_UNSETENV = YesPlease\n \tNO_STRCASESTR = YesPlease\n \tNO_STRLCPY = YesPlease\n-\tNO_FNMATCH = YesPlease\n \tNO_MEMMEM = YesPlease\n \t# NEEDS_LIBICONV = YesPlease\n \tNO_ICONV = YesPlease\n@@ -389,13 +384,11 @@ ifeq ($(uname_S),Interix)\n \t\tNO_INET_NTOP = YesPlease\n \t\tNO_INET_PTON = YesPlease\n \t\tNO_SOCKADDR_STORAGE = YesPlease\n-\t\tNO_FNMATCH_CASEFOLD = YesPlease\n \tendif\n \tifeq ($(uname_R),5.2)\n \t\tNO_INET_NTOP = YesPlease\n \t\tNO_INET_PTON = YesPlease\n \t\tNO_SOCKADDR_STORAGE = YesPlease\n-\t\tNO_FNMATCH_CASEFOLD = YesPlease\n \tendif\n endif\n ifeq ($(uname_S),Minix)\n@@ -440,7 +433,6 @@ ifeq ($(uname_S),NONSTOP_KERNEL)\n \tNO_D_TYPE_IN_DIRENT = YesPlease\n \tNO_HSTRERROR = YesPlease\n \tNO_STRCASESTR = YesPlease\n-\tNO_FNMATCH_CASEFOLD = YesPlease\n \tNO_MEMMEM = YesPlease\n \tNO_STRLCPY = YesPlease\n \tNO_SETENV = YesPlease\n@@ -484,7 +476,6 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tNO_UNSETENV = YesPlease\n \tNO_STRCASESTR = YesPlease\n \tNO_STRLCPY = YesPlease\n-\tNO_FNMATCH = YesPlease\n \tNO_MEMMEM = YesPlease\n \tNEEDS_LIBICONV = YesPlease\n \tNO_STRTOUMAX = YesPlease\n@@ -538,7 +529,6 @@ ifeq ($(uname_S),QNX)\n \tEXPAT_NEEDS_XMLPARSE_H = YesPlease\n \tHAVE_STRINGS_H = YesPlease\n \tNEEDS_SOCKET = YesPlease\n-\tNO_FNMATCH_CASEFOLD = YesPlease\n \tNO_GETPAGESIZE = YesPlease\n \tNO_ICONV = YesPlease\n \tNO_MEMMEM = YesPlease\ndiff --git a/configure.ac b/configure.ac\nindex 2f43393..24ab738 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -901,34 +901,6 @@ GIT_CHECK_FUNC(strcasestr,\n [NO_STRCASESTR=YesPlease])\n GIT_CONF_SUBST([NO_STRCASESTR])\n #\n-# Define NO_FNMATCH if you don't have fnmatch\n-GIT_CHECK_FUNC(fnmatch,\n-[NO_FNMATCH=],\n-[NO_FNMATCH=YesPlease])\n-GIT_CONF_SUBST([NO_FNMATCH])\n-#\n-# Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the\n-# FNM_CASEFOLD GNU extension.\n-AC_CACHE_CHECK([whether the fnmatch function supports the FNMATCH_CASEFOLD GNU extension],\n- [ac_cv_c_excellent_fnmatch], [\n-AC_EGREP_CPP(yippeeyeswehaveit,\n-\tAC_LANG_PROGRAM([\n-#include <fnmatch.h>\n-],\n-[#ifdef FNM_CASEFOLD\n-yippeeyeswehaveit\n-#endif\n-]),\n-\t[ac_cv_c_excellent_fnmatch=yes],\n-\t[ac_cv_c_excellent_fnmatch=no])\n-])\n-if test $ac_cv_c_excellent_fnmatch = yes; then\n-\tNO_FNMATCH_CASEFOLD=\n-else\n-\tNO_FNMATCH_CASEFOLD=YesPlease\n-fi\n-GIT_CONF_SUBST([NO_FNMATCH_CASEFOLD])\n-#\n # Define NO_MEMMEM if you don't have memmem.\n GIT_CHECK_FUNC(memmem,\n [NO_MEMMEM=],\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex cbd86c3..eaee438 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -116,9 +116,6 @@\n #include <sys/time.h>\n #include <time.h>\n #include <signal.h>\n-#ifndef USE_WILDMATCH\n-#include <fnmatch.h>\n-#endif\n #include <assert.h>\n #include <regex.h>\n #include <utime.h>\n@@ -304,16 +301,7 @@ extern char *gitbasename(char *);\n \n #include \"compat/bswap.h\"\n \n-#ifdef USE_WILDMATCH\n #include \"wildmatch.h\"\n-#define FNM_PATHNAME WM_PATHNAME\n-#define FNM_CASEFOLD WM_CASEFOLD\n-#define FNM_NOMATCH  WM_NOMATCH\n-static inline int fnmatch(const char *pattern, const char *string, int flags)\n-{\n-\treturn wildmatch(pattern, string, flags, NULL);\n-}\n-#endif\n \n /* General helper functions */\n extern void vreportf(const char *prefix, const char *err, va_list params);\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 38446a0..ef509df 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -14,19 +14,6 @@ match() {\n \t    ! test-wildmatch wildmatch '$3' '$4'\n \t\"\n     fi\n-    if [ $2 = 1 ]; then\n-\ttest_expect_success \"fnmatch:       match '$3' '$4'\" \"\n-\t    test-wildmatch fnmatch '$3' '$4'\n-\t\"\n-    elif [ $2 = 0 ]; then\n-\ttest_expect_success \"fnmatch:    no match '$3' '$4'\" \"\n-\t    ! test-wildmatch fnmatch '$3' '$4'\n-\t\"\n-#    else\n-#\ttest_expect_success BROKEN_FNMATCH \"fnmatch:       '$3' '$4'\" \"\n-#\t    ! test-wildmatch fnmatch '$3' '$4'\n-#\t\"\n-    fi\n }\n \n imatch() {\ndiff --git a/test-wildmatch.c b/test-wildmatch.c\nindex 1564bd5..578b164 100644\n--- a/test-wildmatch.c\n+++ b/test-wildmatch.c\n@@ -1,8 +1,4 @@\n-#ifdef USE_WILDMATCH\n-#undef USE_WILDMATCH  /* We need real fnmatch implementation here */\n-#endif\n #include \"cache.h\"\n-#include \"wildmatch.h\"\n \n int main(int argc, char **argv)\n {\n@@ -20,8 +16,6 @@ int main(int argc, char **argv)\n \t\treturn !!wildmatch(argv[3], argv[2], WM_PATHNAME | WM_CASEFOLD, NULL);\n \telse if (!strcmp(argv[1], \"pathmatch\"))\n \t\treturn !!wildmatch(argv[3], argv[2], 0, NULL);\n-\telse if (!strcmp(argv[1], \"fnmatch\"))\n-\t\treturn !!fnmatch(argv[3], argv[2], FNM_PATHNAME);\n \telse\n \t\treturn 1;\n }\n-- \n1.8.5.2.240.g8478abd\n"},{"id":"234839","messageId":"1392429709-9237-5-git-send-email-pclouds@gmail.com","threadId":"35876","inReplyTo":"1392429709-9237-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 4/4] Actually remove compat fnmatch source code","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2014-02-15T02:01:49Z","receivedAt":"2014-02-15T02:01:49Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n compat/fnmatch/fnmatch.c (gone) | 494 ----------------------------------------\n compat/fnmatch/fnmatch.h (gone) |  84 -------\n 2 files changed, 578 deletions(-)\n\ndiff --git a/compat/fnmatch/fnmatch.c b/compat/fnmatch/fnmatch.c\ndeleted file mode 100644\nindex 378c467..0000000\n--- a/compat/fnmatch/fnmatch.c\n+++ /dev/null\n@@ -1,494 +0,0 @@\n-/* Copyright (C) 1991, 92, 93, 96, 97, 98, 99 Free Software Foundation, Inc.\n-   This file is part of the GNU C Library.\n-\n-   This library is free software; you can redistribute it and/or\n-   modify it under the terms of the GNU Library General Public License as\n-   published by the Free Software Foundation; either version 2 of the\n-   License, or (at your option) any later version.\n-\n-   This library is distributed in the hope that it will be useful,\n-   but WITHOUT ANY WARRANTY; without even the implied warranty of\n-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n-   Library General Public License for more details.\n-\n-   You should have received a copy of the GNU Library General Public\n-   License along with this library; see the file COPYING.LIB.  If not,\n-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n-   Boston, MA 02111-1307, USA.  */\n-\n-#if HAVE_CONFIG_H\n-# include <config.h>\n-#endif\n-\n-/* Enable GNU extensions in fnmatch.h.  */\n-#ifndef _GNU_SOURCE\n-# define _GNU_SOURCE\t1\n-#endif\n-\n-#include <stddef.h>\n-#include <errno.h>\n-#include <fnmatch.h>\n-#include <ctype.h>\n-\n-#if HAVE_STRING_H || defined _LIBC\n-# include <string.h>\n-#else\n-# include <strings.h>\n-#endif\n-\n-#if defined STDC_HEADERS || defined _LIBC\n-# include <stdlib.h>\n-#endif\n-\n-/* For platforms which support the ISO C amendment 1 functionality we\n-   support user defined character classes.  */\n-#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)\n-/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.  */\n-# include <wchar.h>\n-# include <wctype.h>\n-#endif\n-\n-/* Comment out all this code if we are using the GNU C Library, and are not\n-   actually compiling the library itself.  This code is part of the GNU C\n-   Library, but also included in many other GNU distributions.  Compiling\n-   and linking in this code is a waste when using the GNU C library\n-   (especially if it is a shared library).  Rather than having every GNU\n-   program understand `configure --with-gnu-libc' and omit the object files,\n-   it is simpler to just do this in the source for each such file.  */\n-\n-#if defined NO_FNMATCH || defined NO_FNMATCH_CASEFOLD || \\\n-    defined _LIBC || !defined __GNU_LIBRARY__\n-\n-\n-# if defined STDC_HEADERS || !defined isascii\n-#  define ISASCII(c) 1\n-# else\n-#  define ISASCII(c) isascii(c)\n-# endif\n-\n-# ifdef isblank\n-#  define ISBLANK(c) (ISASCII (c) && isblank (c))\n-# else\n-#  define ISBLANK(c) ((c) == ' ' || (c) == '\\t')\n-# endif\n-# ifdef isgraph\n-#  define ISGRAPH(c) (ISASCII (c) && isgraph (c))\n-# else\n-#  define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))\n-# endif\n-\n-# define ISPRINT(c) (ISASCII (c) && isprint (c))\n-# define ISDIGIT(c) (ISASCII (c) && isdigit (c))\n-# define ISALNUM(c) (ISASCII (c) && isalnum (c))\n-# define ISALPHA(c) (ISASCII (c) && isalpha (c))\n-# define ISCNTRL(c) (ISASCII (c) && iscntrl (c))\n-# define ISLOWER(c) (ISASCII (c) && islower (c))\n-# define ISPUNCT(c) (ISASCII (c) && ispunct (c))\n-# define ISSPACE(c) (ISASCII (c) && isspace (c))\n-# define ISUPPER(c) (ISASCII (c) && isupper (c))\n-# define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))\n-\n-# define STREQ(s1, s2) ((strcmp (s1, s2) == 0))\n-\n-# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)\n-/* The GNU C library provides support for user-defined character classes\n-   and the functions from ISO C amendment 1.  */\n-#  ifdef CHARCLASS_NAME_MAX\n-#   define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX\n-#  else\n-/* This shouldn't happen but some implementation might still have this\n-   problem.  Use a reasonable default value.  */\n-#   define CHAR_CLASS_MAX_LENGTH 256\n-#  endif\n-\n-#  ifdef _LIBC\n-#   define IS_CHAR_CLASS(string) __wctype (string)\n-#  else\n-#   define IS_CHAR_CLASS(string) wctype (string)\n-#  endif\n-# else\n-#  define CHAR_CLASS_MAX_LENGTH  6 /* Namely, `xdigit'.  */\n-\n-#  define IS_CHAR_CLASS(string)\t\t\t\t\t\t      \\\n-   (STREQ (string, \"alpha\") || STREQ (string, \"upper\")\t\t\t      \\\n-    || STREQ (string, \"lower\") || STREQ (string, \"digit\")\t\t      \\\n-    || STREQ (string, \"alnum\") || STREQ (string, \"xdigit\")\t\t      \\\n-    || STREQ (string, \"space\") || STREQ (string, \"print\")\t\t      \\\n-    || STREQ (string, \"punct\") || STREQ (string, \"graph\")\t\t      \\\n-    || STREQ (string, \"cntrl\") || STREQ (string, \"blank\"))\n-# endif\n-\n-/* Avoid depending on library functions or files\n-   whose names are inconsistent.  */\n-\n-# if !defined _LIBC && !defined getenv\n-extern char *getenv (const char *name);\n-# endif\n-\n-# ifndef errno\n-extern int errno;\n-# endif\n-\n-# ifndef NULL\n-#  define NULL 0\n-# endif\n-\n-/* This function doesn't exist on most systems.  */\n-\n-# if !defined HAVE___STRCHRNUL && !defined _LIBC\n-static char *\n-__strchrnul (const char *s, int c)\n-\n-\n-{\n-  char *result = strchr (s, c);\n-  if (result == NULL)\n-    result = strchr (s, '\\0');\n-  return result;\n-}\n-# endif\n-\n-# ifndef internal_function\n-/* Inside GNU libc we mark some function in a special way.  In other\n-   environments simply ignore the marking.  */\n-#  define internal_function\n-# endif\n-\n-/* Match STRING against the filename pattern PATTERN, returning zero if\n-   it matches, nonzero if not.  */\n-static int internal_fnmatch __P ((const char *pattern, const char *string,\n-\t\t\t\t  int no_leading_period, int flags))\n-     internal_function;\n-static int\n-internal_function\n-internal_fnmatch (const char *pattern, const char *string, int no_leading_period, int flags)\n-\n-\n-\n-\n-{\n-  register const char *p = pattern, *n = string;\n-  register unsigned char c;\n-\n-/* Note that this evaluates C many times.  */\n-# ifdef _LIBC\n-#  define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))\n-# else\n-#  define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))\n-# endif\n-\n-  while ((c = *p++) != '\\0')\n-    {\n-      c = FOLD (c);\n-\n-      switch (c)\n-\t{\n-\tcase '?':\n-\t  if (*n == '\\0')\n-\t    return FNM_NOMATCH;\n-\t  else if (*n == '/' && (flags & FNM_FILE_NAME))\n-\t    return FNM_NOMATCH;\n-\t  else if (*n == '.' && no_leading_period\n-\t\t   && (n == string\n-\t\t       || (n[-1] == '/' && (flags & FNM_FILE_NAME))))\n-\t    return FNM_NOMATCH;\n-\t  break;\n-\n-\tcase '\\\\':\n-\t  if (!(flags & FNM_NOESCAPE))\n-\t    {\n-\t      c = *p++;\n-\t      if (c == '\\0')\n-\t\t/* Trailing \\ loses.  */\n-\t\treturn FNM_NOMATCH;\n-\t      c = FOLD (c);\n-\t    }\n-\t  if (FOLD ((unsigned char) *n) != c)\n-\t    return FNM_NOMATCH;\n-\t  break;\n-\n-\tcase '*':\n-\t  if (*n == '.' && no_leading_period\n-\t      && (n == string\n-\t\t  || (n[-1] == '/' && (flags & FNM_FILE_NAME))))\n-\t    return FNM_NOMATCH;\n-\n-\t  for (c = *p++; c == '?' || c == '*'; c = *p++)\n-\t    {\n-\t      if (*n == '/' && (flags & FNM_FILE_NAME))\n-\t\t/* A slash does not match a wildcard under FNM_FILE_NAME.  */\n-\t\treturn FNM_NOMATCH;\n-\t      else if (c == '?')\n-\t\t{\n-\t\t  /* A ? needs to match one character.  */\n-\t\t  if (*n == '\\0')\n-\t\t    /* There isn't another character; no match.  */\n-\t\t    return FNM_NOMATCH;\n-\t\t  else\n-\t\t    /* One character of the string is consumed in matching\n-\t\t       this ? wildcard, so *??? won't match if there are\n-\t\t       less than three characters.  */\n-\t\t    ++n;\n-\t\t}\n-\t    }\n-\n-\t  if (c == '\\0')\n-\t    /* The wildcard(s) is/are the last element of the pattern.\n-\t       If the name is a file name and contains another slash\n-\t       this does mean it cannot match.  */\n-\t    return ((flags & FNM_FILE_NAME) && strchr (n, '/') != NULL\n-\t\t    ? FNM_NOMATCH : 0);\n-\t  else\n-\t    {\n-\t      const char *endp;\n-\n-\t      endp = __strchrnul (n, (flags & FNM_FILE_NAME) ? '/' : '\\0');\n-\n-\t      if (c == '[')\n-\t\t{\n-\t\t  int flags2 = ((flags & FNM_FILE_NAME)\n-\t\t\t\t? flags : (flags & ~FNM_PERIOD));\n-\n-\t\t  for (--p; n < endp; ++n)\n-\t\t    if (internal_fnmatch (p, n,\n-\t\t\t\t\t  (no_leading_period\n-\t\t\t\t\t   && (n == string\n-\t\t\t\t\t       || (n[-1] == '/'\n-\t\t\t\t\t\t   && (flags\n-\t\t\t\t\t\t       & FNM_FILE_NAME)))),\n-\t\t\t\t\t  flags2)\n-\t\t\t== 0)\n-\t\t      return 0;\n-\t\t}\n-\t      else if (c == '/' && (flags & FNM_FILE_NAME))\n-\t\t{\n-\t\t  while (*n != '\\0' && *n != '/')\n-\t\t    ++n;\n-\t\t  if (*n == '/'\n-\t\t      && (internal_fnmatch (p, n + 1, flags & FNM_PERIOD,\n-\t\t\t\t\t    flags) == 0))\n-\t\t    return 0;\n-\t\t}\n-\t      else\n-\t\t{\n-\t\t  int flags2 = ((flags & FNM_FILE_NAME)\n-\t\t\t\t? flags : (flags & ~FNM_PERIOD));\n-\n-\t\t  if (c == '\\\\' && !(flags & FNM_NOESCAPE))\n-\t\t    c = *p;\n-\t\t  c = FOLD (c);\n-\t\t  for (--p; n < endp; ++n)\n-\t\t    if (FOLD ((unsigned char) *n) == c\n-\t\t\t&& (internal_fnmatch (p, n,\n-\t\t\t\t\t      (no_leading_period\n-\t\t\t\t\t       && (n == string\n-\t\t\t\t\t\t   || (n[-1] == '/'\n-\t\t\t\t\t\t       && (flags\n-\t\t\t\t\t\t\t   & FNM_FILE_NAME)))),\n-\t\t\t\t\t      flags2) == 0))\n-\t\t      return 0;\n-\t\t}\n-\t    }\n-\n-\t  /* If we come here no match is possible with the wildcard.  */\n-\t  return FNM_NOMATCH;\n-\n-\tcase '[':\n-\t  {\n-\t    /* Nonzero if the sense of the character class is inverted.  */\n-\t    static int posixly_correct;\n-\t    register int not;\n-\t    char cold;\n-\n-\t    if (posixly_correct == 0)\n-\t      posixly_correct = getenv (\"POSIXLY_CORRECT\") != NULL ? 1 : -1;\n-\n-\t    if (*n == '\\0')\n-\t      return FNM_NOMATCH;\n-\n-\t    if (*n == '.' && no_leading_period && (n == string\n-\t\t\t\t\t\t   || (n[-1] == '/'\n-\t\t\t\t\t\t       && (flags\n-\t\t\t\t\t\t\t   & FNM_FILE_NAME))))\n-\t      return FNM_NOMATCH;\n-\n-\t    if (*n == '/' && (flags & FNM_FILE_NAME))\n-\t      /* `/' cannot be matched.  */\n-\t      return FNM_NOMATCH;\n-\n-\t    not = (*p == '!' || (posixly_correct < 0 && *p == '^'));\n-\t    if (not)\n-\t      ++p;\n-\n-\t    c = *p++;\n-\t    for (;;)\n-\t      {\n-\t\tunsigned char fn = FOLD ((unsigned char) *n);\n-\n-\t\tif (!(flags & FNM_NOESCAPE) && c == '\\\\')\n-\t\t  {\n-\t\t    if (*p == '\\0')\n-\t\t      return FNM_NOMATCH;\n-\t\t    c = FOLD ((unsigned char) *p);\n-\t\t    ++p;\n-\n-\t\t    if (c == fn)\n-\t\t      goto matched;\n-\t\t  }\n-\t\telse if (c == '[' && *p == ':')\n-\t\t  {\n-\t\t    /* Leave room for the null.  */\n-\t\t    char str[CHAR_CLASS_MAX_LENGTH + 1];\n-\t\t    size_t c1 = 0;\n-# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)\n-\t\t    wctype_t wt;\n-# endif\n-\t\t    const char *startp = p;\n-\n-\t\t    for (;;)\n-\t\t      {\n-\t\t\tif (c1 > CHAR_CLASS_MAX_LENGTH)\n-\t\t\t  /* The name is too long and therefore the pattern\n-\t\t\t     is ill-formed.  */\n-\t\t\t  return FNM_NOMATCH;\n-\n-\t\t\tc = *++p;\n-\t\t\tif (c == ':' && p[1] == ']')\n-\t\t\t  {\n-\t\t\t    p += 2;\n-\t\t\t    break;\n-\t\t\t  }\n-\t\t\tif (c < 'a' || c >= 'z')\n-\t\t\t  {\n-\t\t\t    /* This cannot possibly be a character class name.\n-\t\t\t       Match it as a normal range.  */\n-\t\t\t    p = startp;\n-\t\t\t    c = '[';\n-\t\t\t    goto normal_bracket;\n-\t\t\t  }\n-\t\t\tstr[c1++] = c;\n-\t\t      }\n-\t\t    str[c1] = '\\0';\n-\n-# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)\n-\t\t    wt = IS_CHAR_CLASS (str);\n-\t\t    if (wt == 0)\n-\t\t      /* Invalid character class name.  */\n-\t\t      return FNM_NOMATCH;\n-\n-\t\t    if (__iswctype (__btowc ((unsigned char) *n), wt))\n-\t\t      goto matched;\n-# else\n-\t\t    if ((STREQ (str, \"alnum\") && ISALNUM ((unsigned char) *n))\n-\t\t\t|| (STREQ (str, \"alpha\") && ISALPHA ((unsigned char) *n))\n-\t\t\t|| (STREQ (str, \"blank\") && ISBLANK ((unsigned char) *n))\n-\t\t\t|| (STREQ (str, \"cntrl\") && ISCNTRL ((unsigned char) *n))\n-\t\t\t|| (STREQ (str, \"digit\") && ISDIGIT ((unsigned char) *n))\n-\t\t\t|| (STREQ (str, \"graph\") && ISGRAPH ((unsigned char) *n))\n-\t\t\t|| (STREQ (str, \"lower\") && ISLOWER ((unsigned char) *n))\n-\t\t\t|| (STREQ (str, \"print\") && ISPRINT ((unsigned char) *n))\n-\t\t\t|| (STREQ (str, \"punct\") && ISPUNCT ((unsigned char) *n))\n-\t\t\t|| (STREQ (str, \"space\") && ISSPACE ((unsigned char) *n))\n-\t\t\t|| (STREQ (str, \"upper\") && ISUPPER ((unsigned char) *n))\n-\t\t\t|| (STREQ (str, \"xdigit\") && ISXDIGIT ((unsigned char) *n)))\n-\t\t      goto matched;\n-# endif\n-\t\t  }\n-\t\telse if (c == '\\0')\n-\t\t  /* [ (unterminated) loses.  */\n-\t\t  return FNM_NOMATCH;\n-\t\telse\n-\t\t  {\n-\t\t  normal_bracket:\n-\t\t    if (FOLD (c) == fn)\n-\t\t      goto matched;\n-\n-\t\t    cold = c;\n-\t\t    c = *p++;\n-\n-\t\t    if (c == '-' && *p != ']')\n-\t\t      {\n-\t\t\t/* It is a range.  */\n-\t\t\tunsigned char cend = *p++;\n-\t\t\tif (!(flags & FNM_NOESCAPE) && cend == '\\\\')\n-\t\t\t  cend = *p++;\n-\t\t\tif (cend == '\\0')\n-\t\t\t  return FNM_NOMATCH;\n-\n-\t\t\tif (cold <= fn && fn <= FOLD (cend))\n-\t\t\t  goto matched;\n-\n-\t\t\tc = *p++;\n-\t\t      }\n-\t\t  }\n-\n-\t\tif (c == ']')\n-\t\t  break;\n-\t      }\n-\n-\t    if (!not)\n-\t      return FNM_NOMATCH;\n-\t    break;\n-\n-\t  matched:\n-\t    /* Skip the rest of the [...] that already matched.  */\n-\t    while (c != ']')\n-\t      {\n-\t\tif (c == '\\0')\n-\t\t  /* [... (unterminated) loses.  */\n-\t\t  return FNM_NOMATCH;\n-\n-\t\tc = *p++;\n-\t\tif (!(flags & FNM_NOESCAPE) && c == '\\\\')\n-\t\t  {\n-\t\t    if (*p == '\\0')\n-\t\t      return FNM_NOMATCH;\n-\t\t    /* XXX 1003.2d11 is unclear if this is right.  */\n-\t\t    ++p;\n-\t\t  }\n-\t\telse if (c == '[' && *p == ':')\n-\t\t  {\n-\t\t    do\n-\t\t      if (*++p == '\\0')\n-\t\t\treturn FNM_NOMATCH;\n-\t\t    while (*p != ':' || p[1] == ']');\n-\t\t    p += 2;\n-\t\t    c = *p;\n-\t\t  }\n-\t      }\n-\t    if (not)\n-\t      return FNM_NOMATCH;\n-\t  }\n-\t  break;\n-\n-\tdefault:\n-\t  if (c != FOLD ((unsigned char) *n))\n-\t    return FNM_NOMATCH;\n-\t}\n-\n-      ++n;\n-    }\n-\n-  if (*n == '\\0')\n-    return 0;\n-\n-  if ((flags & FNM_LEADING_DIR) && *n == '/')\n-    /* The FNM_LEADING_DIR flag says that \"foo*\" matches \"foobar/frobozz\".  */\n-    return 0;\n-\n-  return FNM_NOMATCH;\n-\n-# undef FOLD\n-}\n-\n-\n-int\n-fnmatch (const char *pattern, const char *string, int flags)\n-\n-\n-\n-{\n-  return internal_fnmatch (pattern, string, flags & FNM_PERIOD, flags);\n-}\n-\n-#endif\t/* _LIBC or not __GNU_LIBRARY__.  */\ndiff --git a/compat/fnmatch/fnmatch.h b/compat/fnmatch/fnmatch.h\ndeleted file mode 100644\nindex cc3ec37..0000000\n--- a/compat/fnmatch/fnmatch.h\n+++ /dev/null\n@@ -1,84 +0,0 @@\n-/* Copyright (C) 1991, 92, 93, 96, 97, 98, 99 Free Software Foundation, Inc.\n-   This file is part of the GNU C Library.\n-\n-   The GNU C Library is free software; you can redistribute it and/or\n-   modify it under the terms of the GNU Library General Public License as\n-   published by the Free Software Foundation; either version 2 of the\n-   License, or (at your option) any later version.\n-\n-   The GNU C Library is distributed in the hope that it will be useful,\n-   but WITHOUT ANY WARRANTY; without even the implied warranty of\n-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n-   Library General Public License for more details.\n-\n-   You should have received a copy of the GNU Library General Public\n-   License along with the GNU C Library; see the file COPYING.LIB.  If not,\n-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n-   Boston, MA 02111-1307, USA.  */\n-\n-#ifndef\t_FNMATCH_H\n-#define\t_FNMATCH_H\t1\n-\n-#ifdef\t__cplusplus\n-extern \"C\" {\n-#endif\n-\n-#if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32\n-# if !defined __GLIBC__ || !defined __P\n-#  undef\t__P\n-#  define __P(protos)\tprotos\n-# endif\n-#else /* Not C++ or ANSI C.  */\n-# undef\t__P\n-# define __P(protos)\t()\n-/* We can get away without defining `const' here only because in this file\n-   it is used only inside the prototype for `fnmatch', which is elided in\n-   non-ANSI C where `const' is problematical.  */\n-#endif /* C++ or ANSI C.  */\n-\n-#ifndef const\n-# if (defined __STDC__ && __STDC__) || defined __cplusplus\n-#  define __const\tconst\n-# else\n-#  define __const\n-# endif\n-#endif\n-\n-/* We #undef these before defining them because some losing systems\n-   (HP-UX A.08.07 for example) define these in <unistd.h>.  */\n-#undef\tFNM_PATHNAME\n-#undef\tFNM_NOESCAPE\n-#undef\tFNM_PERIOD\n-\n-/* Bits set in the FLAGS argument to `fnmatch'.  */\n-#define\tFNM_PATHNAME\t(1 << 0) /* No wildcard can ever match `/'.  */\n-#define\tFNM_NOESCAPE\t(1 << 1) /* Backslashes don't quote special chars.  */\n-#define\tFNM_PERIOD\t(1 << 2) /* Leading `.' is matched only explicitly.  */\n-\n-#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE\n-# define FNM_FILE_NAME\t FNM_PATHNAME\t/* Preferred GNU name.  */\n-# define FNM_LEADING_DIR (1 << 3)\t/* Ignore `/...' after a match.  */\n-# define FNM_CASEFOLD\t (1 << 4)\t/* Compare without regard to case.  */\n-#endif\n-\n-/* Value returned by `fnmatch' if STRING does not match PATTERN.  */\n-#define\tFNM_NOMATCH\t1\n-\n-/* This value is returned if the implementation does not support\n-   `fnmatch'.  Since this is not the case here it will never be\n-   returned but the conformance test suites still require the symbol\n-   to be defined.  */\n-#ifdef _XOPEN_SOURCE\n-# define FNM_NOSYS\t(-1)\n-#endif\n-\n-/* Match NAME against the filename pattern PATTERN,\n-   returning zero if it matches, FNM_NOMATCH if not.  */\n-extern int fnmatch __P ((__const char *__pattern, __const char *__name,\n-\t\t\t int __flags));\n-\n-#ifdef\t__cplusplus\n-}\n-#endif\n-\n-#endif /* fnmatch.h */\n-- \n1.8.5.2.240.g8478abd\n"},{"id":"234843","messageId":"8761og3htv.fsf@fencepost.gnu.org","threadId":"35876","inReplyTo":"1392429709-9237-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 0/4] Good bye fnmatch","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2014-02-15T08:23:24Z","receivedAt":"2014-02-15T08:23:24Z","isPatch":true,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:\n\n> Long story short, we wanted globbing wildcard \"**\" so I ripped\n> wildmatch library from rsync to do it.\n\nSince version 3.0.0, rsync is GPLv3\n<URL:https://rsync.samba.org/GPL.html>.  So be sure to take an older\nversion.\n\n> And it opened a possibility to replace fnmatch completely, which would\n> provide consistent behavior across platforms (native fnmatch behaves\n> differently on many corner cases), and some performance gains. I\n> started fnmatch replacement with 4917e1e (Makefile: promote wildmatch\n> to be the default fnmatch implementation - 2013-05-30). This is the\n> final step.\n\nSounds like I'm, uh, somewhat late in the game.  More likely than not\nyou've taken care of that aspect long ago.  Just thought I'd mention it.\n\n-- \nDavid Kastrup\n"},{"id":"234844","messageId":"CACsJy8C+3AED3p0sWb91gq6tY4zAH+k0SdMv0RkpeqJPzL+naw@mail.gmail.com","threadId":"35876","inReplyTo":"8761og3htv.fsf@fencepost.gnu.org","subject":"Re: [PATCH 0/4] Good bye fnmatch","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2014-02-15T08:29:39Z","receivedAt":"2014-02-15T08:29:39Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Feb 15, 2014 at 3:23 PM, David Kastrup <dak@gnu.org> wrote:\n> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:\n>\n>> Long story short, we wanted globbing wildcard \"**\" so I ripped\n>> wildmatch library from rsync to do it.\n>\n> Since version 3.0.0, rsync is GPLv3\n> <URL:https://rsync.samba.org/GPL.html>.  So be sure to take an older\n> version.\n\nYes. See 5230f60 (Import wildmatch from rsync - 2012-10-15), the code\nwas taken from the last GPL-2 commit.\n-- \nDuy\n"},{"id":"234845","messageId":"871tz43glm.fsf@fencepost.gnu.org","threadId":"35876","inReplyTo":"CACsJy8C+3AED3p0sWb91gq6tY4zAH+k0SdMv0RkpeqJPzL+naw@mail.gmail.com","subject":"Re: [PATCH 0/4] Good bye fnmatch","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2014-02-15T08:49:57Z","receivedAt":"2014-02-15T08:49:57Z","isPatch":true,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> On Sat, Feb 15, 2014 at 3:23 PM, David Kastrup <dak@gnu.org> wrote:\n>> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:\n>>\n>>> Long story short, we wanted globbing wildcard \"**\" so I ripped\n>>> wildmatch library from rsync to do it.\n>>\n>> Since version 3.0.0, rsync is GPLv3\n>> <URL:https://rsync.samba.org/GPL.html>.  So be sure to take an older\n>> version.\n>\n> Yes. See 5230f60 (Import wildmatch from rsync - 2012-10-15), the code\n> was taken from the last GPL-2 commit.\n\nThanks.\n\n-- \nDavid Kastrup\n"},{"id":"235005","messageId":"xmqq38jgfcft.fsf@gitster.dls.corp.google.com","threadId":"35876","inReplyTo":"1392429709-9237-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 0/4] Good bye fnmatch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-02-18T19:28:06Z","receivedAt":"2014-02-18T19:28:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> Long story short, we wanted globbing wildcard \"**\" so I ripped\n> wildmatch library from rsync to do it. And it opened a possibility\n> to replace fnmatch completely, which would provide consistent behavior\n> across platforms (native fnmatch behaves differently on many corner\n> cases), and some performance gains. I started fnmatch replacement with\n> 4917e1e (Makefile: promote wildmatch to be the default fnmatch\n> implementation - 2013-05-30). This is the final step.\n\nNice.\n\n>\n> Nguyễn Thái Ngọc Duy (4):\n>   Use wildmatch() directly without fnmatch() wrapper\n>   Revert \"test-wildmatch: add \"perf\" command to compare wildmatch and fnmatch\"\n>   Stop using fnmatch (either native or compat)\n>   Actually remove compat fnmatch source code\n>\n>  Makefile                        |  22 --\n>  builtin/apply.c                 |   2 +-\n>  builtin/branch.c                |   2 +-\n>  builtin/describe.c              |   2 +-\n>  builtin/for-each-ref.c          |   2 +-\n>  builtin/ls-remote.c             |   2 +-\n>  builtin/name-rev.c              |   2 +-\n>  builtin/reflog.c                |   2 +-\n>  builtin/replace.c               |   2 +-\n>  builtin/show-branch.c           |   2 +-\n>  builtin/tag.c                   |   2 +-\n>  compat/fnmatch/fnmatch.c (gone) | 494 ----------------------------------------\n>  compat/fnmatch/fnmatch.h (gone) |  84 -------\n>  config.mak.uname                |  10 -\n>  configure.ac                    |  28 ---\n>  diffcore-order.c                |   2 +-\n>  dir.c                           |  11 +-\n>  git-compat-util.h               |  12 -\n>  refs.c                          |   2 +-\n>  revision.c                      |   2 +-\n>  t/t3070-wildmatch.sh            |  13 --\n>  test-wildmatch.c                |  79 -------\n>  22 files changed, 20 insertions(+), 759 deletions(-)\n"}]}