public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* Re: Libiberty regex support - revised patch
       [not found] <3B3BB266.551EDBCD.cygnus.local.cgen@cygnus.com>
@ 2001-07-02 23:25 ` Geoff Keating
  0 siblings, 0 replies; 2+ messages in thread
From: Geoff Keating @ 2001-07-02 23:25 UTC (permalink / raw)
  To: J. Johnston; +Cc: gcc-patches

This patch is OK for GCC, if it hasn't been approved already.

-- 
- Geoffrey Keating <geoffk@geoffk.org>

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

* Libiberty regex support - revised patch
@ 2001-06-28 15:40 J. Johnston
  0 siblings, 0 replies; 2+ messages in thread
From: J. Johnston @ 2001-06-28 15:40 UTC (permalink / raw)
  To: gcc-patches; +Cc: cgen, gdb-patches

Responding to comments on my previous patch, I have a revised version.

The change was designed to support the opcodes directory whereby CGEN optionally uses regex to help
out in insn syntax parsing so as to dramatically improve error messages.  Because Cygwin's regex
doesn't conform to POSIX, the opcodes fix fails under Cygwin.  As well, the regex code under Cygwin
causes problems with gdb using the simulator due to the mismatch of the native regex dragged in by
opcodes and the internal one used by gdb.

The source for the latest patch has been taken from the latest CVS glibc sources.  The regex.c file
has only been modified to change #include <regex.h> to #include "xregex.h".  A comment has been
added regarding this.  The regex.h file has been renamed to xregex2.h and is otherwise unchanged. 
An additional header file, xregex.h has been added which a) redefines all external names in regex.c
to add an "x" prefix and b) includes xregex2.h.  This has been designed so that changes in the glibc
sources will be relatively easy to apply to the libiberty version.

The rename in xregex.h is performed to avoid any name collision with the native regex or with any
component's private regex implementation (e.g. gdb).  The new regex code is always built into
libiberty.  A component can decide whether or not to use it by specifying #include "xregex.h"
instead of <regex.h> or any internal regex header file.

There are two patches attached.  The first patch is to existing libiberty files.  The second is for
the new code being added.

-- Jeff J.
Index: libiberty/Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/libiberty/Makefile.in,v
retrieving revision 1.62
diff -u -r1.62 Makefile.in
--- libiberty/Makefile.in	2001/04/16 15:30:17	1.62
+++ libiberty/Makefile.in	2001/06/28 21:57:52
@@ -127,7 +127,8 @@
 	floatformat.c hashtab.c hex.c index.c insque.c lbasename.c            \
 	md5.c make-temp-file.c memchr.c					      \
 	memcmp.c memcpy.c memmove.c memset.c mkstemps.c objalloc.c obstack.c  \
-	partition.c pexecute.c putenv.c random.c rename.c rindex.c setenv.c   \
+	partition.c pexecute.c putenv.c random.c			      \
+	regex.c rename.c rindex.c setenv.c				      \
 	sigsetmask.c safe-ctype.c sort.c spaces.c splay-tree.c strcasecmp.c   \
 	strncasecmp.c strchr.c strdup.c strerror.c strncmp.c strrchr.c        \
 	strsignal.c strstr.c strtod.c strtol.c strtoul.c tmpnam.c vasprintf.c \
@@ -139,7 +140,7 @@
 	cp-demangle.o dyn-string.o fdmatch.o fnmatch.o getopt.o getopt1.o     \
 	getpwd.o getruntime.o hashtab.o hex.o floatformat.o lbasename.o       \
         md5.o make-temp-file.o objalloc.o				      \
-	obstack.o partition.o pexecute.o safe-ctype.o sort.o spaces.o         \
+	obstack.o partition.o pexecute.o regex.o safe-ctype.o sort.o spaces.o \
 	splay-tree.o strerror.o strsignal.o xatexit.o xexit.o xmalloc.o       \
 	xmemdup.o xstrdup.o xstrerror.o ternary.o
 
@@ -281,6 +282,7 @@
 obstack.o: config.h $(INCDIR)/obstack.h
 partition.o: config.h $(INCDIR)/partition.h
 pexecute.o: config.h $(INCDIR)/libiberty.h
+regex.o: $(INCDIR)/xregex.h $(INCDIR)/xregex2.h
 rename.o: config.h
 setenv.o: config.h
 sort.o: config.h $(INCDIR)/sort.h $(INCDIR)/ansidecl.h
Index: libiberty/aclocal.m4
===================================================================
RCS file: /cvs/gcc/gcc/libiberty/aclocal.m4,v
retrieving revision 1.4
diff -u -r1.4 aclocal.m4
--- libiberty/aclocal.m4	2001/03/06 09:52:35	1.4
+++ libiberty/aclocal.m4	2001/06/28 21:57:52
@@ -70,6 +70,47 @@
 fi
 ])
 
+dnl See whether native regexec exists and is POSIX-compliant.  On Cygwin, for
+dnl example, the regex family exists but does not follow POSIX prototypes.
+AC_DEFUN(libiberty_AC_FUNC_REGEXEC,
+[AC_CACHE_CHECK([for working regex functions], ac_cv_func_regexec_works,
+[AC_TRY_RUN([
+/* Test by Jeff Johnston
+   Check whether regexec on simple string works. */
+#include <sys/types.h>
+
+#ifdef HAVE_REGEX_H
+#include <regex.h>
+#endif
+
+main ()
+{
+  const char *pattern = "[abc]*.*[ghi]*$";
+  const char *str = "ABCcbaDEFGHIihg"
+  regex_t k;
+
+  int rc;
+
+  rc = regcomp (&k, pattern, REG_ICASE);
+
+  if (rc != REG_NOERROR)
+    exit(1);
+
+  rc = regexec (&k, str, 0, NULL, 0);
+
+  if (rc != REG_NOERROR)
+    exit(2);
+
+  exit (0);
+}
+], ac_cv_func_regexec_works=yes, ac_cv_func_regexec_works=no,
+  ac_cv_func_regexec_works=no)
+rm -f core core.* *.core])
+if test $ac_cv_func_regexec_works = no ; then
+  LIBOBJS="$LIBOBJS regex.o"
+fi
+])
+
 dnl See if errno must be declared even when <errno.h> is included.
 AC_DEFUN(libiberty_AC_DECLARE_ERRNO,
 [AC_CACHE_CHECK(whether errno must be declared, libiberty_cv_declare_errno,

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

end of thread, other threads:[~2001-07-02 23:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <3B3BB266.551EDBCD.cygnus.local.cgen@cygnus.com>
2001-07-02 23:25 ` Libiberty regex support - revised patch Geoff Keating
2001-06-28 15:40 J. Johnston

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 read-only IMAP folder(s) and NNTP newsgroup(s).