OSDN Git Service

Use compatibility regex library for OSX/Darwin
authorArjen Laarhoven <arjen@yaph.org>
Sun, 7 Sep 2008 18:45:37 +0000 (20:45 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Sep 2008 20:36:40 +0000 (13:36 -0700)
The standard libc regex library on OSX does not support alternation
in POSIX Basic Regular Expression mode.  This breaks the diff.funcname
functionality on OSX.

To fix this, we use the GNU regex library which is already present in
the compat/ diretory for the MinGW port.  However, simply adding compat/
to the COMPAT_CFLAGS variable causes a conflict between the system
fnmatch.h and the one present in compat/.  To remedy this, move the
regex and fnmatch functionality to their own subdirectories in compat/
so they can be included seperately.

Signed-off-by: Arjen Laarhoven <arjen@yaph.org>
Tested-by: Mike Ralphson <mike@abacus.co.uk> (AIX)
Tested-by: Johannes Sixt <johannes.sixt@telecom.at> (MinGW)
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
compat/fnmatch/fnmatch.c [moved from compat/fnmatch.c with 100% similarity]
compat/fnmatch/fnmatch.h [moved from compat/fnmatch.h with 100% similarity]
compat/regex/regex.c [moved from compat/regex.c with 100% similarity]
compat/regex/regex.h [moved from compat/regex.h with 100% similarity]
t/t4018-diff-funcname.sh

index 672ea74..a8b3f9e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -626,6 +626,8 @@ ifeq ($(uname_S),Darwin)
        endif
        NO_STRLCPY = YesPlease
        NO_MEMMEM = YesPlease
+       COMPAT_CFLAGS += -Icompat/regex
+       COMPAT_OBJS += compat/regex/regex.o
 endif
 ifeq ($(uname_S),SunOS)
        NEEDS_SOCKET = YesPlease
@@ -750,10 +752,10 @@ ifneq (,$(findstring MINGW,$(uname_S)))
        NO_SVN_TESTS = YesPlease
        NO_PERL_MAKEMAKER = YesPlease
        NO_POSIX_ONLY_PROGRAMS = YesPlease
-       COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat
+       COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/regex -Icompat/fnmatch
        COMPAT_CFLAGS += -DSNPRINTF_SIZE_CORR=1
        COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
-       COMPAT_OBJS += compat/mingw.o compat/fnmatch.o compat/regex.o compat/winansi.o
+       COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/regex/regex.o compat/winansi.o
        EXTLIBS += -lws2_32
        X = .exe
        gitexecdir = ../libexec/git-core
similarity index 100%
rename from compat/fnmatch.c
rename to compat/fnmatch/fnmatch.c
similarity index 100%
rename from compat/fnmatch.h
rename to compat/fnmatch/fnmatch.h
similarity index 100%
rename from compat/regex.c
rename to compat/regex/regex.c
similarity index 100%
rename from compat/regex.h
rename to compat/regex/regex.h
index 833d6cb..18bcd97 100755 (executable)
@@ -57,4 +57,10 @@ test_expect_success 'last regexp must not be negated' '
        test_must_fail git diff --no-index Beer.java Beer-correct.java
 '
 
+test_expect_success 'alternation in pattern' '
+       git config diff.java.funcname "^[       ]*\\(\\(public\\|static\\).*\\)$"
+       git diff --no-index Beer.java Beer-correct.java |
+       grep "^@@.*@@ public static void main("
+'
+
 test_done