changeset 17377:e192356f48c2

regex-tests, regex: allow glibc re_search behavior 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.
author Dmitry V. Levin <ldv@altlinux.org>
date Thu, 11 Apr 2013 05:47:31 +0000
parents 79877e369ef2
children ee311a5bfb19
files ChangeLog m4/regex.m4 tests/test-regex.c
diffstat 3 files changed, 42 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2013-04-11  Dmitry V. Levin  <ldv@altlinux.org>
+
+	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  <eggert@cs.ucla.edu>
 
 	stdalign: doc fix
--- a/m4/regex.m4
+++ b/m4/regex.m4
@@ -84,17 +84,28 @@
                      */
                   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"))
--- a/tests/test-regex.c
+++ b/tests/test-regex.c
@@ -79,17 +79,28 @@
           */
           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"))