Skip to content

Commit

Permalink
Makefile: add USE_WILDMATCH to use wildmatch as fnmatch
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
pclouds authored and gitster committed Jan 1, 2013
1 parent 6f1a31f commit cebcab1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Makefile
Expand Up @@ -99,6 +99,9 @@ all::
# Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the # Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
# FNM_CASEFOLD GNU extension. # FNM_CASEFOLD GNU extension.
# #
# Define USE_WILDMATCH if you want to use Git's wildmatch
# implementation as fnmatch
#
# Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd # Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd
# in the C library. # in the C library.
# #
Expand Down Expand Up @@ -1625,6 +1628,9 @@ ifdef NO_FNMATCH_CASEFOLD
COMPAT_OBJS += compat/fnmatch/fnmatch.o COMPAT_OBJS += compat/fnmatch/fnmatch.o
endif endif
endif endif
ifdef USE_WILDMATCH
COMPAT_CFLAGS += -DUSE_WILDMATCH
endif
ifdef NO_SETENV ifdef NO_SETENV
COMPAT_CFLAGS += -DNO_SETENV COMPAT_CFLAGS += -DNO_SETENV
COMPAT_OBJS += compat/setenv.o COMPAT_OBJS += compat/setenv.o
Expand Down
13 changes: 13 additions & 0 deletions git-compat-util.h
Expand Up @@ -106,7 +106,9 @@
#include <sys/time.h> #include <sys/time.h>
#include <time.h> #include <time.h>
#include <signal.h> #include <signal.h>
#ifndef USE_WILDMATCH
#include <fnmatch.h> #include <fnmatch.h>
#endif
#include <assert.h> #include <assert.h>
#include <regex.h> #include <regex.h>
#include <utime.h> #include <utime.h>
Expand Down Expand Up @@ -238,6 +240,17 @@ extern char *gitbasename(char *);


#include "compat/bswap.h" #include "compat/bswap.h"


#ifdef USE_WILDMATCH
#include "wildmatch.h"
#define FNM_PATHNAME WM_PATHNAME
#define FNM_CASEFOLD WM_CASEFOLD
#define FNM_NOMATCH WM_NOMATCH
static inline int fnmatch(const char *pattern, const char *string, int flags)
{
return wildmatch(pattern, string, flags, NULL);
}
#endif

/* General helper functions */ /* General helper functions */
extern void vreportf(const char *prefix, const char *err, va_list params); extern void vreportf(const char *prefix, const char *err, va_list params);
extern void vwritef(int fd, const char *prefix, const char *err, va_list params); extern void vwritef(int fd, const char *prefix, const char *err, va_list params);
Expand Down
3 changes: 3 additions & 0 deletions test-wildmatch.c
@@ -1,3 +1,6 @@
#ifdef USE_WILDMATCH
#undef USE_WILDMATCH /* We need real fnmatch implementation here */
#endif
#include "cache.h" #include "cache.h"
#include "wildmatch.h" #include "wildmatch.h"


Expand Down

0 comments on commit cebcab1

Please sign in to comment.