bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH] regex-tests, regex: allow glibc re_search behavior


From: Dmitry V. Levin
Subject: [PATCH] regex-tests, regex: allow glibc re_search behavior
Date: Thu, 11 Apr 2013 10:40:24 +0400

The data passed to re_search by the test for glibc bug 15078 is a
multi-character collating element followed by a single character.
According to POSIX, "It is unspecified whether a non-matching list
expression matches a multi-character collating element that is not
matched by any of the expressions."

One of differences between glibc and gnulib implementations of
re_search is that glibc re_search matches multi-character
collating elements in that case while gnulib re_search doesn't.

Since both re_search implementations conform to standard, change
the test to allow glibc re_search behavior.

* tests/test-regex.c (main): In test for glibc bug 15078, reformat
re_search input data to make the multi-character collating element
in it clearly visible, and treat re_search return code 0 as valid.
* m4/regex.m4 (gl_REGEX): Likewise.
---
 ChangeLog          |  8 ++++++++
 m4/regex.m4        | 23 +++++++++++++++++------
 tests/test-regex.c | 23 +++++++++++++++++------
 3 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 348e091..f49e881 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2013-04-11  Dmitry V. Levin  <address@hidden>
+
+       regex-tests, regex: allow glibc re_search behavior
+       * tests/test-regex.c (main): In test for glibc bug 15078, reformat
+       re_search input data to make the multi-character collating element
+       in it clearly visible, and treat re_search return code 0 as valid.
+       * m4/regex.m4 (gl_REGEX): Likewise.
+
 2013-03-30  Paul Eggert  <address@hidden>
 
        stdalign: doc fix
diff --git a/m4/regex.m4 b/m4/regex.m4
index 3334c10..6d29dcf 100644
--- a/m4/regex.m4
+++ b/m4/regex.m4
@@ -84,17 +84,28 @@ AC_DEFUN([gl_REGEX],
                      */
                   static char const pat[] = "[^x]x";
                   static char const data[] =
-                    "\xe1\x80\x80\xe1\x80\xbb\xe1\x80\xbd\xe1\x80\x94\xe1\x80"
-                    "\xba\xe1\x80\xaf\xe1\x80\x95\xe1\x80\xbax";
+                    /* 
<U1000><U103B><U103D><U1014><U103A><U102F><U1015><U103A> */
+                    "\xe1\x80\x80"
+                    "\xe1\x80\xbb"
+                    "\xe1\x80\xbd"
+                    "\xe1\x80\x94"
+                    "\xe1\x80\xba"
+                    "\xe1\x80\xaf"
+                    "\xe1\x80\x95"
+                    "\xe1\x80\xba"
+                    "x";
                   re_set_syntax (0);
                   memset (&regex, 0, sizeof regex);
                   s = re_compile_pattern (pat, sizeof pat - 1, &regex);
                   if (s)
                     result |= 1;
-                  else if (re_search (&regex, data, sizeof data - 1,
-                                      0, sizeof data - 1, 0)
-                           != 21)
-                    result |= 1;
+                  else
+                    {
+                      i = re_search (&regex, data, sizeof data - 1,
+                                     0, sizeof data - 1, 0);
+                      if (i != 0 && i != 21)
+                        result |= 1;
+                    }
                 }
 
                 if (! setlocale (LC_ALL, "C"))
diff --git a/tests/test-regex.c b/tests/test-regex.c
index 5a94c14..15542f4 100644
--- a/tests/test-regex.c
+++ b/tests/test-regex.c
@@ -79,17 +79,28 @@ main (void)
           */
           static char const pat[] = "[^x]x";
           static char const data[] =
-            "\xe1\x80\x80\xe1\x80\xbb\xe1\x80\xbd\xe1\x80\x94\xe1\x80"
-            "\xba\xe1\x80\xaf\xe1\x80\x95\xe1\x80\xbax";
+            /* <U1000><U103B><U103D><U1014><U103A><U102F><U1015><U103A> */
+            "\xe1\x80\x80"
+            "\xe1\x80\xbb"
+            "\xe1\x80\xbd"
+            "\xe1\x80\x94"
+            "\xe1\x80\xba"
+            "\xe1\x80\xaf"
+            "\xe1\x80\x95"
+            "\xe1\x80\xba"
+            "x";
           re_set_syntax (0);
           memset (&regex, 0, sizeof regex);
           s = re_compile_pattern (pat, sizeof pat - 1, &regex);
           if (s)
             result |= 1;
-          else if (re_search (&regex, data, sizeof data - 1,
-                              0, sizeof data - 1, 0)
-                   != 21)
-            result |= 1;
+          else
+            {
+              i = re_search (&regex, data, sizeof data - 1,
+                             0, sizeof data - 1, 0);
+              if (i != 0 && i != 21)
+                result |= 1;
+            }
         }
 
       if (! setlocale (LC_ALL, "C"))

-- 
ldv



reply via email to

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