aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-08-29 05:57:16 +0000
committerRoland McGrath <roland@gnu.org>2002-08-29 05:57:16 +0000
commit9a411bf59fc681103e6a509ec3e13c68e8c61224 (patch)
treef62b3b3542ee9687ab654590687c22f348f47e67
parent963e3b588003bafb2529e4a989211b0ecc39c684 (diff)
downloadglibc-9a411bf59fc681103e6a509ec3e13c68e8c61224.zip
glibc-9a411bf59fc681103e6a509ec3e13c68e8c61224.tar.gz
glibc-9a411bf59fc681103e6a509ec3e13c68e8c61224.tar.bz2
* 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.
-rw-r--r--ChangeLog4
-rw-r--r--locale/findlocale.c19
-rw-r--r--locale/setlocale.c9
3 files changed, 28 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index d8455f8..4630f17 100644
--- 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.
diff --git a/locale/findlocale.c b/locale/findlocale.c
index 8048011..6ecfdc2 100644
--- a/locale/findlocale.c
+++ b/locale/findlocale.c
@@ -30,9 +30,22 @@
#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
diff --git a/locale/setlocale.c b/locale/setlocale.c
index 1944336..c64db08 100644
--- a/locale/setlocale.c
+++ b/locale/setlocale.c
@@ -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. */