bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: --with-included-foo={yes,no} and which foo.h to use?


From: Charles Levert
Subject: Re: --with-included-foo={yes,no} and which foo.h to use?
Date: Thu, 7 Jul 2005 02:33:59 -0400
User-agent: Mutt/1.4.1i

* On Tuesday 2005-06-28 at 13:03:21 +0200, Stepan Kasal wrote:
> Hi,
> 
> On Mon, Jun 27, 2005 at 02:05:22PM +0300, Aharon Robbins wrote:
> > (a) upgrading to the glibc regex
> > (b) always using the included regex
> 
> I thought that we should upgrade to glibc regex in 2.6 branch.
> We should release other fixes in 2.5 branch before.

But there's a catch-22 here.  See below.


> > If the distribution vendors want to optimize that out, let them;
> 
> I think we should support them; the configure option
> --with-included-regex (misnamed, but already established) should be
> there.

So do I.


> I agree that (in 2.6 branch) the default should be to use
> the distributed regex, as we'll always have some fixes to regex.c
> which are ahead of glibc.



Updating to glibc's regex.c will allow us to
progress in fixing RE_ICASE bugs now, and maybe
others as well.  That why I can't see one being
a priority without the other.

The following ChangeLog entry lists files that
do not appear in the diff output below, either
because they are completely new and untouched,
or because the main lib/regex.c diff is huge
and irrelevant.

For m4/regex.m4, the diff included here is
relative to GNU grep's version, but most of the
changes come from gnulib and a diff relative to
that may have been more interesting to look at.

I don't believe that, at this point, we have
fixes in regex.c to contribute back to glibc;
it's rather the opposite.  Hopefully this won't
always be true.

Please comment.  I'd really like to see this go
in before 2.6, for the above reasons.




2005-07-07  Charles Levert  <address@hidden>

        Big regex.[ch] update from latest glibc CVS libc/posix/.
        This should be an enabler for fixing pending bugs.
        * lib/regex.h, lib/posix, lib/posix/.cvsignore,
          lib/posix/Makefile.am, lib/posix/regex.h: Removed.
        * lib/regex/regex.h,
          lib/regex/regex_internal.h, lib/regex/regex_internal.c,
          lib/regex/regcomp.c, lib/regex/regexec.c: New from glibc CVS,
          all include files (even the *.c) in their own directory so
          they won't be found if not configured (especially regex.h).
        * lib/regex/.cvsignore, lib/regex/Makefile.am: New.
        * lib/regex.c: Replaced with glibc CVS version.
        * m4/regex.m4: Replaced with gnulib CVS version.
        * m4/onceonly.m4, m4/restrict.m4: New from latest gnulib CVS.
        * m4/Makefile.am: Add previous two files.
        * Makefile.am: Add m4/onceonly.m4 and m4/restrict.m4.
        * lib/regex/regex_internal.h: Do not re#define __mempcpy is it's
          already a cpp macro (maybe even to a gcc internal).
        * tests/spencer1.tests: 'a[b-a]' now has an 'Invalid range end'.
        * m4/regex.m4: Add a configure-time test of the system regex
          for this last error to be correctly reported, number invalid
          return codes from 1 to 7, add AC_SUBST(REGEX_INCLUDE, ...),
          attempt to use RE_ICASE so compilation will fail if missing.
        * bootstrap/Makefile.try: Add -I$(libdir)/regex to CFLAGS.
        * configure.in: Now uses gl_INCLUDED_REGEX, improved
          --without-included-regex warning, generates lib/regex/Makefile
          but no longer lib/posix/Makefile.
        * lib/Makefile.am: SUBDIRS now has regex but no longer posix,
          INCLUDES has @REGEX_INCLUDE@, regex.h gone from noinst_HEADERS.
        * src/Makefile.am: INCLUDES has @address@hidden


--- lib/regex/.cvsignore        1969-12-31 19:00:00 -0500
+++ lib/regex/.cvsignore        2005-07-06 20:01:59 -0400
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
--- lib/regex/Makefile.am       1969-12-31 19:00:00 -0500
+++ lib/regex/Makefile.am       2005-07-06 20:01:59 -0400
@@ -0,0 +1,4 @@
+## Process this file with automake to create Makefile.in
+AUTOMAKE_OPTIONS=no-dependencies
+
+EXTRA_DIST = regex.h regex_internal.h regex_internal.c regcomp.c regexec.c
--- m4/regex.m4.cvs-1.9 2002-03-13 08:37:47 -0500
+++ m4/regex.m4 2005-07-06 23:47:56 -0400
@@ -1,11 +1,23 @@
-#serial 5001
+#serial 22
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
+#               Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
 dnl Initially derived from code in GNU grep.
 dnl Mostly written by Jim Meyering.
 
