From 92f3a4c8e52e64c233e260431d095dbf88554c14 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 11 Apr 2013 05:47:31 +0000 Subject: [PATCH] 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. --- 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 348e09138..f49e88195 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2013-04-11 Dmitry V. Levin + + 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 stdalign: doc fix diff --git a/m4/regex.m4 b/m4/regex.m4 index 3334c1041..6d29dcfb1 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"; + /* */ + "\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 (®ex, 0, sizeof regex); s = re_compile_pattern (pat, sizeof pat - 1, ®ex); if (s) result |= 1; - else if (re_search (®ex, data, sizeof data - 1, - 0, sizeof data - 1, 0) - != 21) - result |= 1; + else + { + i = re_search (®ex, 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 5a94c14f0..15542f441 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"; + /* */ + "\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 (®ex, 0, sizeof regex); s = re_compile_pattern (pat, sizeof pat - 1, ®ex); if (s) result |= 1; - else if (re_search (®ex, data, sizeof data - 1, - 0, sizeof data - 1, 0) - != 21) - result |= 1; + else + { + i = re_search (®ex, data, sizeof data - 1, + 0, sizeof data - 1, 0); + if (i != 0 && i != 21) + result |= 1; + } } if (! setlocale (LC_ALL, "C")) -- 2.11.0