]> Savannah Git Hosting - gnulib.git/commitdiff
localename-unsafe: Optimize.
authorBruno Haible <bruno@clisp.org>
Thu, 15 Feb 2024 18:34:16 +0000 (19:34 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 15 Feb 2024 21:30:53 +0000 (22:30 +0100)
* lib/localename-unsafe.c (gl_locale_name_posix_unsafe): Call
setlocale_null_unlocked instead of setlocale_null.
* modules/localename-unsafe (Depends-on): Add setlocale-null-unlocked.

ChangeLog
lib/localename-unsafe.c
modules/localename-unsafe

index 761f51bc36228bbbd58eeb3e2f4cf1c364c7eaca..487e5cf1dd019bfab7d5413982b99a7fa9b271bf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-02-15  Bruno Haible  <bruno@clisp.org>
+
+       localename-unsafe: Optimize.
+       * lib/localename-unsafe.c (gl_locale_name_posix_unsafe): Call
+       setlocale_null_unlocked instead of setlocale_null.
+       * modules/localename-unsafe (Depends-on): Add setlocale-null-unlocked.
+
 2024-02-15  Bruno Haible  <bruno@clisp.org>
 
        setlocale_null-unlocked: Add tests.
index 5770d4a859f46091d6d5146556f3c743edb03038..845ee92c3139eda293095d5be729ddc4604df6dc 100644 (file)
@@ -3265,7 +3265,10 @@ gl_locale_name_posix_unsafe (int category, _GL_UNUSED 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_null (category);
+    /* All platforms for which HAVE_LOCALE_NULL is defined happen to have
+       SETLOCALE_NULL_ONE_MTSAFE defined to 1.  Therefore it is OK, here,
+       to call setlocale_null_unlocked instead of setlocale_null.  */
+    locname = setlocale_null_unlocked (category);
 #else
     /* On other systems we ignore what setlocale reports and instead look at the
        environment variables directly.  This is necessary
index 3cb38a7c518d84b2727f7077fa9e9a4c4e8087db..4b8ad0279b97f108d0a5384202e0ed3d8e3a0fae 100644 (file)
@@ -24,6 +24,7 @@ strdup
 lock
 langinfo
 setlocale-null
+setlocale-null-unlocked
 thread-optim
 
 configure.ac: