* locale/findlocale.c [NL_CURRENT_INDIRECT] (_nl_C): New variable.
authorRoland McGrath <roland@gnu.org>
Thu, 29 Aug 2002 05:57:16 +0000 (05:57 +0000)
committerRoland McGrath <roland@gnu.org>
Thu, 29 Aug 2002 05:57:16 +0000 (05:57 +0000)
* locale/setlocale.c (setlocale) [NL_CURRENT_INDIRECT]: Null return
from _nl_find_locale ok if for _nl_C_name.

ChangeLog
locale/findlocale.c
locale/setlocale.c

index d8455f871e5280675f8c04c4899f954124758392..4630f17d9430dfa4f3367f23fd25c2edb3cd156c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2002-08-28  Roland McGrath  <roland@redhat.com>
 
+       * locale/findlocale.c [NL_CURRENT_INDIRECT] (_nl_C): New variable.
+       * locale/setlocale.c (setlocale) [NL_CURRENT_INDIRECT]: Null return
+       from _nl_find_locale ok if for _nl_C_name.
+
        * locale/nl_langinfo.c [NL_CURRENT_INDIRECT]: Use a categories.def
        iterator to refer to each category's _nl_current_LC_FOO symbol, so
        we know they are all linked in.
index 80480113c0cc62ab949e0519e0922bf7cb0bd3f8..6ecfdc2324a823b6613a60aa3efe5cbe57e3f981 100644 (file)
 #include "../iconv/gconv_charset.h"
 
 
-#ifndef SHARED
-/* Constant data defined in setlocale.c.  */
-extern struct locale_data *const _nl_C[] attribute_hidden;
+#ifdef NL_CURRENT_INDIRECT
+# define DEFINE_CATEGORY(category, category_name, items, a) \
+extern struct locale_data _nl_C_##category; \
+weak_extern (_nl_C_##category)
+# include "categories.def"
+# undef        DEFINE_CATEGORY
+
+/* Array indexed by category of pointers to _nl_C_CATEGORY slots.
+   Elements are zero for categories whose data is never used.  */
+struct locale_data *const _nl_C[] attribute_hidden =
+  {
+# define DEFINE_CATEGORY(category, category_name, items, a) \
+    [category] = &_nl_C_##category,
+# include "categories.def"
+# undef        DEFINE_CATEGORY
+  };
 #else
 # define _nl_C         (_nl_C_locobj.__locales)
 #endif
index 1944336004b907770f7a246a8dc3371b02a9350b..c64db08f057011cbc0d02b3aaaf635d6dfa515a1 100644 (file)
@@ -307,7 +307,14 @@ setlocale (int category, const char *locale)
                                                 &newnames[category]);
 
            if (newdata[category] == NULL)
-             break;
+             {
+#ifdef NL_CURRENT_INDIRECT
+               if (newnames[category] == _nl_C_name)
+                 /* Null because it's the weak value of _nl_C_LC_FOO.  */
+                 continue;
+#endif
+               break;
+             }
 
            /* We must not simply free a global locale since we have no
               control over the usage.  So we mark it as un-deletable.  */