regex: use locale-independent comparison for codeset name
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 Jun 2012 22:16:07 +0000 (15:16 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 Jun 2012 22:16:55 +0000 (15:16 -0700)
See Bruno Haible's comment in <http://bugs.gnu.org/10305#120>.
* lib/regcomp.c (init_dfa): Use just ASCII case comparison
for codeset name.
* lib/regex_internal.h: Do not include <strings.h>, since we
no longer use strcasecmp.
* modules/regex (Depends-on): Remove strcase.

ChangeLog
lib/regcomp.c
lib/regex_internal.h
modules/regex

index b7e9da9..ceb5a55 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-06-26  Paul Eggert  <eggert@cs.ucla.edu>
+
+       regex: use locale-independent comparison for codeset name
+       See Bruno Haible's comment in <http://bugs.gnu.org/10305#120>.
+       * lib/regcomp.c (init_dfa): Use just ASCII case comparison
+       for codeset name.
+       * lib/regex_internal.h: Do not include <strings.h>, since we
+       no longer use strcasecmp.
+       * modules/regex (Depends-on): Remove strcase.
+
 2012-06-23  Bruno Haible  <bruno@clisp.org>
 
        getopt-posix: No longer guarantee that option processing is resettable.
index 7eb003b..6d5525a 100644 (file)
@@ -899,8 +899,10 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
                       != 0);
 #else
   codeset_name = nl_langinfo (CODESET);
-  if (strcasecmp (codeset_name, "UTF-8") == 0
-      || strcasecmp (codeset_name, "UTF8") == 0)
+  if ((codeset_name[0] == 'U' || codeset_name[0] == 'u')
+      && (codeset_name[1] == 'T' || codeset_name[1] == 't')
+      && (codeset_name[2] == 'F' || codeset_name[2] == 'f')
+      && strcmp (codeset_name + 3 + (codeset_name[3] == '-'), "8") == 0)
     dfa->is_utf8 = 1;
 
   /* We check exhaustively in the loop below if this charset is a
index 64cef47..2b9f697 100644 (file)
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <strings.h>
 
 #include <langinfo.h>
 #ifndef _LIBC
index 5371bab..cfc5d07 100644 (file)
@@ -26,7 +26,6 @@ mbsinit         [test $ac_use_included_regex = yes]
 nl_langinfo     [test $ac_use_included_regex = yes]
 stdbool         [test $ac_use_included_regex = yes]
 stdint          [test $ac_use_included_regex = yes]
-strcase         [test $ac_use_included_regex = yes]
 wchar           [test $ac_use_included_regex = yes]
 wcrtomb         [test $ac_use_included_regex = yes]
 wctype-h        [test $ac_use_included_regex = yes]