From: Bruno Haible Date: Fri, 2 Feb 2018 20:34:14 +0000 (+0100) Subject: localename: Add support for OpenIndiana. X-Git-Tag: v1.0~5744 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=1cbad88ad55560234c43faa138d04d05cdf0562a;p=gnulib.git 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(). --- diff --git a/ChangeLog b/ChangeLog index 898d275927..ad2ba9d27c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018-02-02 Bruno Haible + + 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 malloca, xmalloca: Make multithread-safe. diff --git a/lib/localename.c b/lib/localename.c index 00cf997979..2133cbc7cc 100644 --- a/lib/localename.c +++ b/lib/localename.c @@ -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