From d4903bb0efac5e399b785c71367d8cda3fb539ab Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 26 Jun 2012 15:16:07 -0700 Subject: [PATCH] regex: use locale-independent comparison for codeset name See Bruno Haible's comment in . * lib/regcomp.c (init_dfa): Use just ASCII case comparison for codeset name. * lib/regex_internal.h: Do not include , since we no longer use strcasecmp. * modules/regex (Depends-on): Remove strcase. --- ChangeLog | 10 ++++++++++ lib/regcomp.c | 6 ++++-- lib/regex_internal.h | 1 - modules/regex | 1 - 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b7e9da957..ceb5a55d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2012-06-26 Paul Eggert + + regex: use locale-independent comparison for codeset name + See Bruno Haible's comment in . + * lib/regcomp.c (init_dfa): Use just ASCII case comparison + for codeset name. + * lib/regex_internal.h: Do not include , since we + no longer use strcasecmp. + * modules/regex (Depends-on): Remove strcase. + 2012-06-23 Bruno Haible getopt-posix: No longer guarantee that option processing is resettable. diff --git a/lib/regcomp.c b/lib/regcomp.c index 7eb003bfa..6d5525a6f 100644 --- a/lib/regcomp.c +++ b/lib/regcomp.c @@ -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 diff --git a/lib/regex_internal.h b/lib/regex_internal.h index 64cef470e..2b9f69756 100644 --- a/lib/regex_internal.h +++ b/lib/regex_internal.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #ifndef _LIBC diff --git a/modules/regex b/modules/regex index 5371bab30..cfc5d0707 100644 --- a/modules/regex +++ b/modules/regex @@ -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] -- 2.11.0