git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC/PATCH] Use compatibility regex library for OSX/Darwin
@ 2008-09-07 18:45 Arjen Laarhoven
  2008-09-10  8:03 ` Mike Ralphson
  2008-09-16 17:49 ` [RFC/PATCH] Use compatibility regex library for OSX/Darwin Brandon Casey
  0 siblings, 2 replies; 44+ messages in thread
From: Arjen Laarhoven @ 2008-09-07 18:45 UTC (permalink / raw)
  To: git

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>
---
This patch is based on 'maint'.  It needs testing on MinGW (although
the change is trivial).

Also, I'm sure the problem occurs on more non-Linux systems (or non
GNU libc systems).  If people who have access to those systems (BSD's,
HP-UX, AIX, etc) can test it, I'd be happy to add those systems to the
patch so it can fix for multiple systems at once.

 Makefile                       |    6 ++++--
 compat/{ => fnmatch}/fnmatch.c |    0
 compat/{ => fnmatch}/fnmatch.h |    0
 compat/{ => regex}/regex.c     |    0
 compat/{ => regex}/regex.h     |    0
 t/t4018-diff-funcname.sh       |    6 ++++++
 6 files changed, 10 insertions(+), 2 deletions(-)
 rename compat/{ => fnmatch}/fnmatch.c (100%)
 rename compat/{ => fnmatch}/fnmatch.h (100%)
 rename compat/{ => regex}/regex.c (100%)
 rename compat/{ => regex}/regex.h (100%)

diff --git a/Makefile b/Makefile
index 672ea74..a8b3f9e 100644
--- 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
diff --git a/compat/fnmatch.c b/compat/fnmatch/fnmatch.c
similarity index 100%
rename from compat/fnmatch.c
rename to compat/fnmatch/fnmatch.c
diff --git a/compat/fnmatch.h b/compat/fnmatch/fnmatch.h
similarity index 100%
rename from compat/fnmatch.h
rename to compat/fnmatch/fnmatch.h
diff --git a/compat/regex.c b/compat/regex/regex.c
similarity index 100%
rename from compat/regex.c
rename to compat/regex/regex.c
diff --git a/compat/regex.h b/compat/regex/regex.h
similarity index 100%
rename from compat/regex.h
rename to compat/regex/regex.h
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 833d6cb..18bcd97 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -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
-- 
1.6.0.1.337.g5c7d67

^ permalink raw reply related	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2008-09-19 18:16 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-07 18:45 [RFC/PATCH] Use compatibility regex library for OSX/Darwin Arjen Laarhoven
2008-09-10  8:03 ` Mike Ralphson
2008-09-10  9:49   ` Johannes Sixt
2008-09-10 10:03   ` Arjen Laarhoven
2008-09-10 11:53     ` Mike Ralphson
2008-09-11  7:59       ` Mike Ralphson
2008-09-11  8:14         ` [PATCH] Use compatibility regex library also on AIX Johannes Sixt
2008-09-11  8:25           ` Arjen Laarhoven
2008-09-11  8:31             ` Mike Ralphson
2008-09-11 12:12               ` Jeff King
2008-09-11  8:27           ` Junio C Hamano
2008-09-16 17:49 ` [RFC/PATCH] Use compatibility regex library for OSX/Darwin Brandon Casey
2008-09-16 18:09   ` Junio C Hamano
2008-09-18  0:08     ` [PATCH 1/4] diff.c: return pattern entry pointer rather than just the hunk header pattern Brandon Casey
2008-09-18  0:10     ` [PATCH 2/4] diff.c: associate a flag with each pattern and use it for compiling regex Brandon Casey
2008-09-18  4:14       ` Junio C Hamano
2008-09-18  6:41         ` Andreas Ericsson
2008-09-18  7:12           ` Junio C Hamano
2008-09-18  8:06             ` Andreas Ericsson
2008-09-18  8:35               ` Junio C Hamano
2008-09-18  0:10     ` [PATCH 3/4] diff.*.xfuncname which uses "extended" regex's for hunk header selection Brandon Casey
     [not found]       ` <7vd4j212gb.fsf@gitster.siamese.dyndns.org>
2008-09-19 18:14         ` Brandon Casey
2008-09-18  0:21     ` [PATCH 4/4] diff.c: convert builtin funcname patterns to extended regular expressions Brandon Casey
2008-09-18  0:33       ` [PATCH 4/4 v2] " Brandon Casey
2008-09-18  7:18       ` [PATCH 4/4] " Andreas Ericsson
2008-09-18  7:31         ` Junio C Hamano
2008-09-18  8:39       ` Johan Herland
2008-09-18 10:15         ` Gustaf Hendeby
2008-09-18 10:53       ` Jonathan del Strother
2008-09-18 15:48         ` Brandon Casey
2008-09-16 19:08   ` [RFC/PATCH] Use compatibility regex library for OSX/Darwin Jeff King
2008-09-16 23:25   ` Boyd Lynn Gerber
2008-09-16 23:32     ` Jeff King
2008-09-16 23:42       ` Boyd Lynn Gerber
2008-09-16 23:46         ` Jeff King
2008-09-17  0:10           ` Boyd Lynn Gerber
2008-09-17  0:13             ` Brandon Casey
2008-09-17  0:13           ` Boyd Lynn Gerber
2008-09-17  0:20             ` Brandon Casey
2008-09-17  0:38               ` Boyd Lynn Gerber
2008-09-17  0:58                 ` Brandon Casey
2008-09-17  1:02           ` Boyd Lynn Gerber
2008-09-17  1:25             ` Brandon Casey
2008-09-17 14:48               ` Boyd Lynn Gerber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).