Skip to content

Commit 70a8fc9

Browse files
pcloudsgitster
authored andcommitted
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>
1 parent ff88022 commit 70a8fc9

File tree

6 files changed

+0
-91
lines changed

6 files changed

+0
-91
lines changed

Makefile

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,6 @@ all::
101101
#
102102
# Define NO_MKSTEMPS if you don't have mkstemps in the C library.
103103
#
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-
#
112104
# Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd
113105
# in the C library.
114106
#
@@ -1271,20 +1263,6 @@ endif
12711263
ifdef NO_STRTOULL
12721264
COMPAT_CFLAGS += -DNO_STRTOULL
12731265
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
12881266
ifdef NO_SETENV
12891267
COMPAT_CFLAGS += -DNO_SETENV
12901268
COMPAT_OBJS += compat/setenv.o

config.mak.uname

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ ifeq ($(uname_S),SunOS)
108108
NO_MKDTEMP = YesPlease
109109
NO_MKSTEMPS = YesPlease
110110
NO_REGEX = YesPlease
111-
NO_FNMATCH_CASEFOLD = YesPlease
112111
NO_MSGFMT_EXTENDED_OPTIONS = YesPlease
113112
HAVE_DEV_TTY = YesPlease
114113
ifeq ($(uname_R),5.6)
@@ -259,7 +258,6 @@ ifeq ($(uname_S),IRIX)
259258
# issue, comment out the NO_MMAP statement.
260259
NO_MMAP = YesPlease
261260
NO_REGEX = YesPlease
262-
NO_FNMATCH_CASEFOLD = YesPlease
263261
SNPRINTF_RETURNS_BOGUS = YesPlease
264262
SHELL_PATH = /usr/gnu/bin/bash
265263
NEEDS_LIBGEN = YesPlease
@@ -279,7 +277,6 @@ ifeq ($(uname_S),IRIX64)
279277
# issue, comment out the NO_MMAP statement.
280278
NO_MMAP = YesPlease
281279
NO_REGEX = YesPlease
282-
NO_FNMATCH_CASEFOLD = YesPlease
283280
SNPRINTF_RETURNS_BOGUS = YesPlease
284281
SHELL_PATH = /usr/gnu/bin/bash
285282
NEEDS_LIBGEN = YesPlease
@@ -296,7 +293,6 @@ ifeq ($(uname_S),HP-UX)
296293
NO_UNSETENV = YesPlease
297294
NO_HSTRERROR = YesPlease
298295
NO_SYS_SELECT_H = YesPlease
299-
NO_FNMATCH_CASEFOLD = YesPlease
300296
SNPRINTF_RETURNS_BOGUS = YesPlease
301297
NO_NSEC = YesPlease
302298
ifeq ($(uname_R),B.11.00)
@@ -327,7 +323,6 @@ ifeq ($(uname_S),Windows)
327323
NO_UNSETENV = YesPlease
328324
NO_STRCASESTR = YesPlease
329325
NO_STRLCPY = YesPlease
330-
NO_FNMATCH = YesPlease
331326
NO_MEMMEM = YesPlease
332327
# NEEDS_LIBICONV = YesPlease
333328
NO_ICONV = YesPlease
@@ -389,13 +384,11 @@ ifeq ($(uname_S),Interix)
389384
NO_INET_NTOP = YesPlease
390385
NO_INET_PTON = YesPlease
391386
NO_SOCKADDR_STORAGE = YesPlease
392-
NO_FNMATCH_CASEFOLD = YesPlease
393387
endif
394388
ifeq ($(uname_R),5.2)
395389
NO_INET_NTOP = YesPlease
396390
NO_INET_PTON = YesPlease
397391
NO_SOCKADDR_STORAGE = YesPlease
398-
NO_FNMATCH_CASEFOLD = YesPlease
399392
endif
400393
endif
401394
ifeq ($(uname_S),Minix)
@@ -440,7 +433,6 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
440433
NO_D_TYPE_IN_DIRENT = YesPlease
441434
NO_HSTRERROR = YesPlease
442435
NO_STRCASESTR = YesPlease
443-
NO_FNMATCH_CASEFOLD = YesPlease
444436
NO_MEMMEM = YesPlease
445437
NO_STRLCPY = YesPlease
446438
NO_SETENV = YesPlease
@@ -484,7 +476,6 @@ ifneq (,$(findstring MINGW,$(uname_S)))
484476
NO_UNSETENV = YesPlease
485477
NO_STRCASESTR = YesPlease
486478
NO_STRLCPY = YesPlease
487-
NO_FNMATCH = YesPlease
488479
NO_MEMMEM = YesPlease
489480
NEEDS_LIBICONV = YesPlease
490481
NO_STRTOUMAX = YesPlease
@@ -538,7 +529,6 @@ ifeq ($(uname_S),QNX)
538529
EXPAT_NEEDS_XMLPARSE_H = YesPlease
539530
HAVE_STRINGS_H = YesPlease
540531
NEEDS_SOCKET = YesPlease
541-
NO_FNMATCH_CASEFOLD = YesPlease
542532
NO_GETPAGESIZE = YesPlease
543533
NO_ICONV = YesPlease
544534
NO_MEMMEM = YesPlease

configure.ac

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -901,34 +901,6 @@ GIT_CHECK_FUNC(strcasestr,
901901
[NO_STRCASESTR=YesPlease])
902902
GIT_CONF_SUBST([NO_STRCASESTR])
903903
#
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-
#
932904
# Define NO_MEMMEM if you don't have memmem.
933905
GIT_CHECK_FUNC(memmem,
934906
[NO_MEMMEM=],

git-compat-util.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@
116116
#include <sys/time.h>
117117
#include <time.h>
118118
#include <signal.h>
119-
#ifndef USE_WILDMATCH
120-
#include <fnmatch.h>
121-
#endif
122119
#include <assert.h>
123120
#include <regex.h>
124121
#include <utime.h>
@@ -304,16 +301,7 @@ extern char *gitbasename(char *);
304301

305302
#include "compat/bswap.h"
306303

307-
#ifdef USE_WILDMATCH
308304
#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
317305

318306
/* General helper functions */
319307
extern void vreportf(const char *prefix, const char *err, va_list params);

t/t3070-wildmatch.sh

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,6 @@ match() {
1414
! test-wildmatch wildmatch '$3' '$4'
1515
"
1616
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
3017
}
3118

3219
imatch() {

test-wildmatch.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
#ifdef USE_WILDMATCH
2-
#undef USE_WILDMATCH /* We need real fnmatch implementation here */
3-
#endif
41
#include "cache.h"
5-
#include "wildmatch.h"
62

73
int main(int argc, char **argv)
84
{
@@ -20,8 +16,6 @@ int main(int argc, char **argv)
2016
return !!wildmatch(argv[3], argv[2], WM_PATHNAME | WM_CASEFOLD, NULL);
2117
else if (!strcmp(argv[1], "pathmatch"))
2218
return !!wildmatch(argv[3], argv[2], 0, NULL);
23-
else if (!strcmp(argv[1], "fnmatch"))
24-
return !!fnmatch(argv[3], argv[2], FNM_PATHNAME);
2519
else
2620
return 1;
2721
}

0 commit comments

Comments
 (0)