bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH 3/2] regex-tests: pass on mingw


From: Eric Blake
Subject: [PATCH 3/2] regex-tests: pass on mingw
Date: Tue, 12 Mar 2013 15:57:12 -0600

test-regex failed on mingw; and I traced it in gdb to an instance
of init_dfa() setting dfa->is_utf8 to 0 in spite of setlocale()
claiming success for "en_US.UTF-8".  test-wcwidth already has
precedent for skipping utf-8 tests where the system (or gnulib
setlocale replacement, in this case) lies about utf-8 support.

* modules/regex-tests (Depends-on): Add localcharset.
* tests/test-regex.c (main): Use it to skip test on mingw.

Signed-off-by: Eric Blake <address@hidden>
---

Getting the test to compile was a good start, but this followup is
needed to get the test to actually pass on mingw.

 ChangeLog           |  6 ++++++
 modules/regex-tests |  1 +
 tests/test-regex.c  | 45 ++++++++++++++++++++++++++-------------------
 3 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a608362..bb0e711 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-03-12  Eric Blake  <address@hidden>
+
+       regex-tests: pass on mingw
+       * modules/regex-tests (Depends-on): Add localcharset.
+       * tests/test-regex.c (main): Use it to skip test on mingw.
+
 2013-03-11  Eric Blake  <address@hidden>

        tests: make it easier to bypass alarm time in debugger
diff --git a/modules/regex-tests b/modules/regex-tests
index eb1b1d3..cfff7bf 100644
--- a/modules/regex-tests
+++ b/modules/regex-tests
@@ -3,6 +3,7 @@ tests/test-regex.c
 tests/macros.h

 Depends-on:
+localcharset

 configure.ac:

diff --git a/tests/test-regex.c b/tests/test-regex.c
index 6829035..83f58de 100644
--- a/tests/test-regex.c
+++ b/tests/test-regex.c
@@ -26,6 +26,8 @@
 # include <signal.h>
 #endif

+#include "localcharset.h"
+
 int
 main (void)
 {
@@ -65,25 +67,30 @@ main (void)
           result |= 1;
       }

-      {
-        /* This test is from glibc bug 15078.
-           The test case is from Andreas Schwab in
-           <http://www.sourceware.org/ml/libc-alpha/2013-01/msg00967.html>.
-           */
-        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";
-        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;
-      }
+      /* Check whether it's really a UTF-8 locale.
+         On mingw, the setlocale call succeeds but returns
+         "English_United States.1252", with locale_charset() returning
+         "ASCII".  */
+      if (strcmp (locale_charset (), "UTF-8") == 0)
+        {
+          /* This test is from glibc bug 15078.
+             The test case is from Andreas Schwab in
+             <http://www.sourceware.org/ml/libc-alpha/2013-01/msg00967.html>.
+          */
+          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";
+          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;
+        }

       if (! setlocale (LC_ALL, "C"))
         return 1;
-- 
1.8.1.4




reply via email to

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