]> Savannah Git Hosting - gnulib.git/commitdiff
localename: Ensure multithread-safety in future changes.
authorBruno Haible <bruno@clisp.org>
Wed, 18 Dec 2019 16:03:42 +0000 (17:03 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 18 Dec 2019 16:03:42 +0000 (17:03 +0100)
* lib/localename.c (setlocale): Reference the system's setlocale().
(get_locale_t_name): Invoke setlocale_null instead of setlocale.
(gl_locale_name_posix): Likewise.
* modules/localename (Depends-on): Add setlocale-null.

ChangeLog
lib/localename.c
modules/localename

index 1c31c803e8401efdd68c529009d34f46b1f36c49..ff5ecb86e688b0de12feaec2c61cc08fd45d75ff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-12-18  Bruno Haible  <bruno@clisp.org>
+
+       localename: Ensure multithread-safety in future changes.
+       * lib/localename.c (setlocale): Reference the system's setlocale().
+       (get_locale_t_name): Invoke setlocale_null instead of setlocale.
+       (gl_locale_name_posix): Likewise.
+       * modules/localename (Depends-on): Add setlocale-null.
+
 2019-12-18  Bruno Haible  <bruno@clisp.org>
 
        setlocale-null: Make API more useful.
index d88743e4ce7a01d65370b8f89382ceaa0909bc7f..65dddeb3780aa78492977333da5b5a6e24b4c687 100644 (file)
@@ -1151,6 +1151,10 @@ extern char * getlocalename_l(int, locale_t);
 # endif
 #endif
 
+/* We want to use the system's setlocale() function here, not the gnulib
+   override.  */
+#undef setlocale
+
 
 #if HAVE_CFPREFERENCESCOPYAPPVALUE
 /* Mac OS X 10.4 or newer */
@@ -2725,7 +2729,7 @@ get_locale_t_name (int category, locale_t locale)
   if (locale == LC_GLOBAL_LOCALE)
     {
       /* Query the global locale.  */
-      const char *name = setlocale (category, NULL);
+      const char *name = setlocale_null (category);
       if (name != NULL)
         return struniq (name);
       else
@@ -3241,7 +3245,10 @@ gl_locale_name_posix (int category, const char *categoryname)
 #if defined WINDOWS_NATIVE
   if (LC_MIN <= category && category <= LC_MAX)
     {
-      const char *locname = setlocale (category, NULL);
+      const char *locname =
+        /* setlocale_null (category) is identical to setlocale (category, NULL)
+           on this platform.  */
+        setlocale (category, NULL);
 
       /* Convert locale name to LCID.  We don't want to use
          LocaleNameToLCID because (a) it is only available since Vista,
@@ -3258,7 +3265,7 @@ gl_locale_name_posix (int category, const char *categoryname)
     /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
        On some systems this can be done by the 'setlocale' function itself.  */
 #if defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
-    locname = setlocale (category, NULL);
+    locname = setlocale_null (category);
 #else
     /* On other systems we ignore what setlocale reports and instead look at the
        environment variables directly.  This is necessary
index 9eed220e7fe0b76b2b62ff61ba509a8b03ea67b3..c528acb51a6225140ea928bb8df49cb5033f220f 100644 (file)
@@ -18,6 +18,7 @@ flexmember
 strdup
 lock
 langinfo
+setlocale-null
 
 configure.ac:
 gl_LOCALENAME