about summary refs log tree commit diff
path: root/locale/setlocale.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-05-15 18:36:28 +0000
committerUlrich Drepper <drepper@redhat.com>2006-05-15 18:36:28 +0000
commit9446614c28b003812b59e99ff1f38aa526234c1c (patch)
treec7109087c02a598a6d4bb5cba4f77d6e62ce7d12 /locale/setlocale.c
parent88dbff8cf980b4b63bdbb0e987489bc20176f220 (diff)
downloadglibc-9446614c28b003812b59e99ff1f38aa526234c1c.tar.gz
glibc-9446614c28b003812b59e99ff1f38aa526234c1c.tar.xz
glibc-9446614c28b003812b59e99ff1f38aa526234c1c.zip
* locale/setlocale.c: Change _nl_category_names into a string.
	Add new _nl_category_name_idxs.  Change all users.
	* locale/localeinfo.h: Adjust declaration of _nl_category_names.
	Declare _nl_category_name_idxs.
	* locale/findlocale.c: Adjust for _nl_category_names change.
	* locale/loadlocale.c: Likewise.
	* locale/newlocale.c: Likewise.
	* intl/dcigettext.c: Likewise.
Diffstat (limited to 'locale/setlocale.c')
-rw-r--r--locale/setlocale.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/locale/setlocale.c b/locale/setlocale.c
index 50bf8e772f..c1b8c3faec 100644
--- a/locale/setlocale.c
+++ b/locale/setlocale.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1995-2000, 2002, 2003, 2004
+/* Copyright (C) 1991, 1992, 1995-2000, 2002, 2003, 2004, 2006
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -66,18 +66,27 @@ static char *const _nl_current_used[] =
 #endif
 
 
-/* Define an array of category names (also the environment variable names),
-   indexed by integral category.  */
-const char *const _nl_category_names[] =
+/* Define an array of category names (also the environment variable names).  */
+const union catnamestr_t _nl_category_names attribute_hidden =
   {
+    {
 #define DEFINE_CATEGORY(category, category_name, items, a) \
-    [category] = category_name,
+      category_name,
 #include "categories.def"
-#undef	DEFINE_CATEGORY
-    [LC_ALL] = "LC_ALL"
+#undef DEFINE_CATEGORY
+    }
   };
+
+const uint8_t _nl_category_name_idxs[__LC_LAST] attribute_hidden =
+  {
+#define DEFINE_CATEGORY(category, category_name, items, a) \
+    [category] = offsetof (union catnamestr_t, CATNAMEMF (__LINE__)),
+#include "categories.def"
+#undef DEFINE_CATEGORY
+  };
+
 /* An array of their lengths, for convenience.  */
-const size_t _nl_category_name_sizes[] =
+const uint8_t _nl_category_name_sizes[] attribute_hidden =
   {
 #define DEFINE_CATEGORY(category, category_name, items, a) \
     [category] = sizeof (category_name) - 1,
@@ -173,7 +182,7 @@ new_composite_name (int category, const char *newnames[__LC_LAST])
 	const char *name = (category == LC_ALL ? newnames[i] :
 			    category == i ? newnames[0] :
 			    _nl_global_locale.__names[i]);
-	p = __stpcpy (p, _nl_category_names[i]);
+	p = __stpcpy (p, _nl_category_names.str + _nl_category_name_idxs[i]);
 	*p++ = '=';
 	p = __stpcpy (p, name);
 	*p++ = ';';
@@ -275,7 +284,9 @@ setlocale (int category, const char *locale)
 	      for (cnt = 0; cnt < __LC_LAST; ++cnt)
 		if (cnt != LC_ALL
 		    && (size_t) (cp - np) == _nl_category_name_sizes[cnt]
-		    && memcmp (np, _nl_category_names[cnt], cp - np) == 0)
+		    && (memcmp (np, (_nl_category_names.str
+				     + _nl_category_name_idxs[cnt]), cp - np)
+			== 0))
 		  break;
 
 	      if (cnt == __LC_LAST)