From 7e08f789581b5a3763d35ff937e80c77c41b0120 Mon Sep 17 00:00:00 2001 From: dhiebert Date: Mon, 10 Sep 2007 02:52:22 +0000 Subject: [PATCH] Fixed regex support for MinGW. Gnu regex module now included in all distributions. git-svn-id: svn://svn.code.sf.net/p/ctags/code/trunk@623 c5d04d22-be80-434c-894e-aa346cc9e8e8 --- INSTALL.oth | 13 +----------- NEWS | 3 +++ gnu_regex/README.txt | 2 +- gnu_regex/regex.c | 12 +++++++---- gnu_regex/regex.diff | 48 -------------------------------------------- index.html | 1 + maintainer.mak | 20 ++++++++++++++---- mk_bc5.mak | 41 +++++++------------------------------ mk_ming.mak | 26 ------------------------ mk_mingw.mak | 31 ++++++++++++++++++++++++++++ mk_mvc.mak | 19 +++++++++--------- source.mak | 4 ++++ 12 files changed, 82 insertions(+), 138 deletions(-) delete mode 100644 gnu_regex/regex.diff delete mode 100644 mk_ming.mak create mode 100644 mk_mingw.mak diff --git a/INSTALL.oth b/INSTALL.oth index ef626e5..8577c7e 100644 --- a/INSTALL.oth +++ b/INSTALL.oth @@ -11,7 +11,7 @@ For non-Unix platforms, simple makefiles are provided: mk_bc5.mak For Win32 using Borland C++ 5.5 mk_djg.mak For MSDOS using DJGPP Gnu GCC (better to follow Unix install) mk_manx.mak For Amiga using Aztec/Manx C 5.0 - mk_ming.mak For Win32 using Mingw32 + mk_mingw.mak For Win32 using MinGW mk_mpw.mak For Macintosh using MPW mk_mvc.mak For Win32 using Microsoft Visual C++ mk_os2.mak For OS/2 using GCC (EMX) @@ -23,17 +23,6 @@ For non-Unix platforms, simple makefiles are provided: Special Notes ============= -Win32: ------- - - Regex support on Win32 is available when compiled to use the Win32 port of - the Gnu regex library, which can be obtained here: - - http://people.delphiforums.com/gjc/gnu_regex.html - - See the makefiles, mk_mvc.mak or mk_bc5.mak, to learn how to build with - this library. - DJGPP: ------ diff --git a/NEWS b/NEWS index 24a020e..130a25e 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,9 @@ Current Version: @VERSION@ ctags-@VERSION@ (@DATE@) +Added regex support when compiling with MinGW. Gnu regex module now included in all distributions. + +ctags-5.7 (04 Sep 2007) * Added support for DIM AS [Freebasic, Bug #1741778]. * Added support for arbitrary nesting depth [Python, Bug #1684786, Debian bug #409078]. * Added support for verbatim string literals [C#, Bug #1515910]. diff --git a/gnu_regex/README.txt b/gnu_regex/README.txt index 0939ffa..3ba547c 100644 --- a/gnu_regex/README.txt +++ b/gnu_regex/README.txt @@ -2,4 +2,4 @@ These source files were taken from the GNU regex-0.12 package, found at: http://directory.fsf.org/GNU/regex.html -Corrections (contained in regex.diff) were then made to eliminate compiler errors in Microsoft Visual C++. +Corrections were then made to eliminate compiler errors. diff --git a/gnu_regex/regex.c b/gnu_regex/regex.c index f3aa320..d4156e8 100644 --- a/gnu_regex/regex.c +++ b/gnu_regex/regex.c @@ -1,5 +1,5 @@ /* Extended regular expression matching and search library, - version 0.12, which minor changes by Darren Hiebert. + version 0.12, with minor changes by Darren Hiebert. (Implements POSIX draft P10003.2/D11.2, except for internationalization features.) @@ -880,7 +880,7 @@ static reg_errcode_t compile_range (); /* Make sure we have at least N more bytes of space in buffer. */ #define GET_BUFFER_SPACE(n) \ - while (b - bufp->buffer + (n) > bufp->allocated) \ + while ((unsigned long)(b - bufp->buffer + (n)) > bufp->allocated) \ EXTEND_BUFFER () /* Make sure we have one more byte of buffer space and then add C to it. */ @@ -1624,10 +1624,12 @@ regex_compile (pattern, size, syntax, bufp) if (syntax & RE_NO_BK_PARENS) goto normal_backslash; if (COMPILE_STACK_EMPTY) + { if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_backslash; else return REG_ERPAREN; + } handle_close: if (fixup_alt_jump) @@ -1644,10 +1646,12 @@ regex_compile (pattern, size, syntax, bufp) /* See similar code for backslashed left paren above. */ if (COMPILE_STACK_EMPTY) + { if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_char; else return REG_ERPAREN; + } /* Since we just checked for an empty stack above, this ``can't happen''. */ @@ -2218,8 +2222,8 @@ compile_range (p_ptr, pend, translate, syntax, b) We also want to fetch the endpoints without translating them; the appropriate translation is done in the bit-setting loop below. */ - range_start = ((unsigned char *) p)[-2]; - range_end = ((unsigned char *) p)[0]; + range_start = ((const unsigned char *) p)[-2]; + range_end = ((const unsigned char *) p)[0]; /* Have to increment the pointer into the pattern string, so the caller isn't still at the ending character. */ diff --git a/gnu_regex/regex.diff b/gnu_regex/regex.diff deleted file mode 100644 index 7aabd50..0000000 --- a/gnu_regex/regex.diff +++ /dev/null @@ -1,48 +0,0 @@ ---- regex-0.12/regex.c 1993-04-02 17:17:03.000000000 -0600 -+++ regex.c 2007-07-16 23:02:09.000000000 -0500 -@@ -1,5 +1,5 @@ - /* Extended regular expression matching and search library, -- version 0.12. -+ version 0.12, which minor changes by Darren Hiebert. - (Implements POSIX draft P10003.2/D11.2, except for - internationalization features.) - -@@ -2831,7 +2831,7 @@ - { - bufp->regs_allocated = REGS_UNALLOCATED; - regs->num_regs = 0; -- regs->start = regs->end = (regoff_t) 0; -+ regs->start = regs->end = NULL; - } - } - -@@ -4873,8 +4873,8 @@ - from either regcomp or regexec. We don't use PREG here. */ - - size_t --regerror (errcode, preg, errbuf, errbuf_size) -- int errcode; -+regerror (code, preg, errbuf, errbuf_size) -+ int code; - const regex_t *preg; - char *errbuf; - size_t errbuf_size; -@@ -4882,15 +4882,15 @@ - const char *msg; - size_t msg_size; - -- if (errcode < 0 -- || errcode >= (sizeof (re_error_msg) / sizeof (re_error_msg[0]))) -+ if (code < 0 -+ || code >= (sizeof (re_error_msg) / sizeof (re_error_msg[0]))) - /* Only error codes returned by the rest of the code should be passed - to this routine. If we are given anything else, or if other regex - code generates an invalid error code, then the program has a bug. - Dump core so we can fix it. */ - abort (); - -- msg = re_error_msg[errcode]; -+ msg = re_error_msg[code]; - - /* POSIX doesn't require that we do anything in this case, but why - not be nice. */ diff --git a/index.html b/index.html index 3ccdac6..39669ba 100644 --- a/index.html +++ b/index.html @@ -175,6 +175,7 @@
  • Praised in the Weekend Mechanic column of the June 1997 issue of Linux Gazette + Praised in Perl Buzz
  • Freely available under the terms of the GNU General Public License diff --git a/maintainer.mak b/maintainer.mak index cc6424b..6a3c787 100644 --- a/maintainer.mak +++ b/maintainer.mak @@ -16,7 +16,7 @@ VERSION_FILES:= ctags.h ctags.1 NEWS LIB_FILES := readtags.c readtags.h ENVIRONMENT_MAKEFILES := \ - mk_bc3.mak mk_bc5.mak mk_djg.mak mk_manx.mak mk_ming.mak \ + mk_bc3.mak mk_bc5.mak mk_djg.mak mk_manx.mak mk_mingw.mak \ mk_mpw.mak mk_mvc.mak mk_os2.mak mk_qdos.mak mk_sas.mak \ COMMON_FILES := COPYING EXTENDING.html FAQ INSTALL.oth MAINTAINERS NEWS README \ @@ -30,6 +30,8 @@ UNIX_FILES := $(COMMON_FILES) \ descrip.mms mkinstalldirs magic.diff \ ctags.spec ctags.1 +REGEX_DIR := gnu_regex + WIN_FILES := $(COMMON_FILES) $(VERSION_FILES) WIN_REGEX := regex.c regex.h @@ -249,13 +251,15 @@ $(RELEASE_DIR)/ctags-%.tar.gz: $(UNIX_FILES) | $(RELEASE_DIR) @ echo "---------- Building tar ball" if [ -d $(@D)/dirs/ctags-$* ]; then rm -fr $(@D)/dirs/ctags-$*; fi mkdir -p $(@D)/dirs/ctags-$* - cp -p $(UNIX_FILES) $(@D)/dirs/ctags-$*/ + cp -pr $(UNIX_FILES) $(REGEX_DIR) $(@D)/dirs/ctags-$*/ sed -e 's/\(PROGRAM_VERSION\) "\([^ ]*\)"/\1 "$*"/' ctags.h > $(@D)/dirs/ctags-$*/ctags.h sed -e 's/"\(Version\) \([^ ]*\)"/"\1 $*"/' ctags.1 > $(@D)/dirs/ctags-$*/ctags.1 sed -e 's/\(Current Version:\) [^ ]*/\1 $*/' -e 's/@VERSION@/$*/' -e "s/@DATE@/`date +'%d %b %Y'`/" NEWS > $(@D)/dirs/ctags-$*/NEWS (cd $(@D)/dirs/ctags-$* ;\ chmod 644 * ;\ chmod 755 mkinstalldirs ;\ + chmod 755 $(REGEX_DIR) ;\ + chmod 644 $(REGEX_DIR)/* ;\ autoheader ;\ chmod 644 config.h.in ;\ autoconf ;\ @@ -287,9 +291,13 @@ $(WINDOWS_DIR)/ctags$(win_version): \ for file in $(WIN_FILES) ctags.html; do \ $(UNIX2DOS) < "$(RELEASE_DIR)/dirs/ctags-$(version)/$${file}" > $@/$${file} ;\ done - for file in $(WIN_REGEX); do \ - $(UNIX2DOS) < "gnu_regex/$${file}" > $@/$${file} ;\ + mkdir $@/$(REGEX_DIR) + for file in $(REGEX_DIR)/*; do \ + $(UNIX2DOS) < "$${file}" > $@/$(REGEX_DIR)/`basename $${file}` ;\ done + chmod 644 $@/* + chmod 755 $@/$(REGEX_DIR) + chmod 644 $@/$(REGEX_DIR)/* $(RELEASE_DIR)/ctags%.zip: \ check-version-% \ @@ -395,6 +403,10 @@ $(DEP_DIR)/%.d: %.c maintainer.mak # # Compilation rules # +regex.o: gnu_regex/regex.c + @ echo "-- Compiling $<" + @ $(CC) $(COMP_FLAGS) -DEXTERNAL_SORT $(OPT) $(WARNINGS) -Wuninitialized -c -Ignu_regex $< + %.o: %.c @ echo "-- Compiling $<" @ $(CC) $(COMP_FLAGS) -DEXTERNAL_SORT $(OPT) $(WARNINGS) -Wuninitialized -c $< diff --git a/mk_bc5.mak b/mk_bc5.mak index 965fe0e..6012ccd 100644 --- a/mk_bc5.mak +++ b/mk_bc5.mak @@ -4,39 +4,12 @@ !include source.mak -BCC = bcc32 - -# You can obtain an Win32 version of the Gnu regex support library from -# http://people.delphiforums.com/gjc/gnu_regex.html -# Point REGEX_DIR to the directory created when you extract the archive. -# If you just run gnu_regex.exe in this directory, then you can just -# uncomment the REGEX_DIR macro below and everything should work. - -#REGEX_DIR = gnu_regex_dist - -!ifdef REGEX_DIR -EXTRA_INC = -I$(REGEX_DIR) - -# Uncomment the following macro to dynamically link against the regex DLL; -# otherwise link statically against regex. -# WARNING: Borland C++ does not successfully link dynamically. - -#REGEX_DLL=1 - -!ifdef REGEX_DLL -REGEX_DEFINE = -DHAVE_REGCOMP -EXTRA_LIBS = $(REGEX_DIR)\gnu_regex.lib -LDFLAGS = -tWCR -!else REGEX_DEFINE = -DHAVE_REGCOMP -DREGEX_MALLOC -DSTDC_HEADERS=1 -EXTRA_LIBS = regex.obj -!endif -!endif - DEFINES = -DWIN32 $(REGEX_DEFINE) -INCLUDES = $(EXTRA_INC) +INCLUDES = -I. -Ignu_regex WARNINGS = -w-aus -w-par -w-pia -w-pro -w-sus CFLAGS = -d -DSTRICT -lTpe -lap +BCC = bcc32 # Optimizations if your platform supports all of them. OPT = -O2 -OS -lGt @@ -46,24 +19,24 @@ OPT = -O2 -OS -lGt ctags: ctags.exe -ctags.exe: $(SOURCES) respbc5 $(EXTRA_LIBS) +ctags.exe: respbc5 $(BCC) $(OPT) $(MT_OPT) -e$@ $(LDFLAGS) @respbc5 readtags.exe: readtags.c $(BCC) $(CFLAGS) $(OPT) $(MT_OPT) -e$@ $(DEFINES) -DREADTAGS_MAIN readtags.c $(LDFLAGS) # Debug version -dctags.exe: $(SOURCES) respbc5 $(EXTRA_LIBS) +dctags.exe: respbc5 $(BCC) -DDEBUG -e$@ $(LDFLAGS) @respbc5 debug.c regex.obj: - $(BCC) -c -o$@ -w- $(DEFINES) -Dconst= $(INCLUDES) $(REGEX_DIR)\regex.c + $(BCC) -c -o$@ -w- $(DEFINES) -Dconst= $(INCLUDES) -respbc5: $(SOURCES) $(HEADERS) mk_bc5.mak +respbc5: $(SOURCES) $(REGEX_SOURCES) $(HEADERS) $(REGEX_HEADERS) mk_bc5.mak echo $(DEFINES) $(INCLUDES) > $@ echo $(WARNINGS) >> $@ echo $(CFLAGS) >> $@ - echo $(SOURCES) $(EXTRA_LIBS) >> $@ + echo $(SOURCES) $(REGEX_SOURCES) >> $@ mostlyclean: - del *.obj diff --git a/mk_ming.mak b/mk_ming.mak deleted file mode 100644 index 51558b1..0000000 --- a/mk_ming.mak +++ /dev/null @@ -1,26 +0,0 @@ -# $Id$ -# -# Makefile for Exuberant Ctags under Win32 with Mingw32 compiler -# -# Note that only the crtdll variant of the compiler is supported. -# The msvcrt variant has broken implementations of fgetpos() and fsetpos(). - -include source.mak - -CFLAGS = -Wall -DEFINES = -DWIN32 -CC = gcc - -ctags: ctags.exe - -ctags.exe: OPT = -O4 -ctags.exe: LDFLAGS = -s -dctags.exe: OPT = -g - -ctags.exe dctags.exe: $(SOURCES) - $(CC) $(LDFLAGS) $(OPT) $(CFLAGS) $(DEFINES) -o $@ $(SOURCES) - -clean: - - del ctags.exe - - del dctags.exe - - del tags diff --git a/mk_mingw.mak b/mk_mingw.mak new file mode 100644 index 0000000..e5fb7a5 --- /dev/null +++ b/mk_mingw.mak @@ -0,0 +1,31 @@ +# $Id$ +# +# Makefile for Exuberant Ctags under Win32 with MinGW compiler +# + +include source.mak + +REGEX_DEFINES = -DHAVE_REGCOMP -DREGEX_MALLOC -DSTDC_HEADERS=1 + +CFLAGS = -Wall +DEFINES = -DWIN32 $(REGEX_DEFINES) $(DEBUG) +INCLUDES = -I. -Ignu_regex +CC = gcc + +ctags.exe: OPT = -O4 +dctags.exe: OPT = -g +dctags.exe: DEBUG = -DDEBUG +dctags.exe: SOURCES += debug.c + +ctags: ctags.exe + +ctags.exe dctags.exe: $(SOURCES) $(REGEX_SOURCES) $(HEADERS) $(REGEX_HEADERS) + $(CC) $(OPT) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $(SOURCES) $(REGEX_SOURCES) + +readtags.exe: readtags.c + $(CC) $(OPT) $(CFLAGS) -DREADTAGS_MAIN $(DEFINES) $(INCLUDES) -o $@ $< + +clean: + - rm -f ctags.exe + - rm -f dctags.exe + - rm -f tags diff --git a/mk_mvc.mak b/mk_mvc.mak index 0386c6a..b4b5967 100644 --- a/mk_mvc.mak +++ b/mk_mvc.mak @@ -4,30 +4,31 @@ include source.mak -REGEX_DEFINE = -DHAVE_REGCOMP -DREGEX_MALLOC -DSTDC_HEADERS=1 -EXTRA_LIBS = regex.obj - -DEFINES = -DWIN32 $(REGEX_DEFINE) -INCLUDES = -I. +REGEX_DEFINES = -DHAVE_REGCOMP -DREGEX_MALLOC -DSTDC_HEADERS=1 +DEFINES = -DWIN32 $(REGEX_DEFINES) +INCLUDES = -I. -Ignu_regex OPT = /O2 ctags: ctags.exe -ctags.exe: $(SOURCES) respmvc $(EXTRA_LIBS) +ctags.exe: respmvc cl $(OPT) /Fe$@ @respmvc /link setargv.obj readtags.exe: readtags.c cl /clr $(OPT) /Fe$@ $(DEFINES) -DREADTAGS_MAIN readtags.c /link setargv.obj # Debug version -dctags.exe: $(SOURCES) respmvc $(EXTRA_LIBS) +dctags.exe: respmvc cl /Zi -DDEBUG /Fe$@ @respmvc debug.c /link setargv.obj regex.obj: cl /c $(OPT) /Fo$@ $(DEFINES) -Dconst= regex.c -respmvc: $(SOURCES) $(HEADERS) mk_mvc.mak - echo $(DEFINES) $(INCLUDES) $(SOURCES) $(EXTRA_LIBS) > $@ +respmvc: $(SOURCES) $(REGEX_SOURCES) $(HEADERS) $(REGEX_HEADERS) mk_mvc.mak + echo $(DEFINES) > $@ + echo $(INCLUDES) >> $@ + echo $(SOURCES) >> $@ + echo $(REGEX_SOURCES) >> $@ mostlyclean: - del *.obj diff --git a/source.mak b/source.mak index cdef84e..432386a 100644 --- a/source.mak +++ b/source.mak @@ -58,6 +58,10 @@ ENVIRONMENT_HEADERS = \ ENVIRONMENT_SOURCES = \ argproc.c mac.c qdos.c +REGEX_SOURCES = gnu_regex/regex.c + +REGEX_HEADERS = gnu_regex/regex.h + OBJECTS = \ args.$(OBJEXT) \ asm.$(OBJEXT) \