Makefile: add USE_WILDMATCH to use wildmatch as fnmatch

This is similar to NO_FNMATCH but it uses wildmatch instead of compat/fnmatch. This is an intermediate step to let wildmatch be used as fnmatch replacement for wider audience before it replaces fnmatch completely and compat/fnmatch is removed. fnmatch in test-wildmatch is not impacted by this and is the only place that NO_FNMATCH or NO_FNMATCH_CASEFOLD remain active when USE_WILDMATCH is set. 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 Jan 1, 2013 at 09:44 UTC cebcab189aa7727af5027f0215e798bbe66f2815
3 files changed +22
Makefile
+6
@@ -99,6 +99,9 @@ all::
99 # Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
100 # FNM_CASEFOLD GNU extension.
101 #
102 +# Define USE_WILDMATCH if you want to use Git's wildmatch
103 +# implementation as fnmatch
104 +#
105 # Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd
106 # in the C library.
107 #
@@ -1625,6 +1628,9 @@ ifdef NO_FNMATCH_CASEFOLD
1628 COMPAT_OBJS += compat/fnmatch/fnmatch.o
1629 endif
1630 endif
1631 +ifdef USE_WILDMATCH
1632 + COMPAT_CFLAGS += -DUSE_WILDMATCH
1633 +endif
1634 ifdef NO_SETENV
1635 COMPAT_CFLAGS += -DNO_SETENV
1636 COMPAT_OBJS += compat/setenv.o
git-compat-util.h
+13
@@ -106,7 +106,9 @@
106 #include <sys/time.h>
107 #include <time.h>
108 #include <signal.h>
109 +#ifndef USE_WILDMATCH
110 #include <fnmatch.h>
111 +#endif
112 #include <assert.h>
113 #include <regex.h>
114 #include <utime.h>
@@ -238,6 +240,17 @@ extern char *gitbasename(char *);
240
241 #include "compat/bswap.h"
242
243 +#ifdef USE_WILDMATCH
244 +#include "wildmatch.h"
245 +#define FNM_PATHNAME WM_PATHNAME
246 +#define FNM_CASEFOLD WM_CASEFOLD
247 +#define FNM_NOMATCH WM_NOMATCH
248 +static inline int fnmatch(const char *pattern, const char *string, int flags)
249 +{
250 + return wildmatch(pattern, string, flags, NULL);
251 +}
252 +#endif
253 +
254 /* General helper functions */
255 extern void vreportf(const char *prefix, const char *err, va_list params);
256 extern void vwritef(int fd, const char *prefix, const char *err, va_list params);
test-wildmatch.c
+3
@@ -1,3 +1,6 @@
1 +#ifdef USE_WILDMATCH
2 +#undef USE_WILDMATCH /* We need real fnmatch implementation here */
3 +#endif
4 #include "cache.h"
5 #include "wildmatch.h"
6