-dnl Usage: jm_INCLUDED_REGEX([lib/regex.c])
+AC_DEFUN([gl_REGEX],
+[
+  gl_INCLUDED_REGEX([lib/regex.c])
+])
+
+dnl Usage: gl_INCLUDED_REGEX([lib/regex.c])
 dnl
-AC_DEFUN(jm_INCLUDED_REGEX,
+AC_DEFUN([gl_INCLUDED_REGEX],
   [
     dnl Even packages that don't use regex.c can use this macro.
     dnl Of course, for them it doesn't do anything.
@@ -17,35 +29,63 @@
     # the following run test, then default to *not* using the included regex.c.
     # If cross compiling, assume the test would fail and use the included
     # regex.c.  The first failing regular expression is from `Spencer ere
-    # test #75' in grep-2.3.
+    # test #212' in grep-2.5.1a/tests/spencer2.tests.
     AC_CACHE_CHECK([for working re_compile_pattern],
                   jm_cv_func_working_re_compile_pattern,
       AC_TRY_RUN(
-       changequote(<<, >>)dnl
-       <<
-#include <stdio.h>
+[#include <stdio.h>
+#include <string.h>
 #include <regex.h>
          int
          main ()
          {
            static struct re_pattern_buffer regex;
            const char *s;
-           re_set_syntax (RE_SYNTAX_POSIX_EGREP);
-           /* Add this third left square bracket, [, to balance the
-              three right ones below.  Otherwise autoconf-2.14 chokes.  */
-           s = re_compile_pattern ("a[[:]:]]b\n", 9, &regex);
+           struct re_registers regs;
+           re_set_syntax (RE_SYNTAX_POSIX_EGREP | RE_ICASE);
+           memset (&regex, 0, sizeof (regex));
+           [s = re_compile_pattern ("a[[:@:>@:]]b\n", 9, &regex);]
            /* This should fail with _Invalid character class name_ error.  */
            if (!s)
              exit (1);
 
+           /* This should fail with _Invalid range end_ error.  */
+           memset (&regex, 0, sizeof (regex));
+           [s = re_compile_pattern ("a[b-a]", 6, &regex);]
+           if (!s)
+             exit (2);
+
            /* This should succeed, but doesn't for e.g. glibc-2.1.3.  */
+           memset (&regex, 0, sizeof (regex));
            s = re_compile_pattern ("{1", 2, &regex);
 
-          exit (s ? 1 : 0);
-         }
-       >>,
-       changequote([, ])dnl
+           if (s)
+             exit (3);
 
+           /* The following example is derived from a problem report
+               against gawk from Jorge Stolfi <address@hidden>.  */
+           memset (&regex, 0, sizeof (regex));
+           [s = re_compile_pattern ("[an\371]*n", 7, &regex);]
+           if (s)
+             exit (4);
+
+           /* This should match, but doesn't for e.g. glibc-2.2.1.  */
+           if (re_match (&regex, "an", 2, 0, &regs) != 2)
+             exit (5);
+
+           memset (&regex, 0, sizeof (regex));
+           s = re_compile_pattern ("x", 1, &regex);
+           if (s)
+             exit (6);
+
+           /* The version of regex.c in e.g. GNU libc-2.2.93 didn't
+              work with a negative RANGE argument.  */
+           if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)
+             exit (7);
+
+           exit (0);
+         }
+       ],
               jm_cv_func_working_re_compile_pattern=yes,
               jm_cv_func_working_re_compile_pattern=no,
               dnl When crosscompiling, assume it's broken.
@@ -55,10 +95,9 @@
     fi
 
     test -n "$1" || AC_MSG_ERROR([missing argument])
-    syscmd([test -f $1])
-    ifelse(sysval, 0,
+    m4_syscmd([test -f $1])
+    ifelse(m4_sysval, 0,
       [
-
        AC_ARG_WITH(included-regex,
        [  --without-included-regex don't compile regex; this is the default on
                           systems with version 2 of the GNU C library
@@ -67,8 +106,28 @@
                    jm_with_regex=$ac_use_included_regex)
        if test "$jm_with_regex" = yes; then
          AC_LIBOBJ(regex)
+         gl_PREREQ_REGEX
+         AC_SUBST(REGEX_INCLUDE, ['-I$(top_srcdir)/lib/regex'])
        fi
       ],
     )
   ]
 )
+
+# Prerequisites of lib/regex.c.
+AC_DEFUN([gl_PREREQ_REGEX],
+[
+  dnl FIXME: Maybe provide a btowc replacement someday: Solaris 2.5.1 lacks it.
+  dnl FIXME: Check for wctype and iswctype, and and add -lw if necessary
+  dnl to get them.
+
+  dnl Persuade glibc <string.h> to declare mempcpy().
+  AC_REQUIRE([AC_GNU_SOURCE])
+
+  AC_REQUIRE([gl_C_RESTRICT])
+  AC_REQUIRE([AC_FUNC_ALLOCA])
+  AC_REQUIRE([AC_HEADER_STDC])
+  AC_CHECK_HEADERS_ONCE(wchar.h wctype.h)
+  AC_CHECK_FUNCS_ONCE(isascii mempcpy)
+  AC_CHECK_FUNCS(btowc)
+])
--- m4/Makefile.am.cvs-1.9      2004-11-20 09:46:19 -0500
+++ m4/Makefile.am      2005-07-06 22:53:49 -0400
@@ -17,9 +17,11 @@
              malloc.m4 \
              mbstate_t.m4 \
              missing.m4 \
+             onceonly.m4 \
              progtest.m4 \
              realloc.m4 \
              regex.m4 \
+             restrict.m4 \
              sanity.m4 \
              strerror_r.m4 \
             uintmax_t.m4 \
--- Makefile.am.cvs-1.19        2005-04-29 06:41:01 -0400
+++ Makefile.am 2005-07-06 22:53:08 -0400
@@ -15,8 +15,9 @@
   $(M4DIR)/header.m4 $(M4DIR)/init.m4 $(M4DIR)/install.m4 \
   $(M4DIR)/inttypes_h.m4 $(M4DIR)/isc-posix.m4 $(M4DIR)/largefile.m4 \
   $(M4DIR)/lcmessage.m4 $(M4DIR)/malloc.m4 $(M4DIR)/mbstate_t.m4 \
-  $(M4DIR)/missing.m4 $(M4DIR)/progtest.m4 $(M4DIR)/realloc.m4 \
-  $(M4DIR)/regex.m4 $(M4DIR)/sanity.m4 $(M4DIR)/strerror_r.m4 \
+  $(M4DIR)/missing.m4 $(M4DIR)/onceonly.m4 $(M4DIR)/progtest.m4 \
+  $(M4DIR)/realloc.m4 $(M4DIR)/regex.m4 $(M4DIR)/restrict.m4 \
+  $(M4DIR)/sanity.m4 $(M4DIR)/strerror_r.m4 \
   $(M4DIR)/uintmax_t.m4 $(M4DIR)/ulonglong.m4 $(M4DIR)/xstrtoumax.m4
 $(srcdir)/acinclude.m4 : $(ACINCLUDE_INPUTS)
        cat $(ACINCLUDE_INPUTS) >$(srcdir)/acinclude.m4
--- lib/regex/regex_internal.h.glibc-cvs-1.62   2005-06-15 05:31:50 -0400
+++ lib/regex/regex_internal.h  2005-07-06 22:31:58 -0400
@@ -107,7 +107,9 @@
 # define __wctype wctype
 # define __iswctype iswctype
 # define __btowc btowc
-# define __mempcpy mempcpy
+# ifndef __mempcpy
+#  define __mempcpy mempcpy
+# endif
 # define __wcrtomb wcrtomb
 # define __regfree regfree
 # define attribute_hidden
--- tests/spencer1.tests.cvs-1.3        2004-11-19 09:00:18 -0500
+++ tests/spencer1.tests        2005-07-06 21:11:59 -0400
@@ -34,7 +34,7 @@
 address@hidden@aac
 address@hidden@a-
 address@hidden@a-
address@hidden@-
address@hidden@-
 address@hidden@-
 address@hidden@-
 address@hidden@a]
--- bootstrap/Makefile.try.cvs-1.9      2001-07-29 15:32:15 -0400
+++ bootstrap/Makefile.try      2005-07-06 20:00:15 -0400
@@ -106,7 +106,8 @@
 
 ####
 
-CFLAGS = $(DEFS) -I. -I.. -I$(libdir) -DVERSION=\"bootstrap\" 
-DPACKAGE=\"grep\"
+CFLAGS = $(DEFS) -I. -I.. -I$(libdir) -I$(libdir)/regex \
+         -DVERSION=\"bootstrap\" -DPACKAGE=\"grep\"
 
 libdir = ../lib
 
--- configure.in.cvs-1.87       2005-05-02 05:11:48 -0400
+++ configure.in        2005-07-06 20:30:30 -0400
@@ -122,7 +122,7 @@
 
 dnl Many GNU/Linux people have different
 dnl glibc versions with buggy regex.
-jm_INCLUDED_REGEX(lib/regex.c)
+gl_INCLUDED_REGEX(lib/regex.c)
 
 dnl Many people on non-GNU/Linux systems don't have getopt
 AC_CHECK_FUNC(getopt_long,
@@ -146,7 +146,7 @@
 dnl knows that the grep may be invoked on other hosts with buggy libraries,
 dnl then the installer should configure --with-included-regex.
 if test "$jm_with_regex" = no; then
-       AC_MSG_WARN(Included lib/regex.c not used)
+       AC_MSG_WARN(Included lib/regex.c not used; do not report bugs before 
trying to use it.)
 fi
 
 dnl These are the prerequisite macros for GNU's error.c file.
@@ -167,4 +167,4 @@
        AC_CHECK_LIB(pcre, pcre_exec)
 fi
 
-AC_OUTPUT(Makefile lib/Makefile lib/posix/Makefile src/Makefile tests/Makefile 
po/Makefile.in intl/Makefile doc/Makefile m4/Makefile vms/Makefile 
bootstrap/Makefile, [sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > 
po/Makefile; echo timestamp > stamp-h])
+AC_OUTPUT(Makefile lib/Makefile lib/regex/Makefile src/Makefile tests/Makefile 
po/Makefile.in intl/Makefile doc/Makefile m4/Makefile vms/Makefile 
bootstrap/Makefile, [sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > 
po/Makefile; echo timestamp > stamp-h])
--- lib/Makefile.am.cvs-1.5     2001-11-19 09:25:33 -0500
+++ lib/Makefile.am     2005-07-06 20:54:21 -0400
@@ -1,11 +1,11 @@
 #
 AUTOMAKE_OPTIONS = ../src/ansi2knr
 
-SUBDIRS = posix
+SUBDIRS = regex
 
 noinst_LIBRARIES = libgreputils.a
 
-INCLUDES = -I.. -I$(srcdir) -I../intl
+INCLUDES = -I.. -I$(srcdir) -I../intl @REGEX_INCLUDE@
 DEFS = -DLIBDIR=\"$(libdir)\" @DEFS@
 
 libgreputils_a_SOURCES = \
@@ -15,6 +15,6 @@
 libgreputils_a_LIBADD = @LIBOBJS@ @ALLOCA@
 noinst_HEADERS = \
   closeout.h error.h exclude.h fnmatch.h getopt.h \
-  hard-locale.h obstack.h quotearg.h regex.h savedir.h xalloc.h xstrtol.h
+  hard-locale.h obstack.h quotearg.h savedir.h xalloc.h xstrtol.h
 
 EXTRA_DIST = strtol.c malloc.c realloc.c
--- src/Makefile.am.cvs-1.33    2005-06-22 20:44:39 -0400
+++ src/Makefile.am     2005-07-06 20:18:33 -0400
@@ -13,7 +13,7 @@
 LDADD = @INTLLIBS@ ../lib/libgreputils.a
 datadir = $(prefix)/@DATADIRNAME@
 localedir = $(datadir)/locale
-INCLUDES = -I../intl -I$(top_srcdir)/lib -DLOCALEDIR=\"$(localedir)\"
+INCLUDES = -I../intl -I$(top_srcdir)/lib @REGEX_INCLUDE@ 
-DLOCALEDIR=\"$(localedir)\"
 
 EXTRA_DIST = \
              dosbuf.c \




reply via email to

[Prev in Thread] Current Thread [Next in Thread]