]> Savannah Git Hosting - gnulib.git/commitdiff
setlocale-null: Refactor.
authorBruno Haible <bruno@clisp.org>
Thu, 15 Feb 2024 08:47:08 +0000 (09:47 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 15 Feb 2024 18:58:01 +0000 (19:58 +0100)
* lib/setlocale_null.c
(setlocale_null_r_with_lock): Renamed from setlocale_null_with_lock.
(setlocale_null_r_unlocked): Renamed from setlocale_null_unlocked.
(setlocale_null_unlocked): Renamed from setlocale_null_androidfix.

ChangeLog
lib/setlocale_null.c

index 05732c7e9d0efcd0ad67c04e840caefc00144756..4ba5cbfc28d2a82e1f7e725e2274e6363a9af4cb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-02-15  Bruno Haible  <bruno@clisp.org>
+
+       setlocale-null: Refactor.
+       * lib/setlocale_null.c
+       (setlocale_null_r_with_lock): Renamed from setlocale_null_with_lock.
+       (setlocale_null_r_unlocked): Renamed from setlocale_null_unlocked.
+       (setlocale_null_unlocked): Renamed from setlocale_null_androidfix.
+
 2024-02-15  Bruno Haible  <bruno@clisp.org>
 
        localename-unsafe: New module.
index 697502fbfe8bb088234a7fbfbabb5dfe04aca748..152452e04ffa118fc414b5386565d9f678a1c5ce 100644 (file)
@@ -63,7 +63,7 @@
 #undef setlocale
 
 static const char *
-setlocale_null_androidfix (int category)
+setlocale_null_unlocked (int category)
 {
   const char *result = setlocale (category, NULL);
 
@@ -94,7 +94,7 @@ setlocale_null_androidfix (int category)
 }
 
 static int
-setlocale_null_unlocked (int category, char *buf, size_t bufsize)
+setlocale_null_r_unlocked (int category, char *buf, size_t bufsize)
 {
 #if defined _WIN32 && !defined __CYGWIN__ && defined _MSC_VER
   /* On native Windows, nowadays, the setlocale() implementation is based
@@ -143,7 +143,7 @@ setlocale_null_unlocked (int category, char *buf, size_t bufsize)
         }
     }
 #else
-  const char *result = setlocale_null_androidfix (category);
+  const char *result = setlocale_null_unlocked (category);
 
   if (result == NULL)
     {
@@ -181,7 +181,7 @@ setlocale_null_unlocked (int category, char *buf, size_t bufsize)
 
 #if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE) /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin < 3.4.6 */
 
-/* Use a lock, so that no two threads can invoke setlocale_null_unlocked
+/* Use a lock, so that no two threads can invoke setlocale_null_r_unlocked
    at the same time.  */
 
 /* Prohibit renaming this symbol.  */
@@ -190,20 +190,20 @@ setlocale_null_unlocked (int category, char *buf, size_t bufsize)
 # if AVOID_ANY_THREADS
 
 /* The option '--disable-threads' explicitly requests no locking.  */
-#  define setlocale_null_with_lock setlocale_null_unlocked
+#  define setlocale_null_r_with_lock setlocale_null_r_unlocked
 
 # elif defined _WIN32 && !defined __CYGWIN__
 
 extern __declspec(dllimport) CRITICAL_SECTION *gl_get_setlocale_null_lock (void);
 
 static int
-setlocale_null_with_lock (int category, char *buf, size_t bufsize)
+setlocale_null_r_with_lock (int category, char *buf, size_t bufsize)
 {
   CRITICAL_SECTION *lock = gl_get_setlocale_null_lock ();
   int ret;
 
   EnterCriticalSection (lock);
-  ret = setlocale_null_unlocked (category, buf, bufsize);
+  ret = setlocale_null_r_unlocked (category, buf, bufsize);
   LeaveCriticalSection (lock);
 
   return ret;
@@ -234,7 +234,7 @@ extern
 #  endif
 
 static int
-setlocale_null_with_lock (int category, char *buf, size_t bufsize)
+setlocale_null_r_with_lock (int category, char *buf, size_t bufsize)
 {
   if (pthread_in_use())
     {
@@ -243,14 +243,14 @@ setlocale_null_with_lock (int category, char *buf, size_t bufsize)
 
       if (pthread_mutex_lock (lock))
         abort ();
-      ret = setlocale_null_unlocked (category, buf, bufsize);
+      ret = setlocale_null_r_unlocked (category, buf, bufsize);
       if (pthread_mutex_unlock (lock))
         abort ();
 
       return ret;
     }
   else
-    return setlocale_null_unlocked (category, buf, bufsize);
+    return setlocale_null_r_unlocked (category, buf, bufsize);
 }
 
 # elif HAVE_THREADS_H
@@ -258,14 +258,14 @@ setlocale_null_with_lock (int category, char *buf, size_t bufsize)
 extern mtx_t *gl_get_setlocale_null_lock (void);
 
 static int
-setlocale_null_with_lock (int category, char *buf, size_t bufsize)
+setlocale_null_r_with_lock (int category, char *buf, size_t bufsize)
 {
   mtx_t *lock = gl_get_setlocale_null_lock ();
   int ret;
 
   if (mtx_lock (lock) != thrd_success)
     abort ();
-  ret = setlocale_null_unlocked (category, buf, bufsize);
+  ret = setlocale_null_r_unlocked (category, buf, bufsize);
   if (mtx_unlock (lock) != thrd_success)
     abort ();
 
@@ -282,27 +282,27 @@ setlocale_null_r (int category, char *buf, size_t bufsize)
 #if SETLOCALE_NULL_ALL_MTSAFE
 # if SETLOCALE_NULL_ONE_MTSAFE
 
-  return setlocale_null_unlocked (category, buf, bufsize);
+  return setlocale_null_r_unlocked (category, buf, bufsize);
 
 # else
 
   if (category == LC_ALL)
-    return setlocale_null_unlocked (category, buf, bufsize);
+    return setlocale_null_r_unlocked (category, buf, bufsize);
   else
-    return setlocale_null_with_lock (category, buf, bufsize);
+    return setlocale_null_r_with_lock (category, buf, bufsize);
 
 # endif
 #else
 # if SETLOCALE_NULL_ONE_MTSAFE
 
   if (category == LC_ALL)
-    return setlocale_null_with_lock (category, buf, bufsize);
+    return setlocale_null_r_with_lock (category, buf, bufsize);
   else
-    return setlocale_null_unlocked (category, buf, bufsize);
+    return setlocale_null_r_unlocked (category, buf, bufsize);
 
 # else
 
-  return setlocale_null_with_lock (category, buf, bufsize);
+  return setlocale_null_r_with_lock (category, buf, bufsize);
 
 # endif
 #endif
@@ -312,7 +312,7 @@ const char *
 setlocale_null (int category)
 {
 #if SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE
-  return setlocale_null_androidfix (category);
+  return setlocale_null_unlocked (category);
 #else
 
   /* This call must be multithread-safe.  To achieve this without using
@@ -328,7 +328,7 @@ setlocale_null (int category)
   if (category == LC_ALL)
     {
 # if SETLOCALE_NULL_ALL_MTSAFE
-      return setlocale_null_androidfix (LC_ALL);
+      return setlocale_null_unlocked (LC_ALL);
 # else
       char buf[SETLOCALE_NULL_ALL_MAX];
       static char resultbuf[SETLOCALE_NULL_ALL_MAX];
@@ -342,7 +342,7 @@ setlocale_null (int category)
   else
     {
 # if SETLOCALE_NULL_ONE_MTSAFE
-      return setlocale_null_androidfix (category);
+      return setlocale_null_unlocked (category);
 # else
       enum
         {