diff lib/regcomp.c @ 12567:ceb1562f60a5

regcomp: sync from glibc; always use nl_langinfo * lib/regcomp.c (init_dfa) [!LIBC]: Always use nl_langinfo (CODESET), now that gnulib provides it. Recognize UTF8 as well as UTF-8. * lib/regex_internal.h: Always include <langinfo.h>, now. * modules/regex (Depends-on): Add nl_langinfo.
author Jim Meyering <meyering@redhat.com>
date Mon, 04 Jan 2010 09:07:52 +0100
parents c2cbabec01dd
children c97a23e70cb7
line wrap: on
line diff
--- a/lib/regcomp.c	Mon Jan 04 06:36:13 2010 -0700
+++ b/lib/regcomp.c	Mon Jan 04 09:07:52 2010 +0100
@@ -850,6 +850,9 @@
 init_dfa (re_dfa_t *dfa, size_t pat_len)
 {
   __re_size_t table_size;
+#ifndef _LIBC
+  char *codeset_name;
+#endif
 #ifdef RE_ENABLE_I18N
   size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t));
 #else
@@ -893,7 +896,9 @@
   dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII)
 		       != 0);
 #else
-  if (strcmp (locale_charset (), "UTF-8") == 0)
+  codeset_name = nl_langinfo (CODESET);
+  if (strcasecmp (codeset_name, "UTF-8") == 0
+      || strcasecmp (codeset_name, "UTF8") == 0)
     dfa->is_utf8 = 1;
 
   /* We check exhaustively in the loop below if this charset is a