X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-regex.c;h=cac028b8c7a45baa6367c13a016ba46810cfa9bf;hb=cd56634a4a8179fd5a4419fbb3e27211b042ab1c;hp=e30a1e1b9976ed0777cb09a0da53374ef629f37b;hpb=819b1c38b9abd94d7d1ca2a77bbe16053b75029c;p=gnulib.git diff --git a/tests/test-regex.c b/tests/test-regex.c index e30a1e1b9..cac028b8c 100644 --- a/tests/test-regex.c +++ b/tests/test-regex.c @@ -1,5 +1,5 @@ /* Test regular expressions - Copyright 1996-2001, 2003-2013 Free Software Foundation, Inc. + Copyright 1996-2001, 2003-2014 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,12 +20,14 @@ #include #include -#include -#if HAVE_ALARM +#include +#if HAVE_DECL_ALARM # include # include #endif +#include "localcharset.h" + int main (void) { @@ -36,7 +38,7 @@ main (void) const char *s; struct re_registers regs; -#if HAVE_ALARM +#if HAVE_DECL_ALARM /* Some builds of glibc go into an infinite loop on this test. */ int alarm_value = 2; signal (SIGALRM, SIG_DFL); @@ -65,25 +67,41 @@ main (void) result |= 1; } - { - /* This test is from glibc bug 15078. - The test case is from Andreas Schwab in - . - */ - 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 (®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; - } + /* 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 + "CP1252". */ + if (strcmp (locale_charset (), "UTF-8") == 0) + { + /* This test is from glibc bug 15078. + The test case is from Andreas Schwab in + . + */ + 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\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 + { + 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")) return 1;