On 19/03/2010 10:03, Jim Meyering wrote:

We expect a reversed range to make grep give a diagnostic and exit 2.
With glibc (--without-included-regex), you get no diagnostic and exit 1.

OK, following the gnulib change at http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00006.html and subsequent bug report at http://sourceware.org/bugzilla/show_bug.cgi?id=11244 I've come up with the attached patch (against the latest snapshot). It results in grep using Glibc's regex implementation and all tests pass.

However, I will admit (hopefully before the laughter starts!) that I'm not an experienced C coder, so the patch might just be a fluke! I am certainly more than happy to receive constructive criticism on its contents or format though.

Regards,

Matt.
diff -Naur grep-2.5.4.183-9159.orig/configure grep-2.5.4.183-9159/configure
--- grep-2.5.4.183-9159.orig/configure  2010-03-17 17:01:06.000000000 +0000
+++ grep-2.5.4.183-9159/configure       2010-03-19 22:13:34.000000000 +0000
@@ -14652,7 +14652,7 @@
               return 1;
 
             /* Ensure that [b-a] is diagnosed as invalid. */
-            re_set_syntax (RE_SYNTAX_POSIX_EGREP);
+            re_set_syntax (RE_SYNTAX_POSIX_EGREP | RE_NO_EMPTY_RANGES);
             memset (&regex, 0, sizeof regex);
             s = re_compile_pattern ("a[b-a]", 6, &regex);
             if (s == 0)
diff -Naur grep-2.5.4.183-9159.orig/src/search.c 
grep-2.5.4.183-9159/src/search.c
--- grep-2.5.4.183-9159.orig/src/search.c       2010-03-17 10:23:12.000000000 
+0000
+++ grep-2.5.4.183-9159/src/search.c    2010-03-19 22:14:06.000000000 +0000
@@ -368,7 +368,7 @@
 
 COMPILE_FCT(Ecompile)
 {
-  return GEAcompile (pattern, size, RE_SYNTAX_POSIX_EGREP);
+  return GEAcompile (pattern, size, RE_SYNTAX_POSIX_EGREP | 
RE_NO_EMPTY_RANGES);
 }
 #endif /* !EGREP_PROGRAM */
 

Reply via email to