stop using fnmatch (either native or compat)
Since v1.8.4 (about six months ago) wildmatch is used as default replacement for fnmatch. We have seen only one fix since so wildmatch probably has done a good job as fnmatch replacement. This concludes the fnmatch->wildmatch transition by no longer relying on fnmatch. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Feb 15, 2014 at 09:01 UTC
70a8fc999d9f0afbc793b21bbb911ecde4e24367
6 files changed
-91
Makefile
-22
@@ -101,14 +101,6 @@ all::
101
#
102
# Define NO_MKSTEMPS if you don't have mkstemps in the C library.
103
#
104
-# Define NO_FNMATCH if you don't have fnmatch in the C library.
105
-#
106
-# Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
107
-# FNM_CASEFOLD GNU extension.
108
-#
109
-# Define NO_WILDMATCH if you do not want to use Git's wildmatch
110
-# implementation as fnmatch
111
-#
104
# Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd
105
# in the C library.
106
#
@@ -1271,20 +1263,6 @@ endif
1263
ifdef NO_STRTOULL
1264
COMPAT_CFLAGS += -DNO_STRTOULL
1265
endif
1274
-ifdef NO_FNMATCH
1275
- COMPAT_CFLAGS += -Icompat/fnmatch
1276
- COMPAT_CFLAGS += -DNO_FNMATCH
1277
- COMPAT_OBJS += compat/fnmatch/fnmatch.o
1278
-else
1279
-ifdef NO_FNMATCH_CASEFOLD
1280
- COMPAT_CFLAGS += -Icompat/fnmatch
1281
- COMPAT_CFLAGS += -DNO_FNMATCH_CASEFOLD
1282
- COMPAT_OBJS += compat/fnmatch/fnmatch.o
1283
-endif
1284
-endif
1285
-ifndef NO_WILDMATCH
1286
- COMPAT_CFLAGS += -DUSE_WILDMATCH
1287
-endif
1266
ifdef NO_SETENV
1267
COMPAT_CFLAGS += -DNO_SETENV
1268
COMPAT_OBJS += compat/setenv.o
config.mak.uname
-10
@@ -108,7 +108,6 @@ ifeq ($(uname_S),SunOS)
108
NO_MKDTEMP = YesPlease
109
NO_MKSTEMPS = YesPlease
110
NO_REGEX = YesPlease
111
- NO_FNMATCH_CASEFOLD = YesPlease
111
NO_MSGFMT_EXTENDED_OPTIONS = YesPlease
112
HAVE_DEV_TTY = YesPlease
113
ifeq ($(uname_R),5.6)
@@ -259,7 +258,6 @@ ifeq ($(uname_S),IRIX)
258
# issue, comment out the NO_MMAP statement.
259
NO_MMAP = YesPlease
260
NO_REGEX = YesPlease
262
- NO_FNMATCH_CASEFOLD = YesPlease
261
SNPRINTF_RETURNS_BOGUS = YesPlease
262
SHELL_PATH = /usr/gnu/bin/bash
263
NEEDS_LIBGEN = YesPlease
@@ -279,7 +277,6 @@ ifeq ($(uname_S),IRIX64)
277
# issue, comment out the NO_MMAP statement.
278
NO_MMAP = YesPlease
279
NO_REGEX = YesPlease
282
- NO_FNMATCH_CASEFOLD = YesPlease
280
SNPRINTF_RETURNS_BOGUS = YesPlease
281
SHELL_PATH = /usr/gnu/bin/bash
282
NEEDS_LIBGEN = YesPlease
@@ -296,7 +293,6 @@ ifeq ($(uname_S),HP-UX)
293
NO_UNSETENV = YesPlease
294
NO_HSTRERROR = YesPlease
295
NO_SYS_SELECT_H = YesPlease
299
- NO_FNMATCH_CASEFOLD = YesPlease
296
SNPRINTF_RETURNS_BOGUS = YesPlease
297
NO_NSEC = YesPlease
298
ifeq ($(uname_R),B.11.00)
@@ -327,7 +323,6 @@ ifeq ($(uname_S),Windows)
323
NO_UNSETENV = YesPlease
324
NO_STRCASESTR = YesPlease
325
NO_STRLCPY = YesPlease
330
- NO_FNMATCH = YesPlease
326
NO_MEMMEM = YesPlease
327
# NEEDS_LIBICONV = YesPlease
328
NO_ICONV = YesPlease
@@ -389,13 +384,11 @@ ifeq ($(uname_S),Interix)
384
NO_INET_NTOP = YesPlease
385
NO_INET_PTON = YesPlease
386
NO_SOCKADDR_STORAGE = YesPlease
392
- NO_FNMATCH_CASEFOLD = YesPlease
387
endif
388
ifeq ($(uname_R),5.2)
389
NO_INET_NTOP = YesPlease
390
NO_INET_PTON = YesPlease
391
NO_SOCKADDR_STORAGE = YesPlease
398
- NO_FNMATCH_CASEFOLD = YesPlease
392
endif
393
endif
394
ifeq ($(uname_S),Minix)
@@ -440,7 +433,6 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
433
NO_D_TYPE_IN_DIRENT = YesPlease
434
NO_HSTRERROR = YesPlease
435
NO_STRCASESTR = YesPlease
443
- NO_FNMATCH_CASEFOLD = YesPlease
436
NO_MEMMEM = YesPlease
437
NO_STRLCPY = YesPlease
438
NO_SETENV = YesPlease
@@ -484,7 +476,6 @@ ifneq (,$(findstring MINGW,$(uname_S)))
476
NO_UNSETENV = YesPlease
477
NO_STRCASESTR = YesPlease
478
NO_STRLCPY = YesPlease
487
- NO_FNMATCH = YesPlease
479
NO_MEMMEM = YesPlease
480
NEEDS_LIBICONV = YesPlease
481
NO_STRTOUMAX = YesPlease
@@ -538,7 +529,6 @@ ifeq ($(uname_S),QNX)
529
EXPAT_NEEDS_XMLPARSE_H = YesPlease
530
HAVE_STRINGS_H = YesPlease
531
NEEDS_SOCKET = YesPlease
541
- NO_FNMATCH_CASEFOLD = YesPlease
532
NO_GETPAGESIZE = YesPlease
533
NO_ICONV = YesPlease
534
NO_MEMMEM = YesPlease
configure.ac
-28
@@ -901,34 +901,6 @@ GIT_CHECK_FUNC(strcasestr,
901
[NO_STRCASESTR=YesPlease])
902
GIT_CONF_SUBST([NO_STRCASESTR])
903
#
904
-# Define NO_FNMATCH if you don't have fnmatch
905
-GIT_CHECK_FUNC(fnmatch,
906
-[NO_FNMATCH=],
907
-[NO_FNMATCH=YesPlease])
908
-GIT_CONF_SUBST([NO_FNMATCH])
909
-#
910
-# Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
911
-# FNM_CASEFOLD GNU extension.
912
-AC_CACHE_CHECK([whether the fnmatch function supports the FNMATCH_CASEFOLD GNU extension],
913
- [ac_cv_c_excellent_fnmatch], [
914
-AC_EGREP_CPP(yippeeyeswehaveit,
915
- AC_LANG_PROGRAM([
916
-#include <fnmatch.h>
917
-],
918
-[#ifdef FNM_CASEFOLD
919
-yippeeyeswehaveit
920
-#endif
921
-]),
922
- [ac_cv_c_excellent_fnmatch=yes],
923
- [ac_cv_c_excellent_fnmatch=no])
924
-])
925
-if test $ac_cv_c_excellent_fnmatch = yes; then
926
- NO_FNMATCH_CASEFOLD=
927
-else
928
- NO_FNMATCH_CASEFOLD=YesPlease
929
-fi
930
-GIT_CONF_SUBST([NO_FNMATCH_CASEFOLD])
931
-#
904
# Define NO_MEMMEM if you don't have memmem.
905
GIT_CHECK_FUNC(memmem,
906
[NO_MEMMEM=],
git-compat-util.h
-12
@@ -116,9 +116,6 @@
116
#include <sys/time.h>
117
#include <time.h>
118
#include <signal.h>
119
-#ifndef USE_WILDMATCH
120
-#include <fnmatch.h>
121
-#endif
119
#include <assert.h>
120
#include <regex.h>
121
#include <utime.h>
@@ -304,16 +301,7 @@ extern char *gitbasename(char *);
301
302
#include "compat/bswap.h"
303
307
-#ifdef USE_WILDMATCH
304
#include "wildmatch.h"
309
-#define FNM_PATHNAME WM_PATHNAME
310
-#define FNM_CASEFOLD WM_CASEFOLD
311
-#define FNM_NOMATCH WM_NOMATCH
312
-static inline int fnmatch(const char *pattern, const char *string, int flags)
313
-{
314
- return wildmatch(pattern, string, flags, NULL);
315
-}
316
-#endif
305
306
/* General helper functions */
307
extern void vreportf(const char *prefix, const char *err, va_list params);
t/t3070-wildmatch.sh
-13
@@ -14,19 +14,6 @@ match() {
14
! test-wildmatch wildmatch '$3' '$4'
15
"
16
fi
17
- if [ $2 = 1 ]; then
18
- test_expect_success "fnmatch: match '$3' '$4'" "
19
- test-wildmatch fnmatch '$3' '$4'
20
- "
21
- elif [ $2 = 0 ]; then
22
- test_expect_success "fnmatch: no match '$3' '$4'" "
23
- ! test-wildmatch fnmatch '$3' '$4'
24
- "
25
-# else
26
-# test_expect_success BROKEN_FNMATCH "fnmatch: '$3' '$4'" "
27
-# ! test-wildmatch fnmatch '$3' '$4'
28
-# "
29
- fi
17
}
18
19
imatch() {
test-wildmatch.c
-6
@@ -1,8 +1,4 @@
1
-#ifdef USE_WILDMATCH
2
-#undef USE_WILDMATCH /* We need real fnmatch implementation here */
3
-#endif
1
#include "cache.h"
5
-#include "wildmatch.h"
2
3
int main(int argc, char **argv)
4
{
@@ -20,8 +16,6 @@ int main(int argc, char **argv)
16
return !!wildmatch(argv[3], argv[2], WM_PATHNAME | WM_CASEFOLD, NULL);
17
else if (!strcmp(argv[1], "pathmatch"))
18
return !!wildmatch(argv[3], argv[2], 0, NULL);
23
- else if (!strcmp(argv[1], "fnmatch"))
24
- return !!fnmatch(argv[3], argv[2], FNM_PATHNAME);
19
else
20
return 1;
21
}