]> Savannah Git Hosting - gnulib.git/commitdiff
localename: Add support for OpenIndiana.
authorBruno Haible <bruno@clisp.org>
Fri, 2 Feb 2018 20:34:14 +0000 (21:34 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 2 Feb 2018 20:34:14 +0000 (21:34 +0100)
* lib/localename.c (gl_locale_name_thread_unsafe): Add code for
Solaris 11 variants with uselocale() but without getlocalename_l().

ChangeLog
lib/localename.c

index 898d275927774cd9309c73c55b1f5e17f5729ef4..ad2ba9d27cbe12252f9c8ba18080f8f1f418a145 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-02  Bruno Haible  <bruno@clisp.org>
+
+       localename: Add support for OpenIndiana.
+       * lib/localename.c (gl_locale_name_thread_unsafe): Add code for
+       Solaris 11 variants with uselocale() but without getlocalename_l().
+
 2018-02-02  Bruno Haible  <bruno@clisp.org>
 
        malloca, xmalloca: Make multithread-safe.
index 00cf9979795420b9c7087196e9d5dd80391e9735..2133cbc7ccb2e2bc2040697f26e0922578151122 100644 (file)
@@ -2592,7 +2592,7 @@ get_lcid (const char *locale_name)
 #endif
 
 
-#if HAVE_USELOCALE /* glibc, Solaris >= 12 or Mac OS X */
+#if HAVE_USELOCALE /* glibc, Mac OS X, Solaris 11 OpenIndiana, or Solaris 12  */
 
 /* Simple hash set of strings.  We don't want to drag in lots of hash table
    code here.  */
@@ -2731,9 +2731,27 @@ gl_locale_name_thread_unsafe (int category, const char *categoryname)
             return "";
           }
         return querylocale (mask, thread_locale);
-#  elif defined __sun && HAVE_GETLOCALENAME_L
+#  elif defined __sun
+#   if HAVE_GETLOCALENAME_L
         /* Solaris >= 12.  */
         return getlocalename_l (category, thread_locale);
+#   else
+        /* Solaris 11 OpenIndiana.
+           For the internal structure of locale objects, see
+           https://github.com/OpenIndiana/illumos-gate/blob/master/usr/src/lib/libc/port/locale/localeimpl.h  */
+        switch (category)
+          {
+          case LC_CTYPE:
+          case LC_NUMERIC:
+          case LC_TIME:
+          case LC_COLLATE:
+          case LC_MONETARY:
+          case LC_MESSAGES:
+            return ((const char * const *) thread_locale)[category];
+          default: /* We shouldn't get here.  */
+            return "";
+          }
+#   endif
 #  elif defined __CYGWIN__
         /* Cygwin < 2.6 lacks uselocale and thread-local locales altogether.
            Cygwin <= 2.6.1 lacks NL_LOCALE_NAME, requiring peeking inside