]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
intl: Improve support for per-thread locales on Solaris 11.4.
authorBruno Haible <bruno@clisp.org>
Tue, 23 Oct 2018 20:48:46 +0000 (22:48 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Oct 2018 20:48:46 +0000 (22:48 +0200)
* gettext-runtime/intl/localename.c: Update from gnulib:
Handle HAVE_SOLARIS114_LOCALES through Solaris specific code.
* gettext-runtime/intl/localename-table.in.h: Update from gnulib's
localename-table.h.
* gettext-runtime/intl/localename-table.c: Update from gnulib.
* gettext-runtime/m4/intl-thread-locale.m4: Renamed from
gettext-runtime/m4/intlsolaris.m4.
(gt_INTL_THREAD_LOCALE_NAME): Renamed from gt_INTL_SOLARIS. Define
HAVE_SOLARIS114_LOCALES instead of HAVE_NAMELESS_LOCALES.
* gettext-runtime/m4/intl.m4: Update from gnulib:
(AM_INTL_SUBDIR): Require gt_INTL_THREAD_LOCALE_NAME. Test for 'uselocale'. Set
HAVE_NAMELESS_LOCALES.
(gt_INTL_SUBDIR_CORE): Don't invoke gt_INTL_SOLARIS. Don't set
HAVE_NAMELESS_LOCALES here.
* gettext-runtime/m4/Makefile.am (EXTRA_DIST): List intl-thread-locale.m4, not
intlsolaris.m4.
* gettext-tools/m4/Makefile.am (aclocal_DATA): List intl-thread-locale.m4, not
intlsolaris.m4.
* gettext-tools/misc/gettextize.in (m4filelist): List intl-thread-locale.m4, not
intlsolaris.m4.
* Makefile.am (distcheck-hook): Check intl-thread-locale.m4, not intlsolaris.m4.
* gettext-tools/doc/gettext.texi (aclocal): List intl-thread-locale.m4, not
intlsolaris.m4.
* PACKAGING: List intl-thread-locale.m4, not intlsolaris.m4.

12 files changed:
.gitignore
Makefile.am
PACKAGING
gettext-runtime/intl/localename-table.c
gettext-runtime/intl/localename-table.in.h
gettext-runtime/intl/localename.c
gettext-runtime/m4/Makefile.am
gettext-runtime/m4/intl-thread-locale.m4 [moved from gettext-runtime/m4/intlsolaris.m4 with 67% similarity]
gettext-runtime/m4/intl.m4
gettext-tools/doc/gettext.texi
gettext-tools/m4/Makefile.am
gettext-tools/misc/gettextize.in

index da7963371bc3c8c571b384e2720d3ae900f5c638..dc21f7fd3e4a6421ccaf4b9f94687d32ee97bdbd 100644 (file)
@@ -745,6 +745,7 @@ core
 # Other.
 /gettext-runtime/intl/libgnuintl.h
 /gettext-runtime/intl/libgnuintl.la
+/gettext-runtime/intl/localename-table.h
 /gettext-runtime/libasprintf/autosprintf.h
 /gettext-runtime/libasprintf/alloca.h
 /gettext-runtime/libasprintf/errno.h
index 8260e9aa55644736ddb08c2585f35ed36f005d49..60de5b2c53e0b95ef4a7fdac69b0cfdbe279435a 100644 (file)
@@ -80,9 +80,9 @@ distcheck-hook:
        cmp -s gettext-runtime/m4/iconv.m4 gettext-tools/gnulib-m4/iconv.m4
        cmp -s gettext-runtime/m4/intdiv0.m4 gettext-tools/gnulib-m4/intdiv0.m4
        cmp -s gettext-runtime/m4/intl.m4 gettext-tools/gnulib-m4/intl.m4
+       cmp -s gettext-runtime/m4/intl-thread-locale.m4 gettext-tools/gnulib-m4/intl-thread-locale.m4
        cmp -s gettext-runtime/m4/intldir.m4 gettext-tools/gnulib-m4/intldir.m4
        cmp -s gettext-runtime/m4/intlmacosx.m4 gettext-tools/gnulib-m4/intlmacosx.m4
-       cmp -s gettext-runtime/m4/intlsolaris.m4 gettext-tools/gnulib-m4/intlsolaris.m4
        cmp -s gettext-runtime/m4/intmax.m4 gettext-tools/gnulib-m4/intmax.m4
        cmp -s gettext-runtime/m4/inttypes-pri.m4 gettext-tools/gnulib-m4/inttypes-pri.m4
        cmp -s gettext-runtime/m4/inttypes_h.m4 gettext-tools/gnulib-m4/inttypes_h.m4
index 4fbf4424e60a5bbb840920bd54a1baadf2ddef06..64c44bcfe56d18c6f0bf0390124800c76e508df6 100644 (file)
--- a/PACKAGING
+++ b/PACKAGING
@@ -124,9 +124,9 @@ following file list.
       $prefix/share/aclocal/iconv.m4
       $prefix/share/aclocal/intdiv0.m4
       $prefix/share/aclocal/intl.m4
+      $prefix/share/aclocal/intl-thread-locale.m4
       $prefix/share/aclocal/intldir.m4
       $prefix/share/aclocal/intlmacosx.m4
-      $prefix/share/aclocal/intlsolaris.m4
       $prefix/share/aclocal/intmax.m4
       $prefix/share/aclocal/inttypes_h.m4
       $prefix/share/aclocal/inttypes-pri.m4
index 54fd67d083a4dc02f0a8e0676f9ec3b77581905d..4b0810d1e90083181965fe341a49d9b9059524d0 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <config.h>
 
-#if HAVE_USELOCALE && HAVE_NAMELESS_LOCALES /* Solaris >= 11.4 */
+#if HAVE_USELOCALE && HAVE_NAMELESS_LOCALES
 
 /* Specification.  */
 #include "localename-table.h"
index 0d204d6d14a20ea5077abc6a038d70adf726bbb9..07e92f6616dda89d4076bf56d77ccedea6506dec 100644 (file)
@@ -16,7 +16,7 @@
 
 /* Written by Bruno Haible <bruno@clisp.org>, 2018.  */
 
-#if HAVE_USELOCALE && HAVE_NAMELESS_LOCALES /* Solaris >= 11.4 */
+#if HAVE_USELOCALE && HAVE_NAMELESS_LOCALES
 
 # include <stddef.h>
 # include <locale.h>
index 04e6d42b34ac5ce583a62480b965243f68b5d202..ac0354c07d712931d548043a7596ac00b26dc963 100644 (file)
 # if !defined IN_LIBINTL
 #  include "glthread/lock.h"
 # endif
-# if defined __sun && HAVE_GETLOCALENAME_L
+# if defined __sun
+#  if HAVE_GETLOCALENAME_L
 /* Solaris >= 12.  */
 extern char * getlocalename_l(int, locale_t);
+#  elif HAVE_SOLARIS114_LOCALES
+#   include <sys/localedef.h>
+#  endif
 # endif
 # if HAVE_NAMELESS_LOCALES
 #  include <errno.h>
@@ -2704,7 +2708,7 @@ struniq (const char *string)
 #endif
 
 
-#if HAVE_USELOCALE && HAVE_NAMELESS_LOCALES /* Solaris >= 11.4 */
+#if HAVE_USELOCALE && HAVE_NAMELESS_LOCALES
 
 /* The 'locale_t' object does not contain the names of the locale categories.
    We have to associate them with the object through a hash table.
@@ -3145,6 +3149,22 @@ gl_locale_name_thread_unsafe (int category, const char *categoryname)
 #   if HAVE_GETLOCALENAME_L
         /* Solaris >= 12.  */
         return getlocalename_l (category, thread_locale);
+#   elif HAVE_SOLARIS114_LOCALES
+        /* Solaris >= 11.4.  */
+        void *lcp = (*thread_locale)->core.data->lcp;
+        if (lcp != NULL)
+          switch (category)
+            {
+            case LC_CTYPE:
+            case LC_NUMERIC:
+            case LC_TIME:
+            case LC_COLLATE:
+            case LC_MONETARY:
+            case LC_MESSAGES:
+              return ((const char * const *) lcp)[category];
+            default: /* We shouldn't get here.  */
+              return "";
+            }
 #   elif HAVE_NAMELESS_LOCALES
         return get_locale_t_name (category, thread_locale);
 #   else
index bbb4e66267a94e6fd0d433b39578d7d5a63c8d7d..24372859512db6b9c6e223d1ccc71dc02abbae5f 100644 (file)
@@ -13,9 +13,9 @@ glibc21.m4 \
 iconv.m4 \
 intdiv0.m4 \
 intl.m4 \
+intl-thread-locale.m4 \
 intldir.m4 \
 intlmacosx.m4 \
-intlsolaris.m4 \
 intmax.m4 \
 inttypes-pri.m4 \
 inttypes_h.m4 \
similarity index 67%
rename from gettext-runtime/m4/intlsolaris.m4
rename to gettext-runtime/m4/intl-thread-locale.m4
index 6d3ade465ddbd8957aca0f691d225ced57682ecf..6f5ea24d7bbebbcbe7f7b040687e7e8998b19b55 100644 (file)
@@ -1,4 +1,4 @@
-# intlsolaris.m4 serial 2
+# intl-thread-locale.m4 serial 1
 dnl Copyright (C) 2015-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -13,9 +13,9 @@ dnl by the GNU Library General Public License, and the rest of the GNU
 dnl gettext package is covered by the GNU General Public License.
 dnl They are *not* in the public domain.
 
-dnl Checks for special localename support needed on Solaris.
+dnl Check how to retrieve the name of a per-thread locale (POSIX locale_t).
 dnl Sets gt_nameless_locales.
-AC_DEFUN([gt_INTL_SOLARIS],
+AC_DEFUN([gt_INTL_THREAD_LOCALE_NAME],
 [
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
 
@@ -24,7 +24,6 @@ AC_DEFUN([gt_INTL_SOLARIS],
 
   AC_CHECK_FUNCS_ONCE([uselocale])
 
-  gt_nameless_locales=no
   if test $ac_cv_func_uselocale = yes; then
     AC_CACHE_CHECK([for Solaris 11.4 locale system],
       [gt_cv_locale_solaris114],
@@ -33,6 +32,9 @@ AC_DEFUN([gt_INTL_SOLARIS],
            dnl Test whether <locale.h> defines locale_t as a typedef of
            dnl 'struct _LC_locale_t **' (whereas Illumos defines it as a
            dnl typedef of 'struct _locale *').
+           dnl Another possible test would be to include <sys/localedef.h>
+           dnl and test whether it defines the _LC_core_data_locale_t type.
+           dnl This type was added in Solaris 11.4.
            AC_COMPILE_IFELSE(
              [AC_LANG_PROGRAM([[
                 #include <locale.h>
@@ -49,17 +51,27 @@ AC_DEFUN([gt_INTL_SOLARIS],
   fi
   if test $gt_cv_locale_solaris114 = yes; then
     gt_nameless_locales=yes
-    AC_DEFINE([HAVE_NAMELESS_LOCALES], [1],
-      [Define if the locale_t type does not contain the name of each locale category.])
+    AC_DEFINE([HAVE_SOLARIS114_LOCALES], [1],
+      [Define if the locale_t type is as on Solaris 11.4.])
   fi
 
   dnl Solaris 12 will maybe provide getlocalename_l.  If it does, it will
-  dnl simplify the implementation of gl_locale_name_thread().  But the overrides
-  dnl of newlocale, duplocale, freelocale will still be necessary, in order to
-  dnl keep the libintl_locale_hash_table up-to-date, which may be used by
-  dnl libintl or gnulib code that was compiled on Solaris 11.4, before
-  dnl getlocalename_l was introduced.
+  dnl improve the implementation of gl_locale_name_thread(), by removing
+  dnl the use of undocumented structures.
   if test $ac_cv_func_uselocale = yes; then
     AC_CHECK_FUNCS([getlocalename_l])
   fi
+
+  dnl This code is for future use, in case we some day have to port to a
+  dnl platform where the locale_t type does not provide access to the name of
+  dnl each locale category.  This code has the drawback that it requires the
+  dnl gnulib overrides of 'newlocale', 'duplocale', 'freelocale', which is a
+  dnl problem for GNU libunistring.  Therefore try hard to avoid enabling this
+  dnl code!
+  gt_nameless_locales=no
+  if false; then
+    gt_nameless_locales=yes
+    AC_DEFINE([HAVE_NAMELESS_LOCALES], [1],
+      [Define if the locale_t type does not contain the name of each locale category.])
+  fi
 ])
index 7efc7e8552767d93660cacb09f23e02ac39f7c3d..78c8ce5b000051e17878eebc29a7b77e7ffb2406 100644 (file)
@@ -1,4 +1,4 @@
-# intl.m4 serial 33 (gettext-0.19.9)
+# intl.m4 serial 34 (gettext-0.19.9)
 dnl Copyright (C) 1995-2014, 2016-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -40,6 +40,7 @@ AC_DEFUN([AM_INTL_SUBDIR],
   AC_REQUIRE([gl_GLIBC21])dnl
   AC_REQUIRE([gl_XSIZE])dnl
   AC_REQUIRE([gl_FCNTL_O_FLAGS])dnl
+  AC_REQUIRE([gt_INTL_THREAD_LOCALE_NAME])
   AC_REQUIRE([gt_INTL_MACOSX])dnl
   AC_REQUIRE([gl_EXTERN_INLINE])dnl
   AC_REQUIRE([gt_GL_ATTRIBUTE])dnl
@@ -74,7 +75,7 @@ AC_DEFUN([AM_INTL_SUBDIR],
     ])
   AC_CHECK_HEADERS([features.h stddef.h stdlib.h string.h])
   AC_CHECK_FUNCS([asprintf fwprintf newlocale putenv setenv setlocale \
-    snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
+    snprintf strnlen uselocale wcslen wcsnlen mbrtowc wcrtomb])
 
   dnl Use the _snprintf function only if it is declared (because on NetBSD it
   dnl is defined as a weak alias of snprintf; we prefer to use the latter).
@@ -119,6 +120,13 @@ AC_DEFUN([AM_INTL_SUBDIR],
   AM_LANGINFO_CODESET
   gt_LC_MESSAGES
 
+  if test $gt_nameless_locales = yes; then
+    HAVE_NAMELESS_LOCALES=1
+  else
+    HAVE_NAMELESS_LOCALES=0
+  fi
+  AC_SUBST([HAVE_NAMELESS_LOCALES])
+
   dnl Compilation on mingw and Cygwin needs special Makefile rules, because
   dnl 1. when we install a shared library, we must arrange to export
   dnl    auxiliary pointer variables for every exported variable,
@@ -235,15 +243,6 @@ AC_DEFUN([gt_INTL_SUBDIR_CORE],
     stpcpy strcasecmp strdup strtoul tsearch argz_count argz_stringify \
     argz_next __fsetlocking])
 
-  dnl For Solaris 11.4 and 12.
-  gt_INTL_SOLARIS
-  if test $gt_nameless_locales = yes; then
-    HAVE_NAMELESS_LOCALES=1
-  else
-    HAVE_NAMELESS_LOCALES=0
-  fi
-  AC_SUBST([HAVE_NAMELESS_LOCALES])
-
   dnl Use the *_unlocked functions only if they are declared.
   dnl (because some of them were defined without being declared in Solaris
   dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
index 54a870b18cf456c4283514d7d0bad1192b89ef13..1859db7519d66f04afc65bc58b7e8cbda9f3d2f6 100644 (file)
@@ -8043,7 +8043,7 @@ If you do not have an @file{aclocal.m4} file in your distribution,
 the simplest is to concatenate the files @file{codeset.m4}, @file{fcntl-o.m4},
 @file{gettext.m4}, @file{glibc2.m4}, @file{glibc21.m4}, @file{iconv.m4},
 @file{intdiv0.m4}, @file{intl.m4}, @file{intldir.m4}, @file{intlmacosx.m4},
-@file{intlsolaris.m4}, @file{intmax.m4}, @file{inttypes_h.m4},
+@file{intl-thread-locale.m4}, @file{intmax.m4}, @file{inttypes_h.m4},
 @file{inttypes-pri.m4}, @file{lcmessage.m4}, @file{lib-ld.m4},
 @file{lib-link.m4}, @file{lib-prefix.m4}, @file{lock.m4}, @file{longlong.m4},
 @file{nls.m4}, @file{po.m4}, @file{printf-posix.m4}, @file{progtest.m4},
index 3a5d9e993cc38a28b9e66d7de8c345b265e7c0c4..0d34b8de8b0b0654aa9207a6eecc47e6b08d15af 100644 (file)
@@ -16,9 +16,9 @@ aclocal_DATA = \
   ../../gettext-runtime/m4/iconv.m4 \
   ../../gettext-runtime/m4/intdiv0.m4 \
   ../../gettext-runtime/m4/intl.m4 \
+  ../../gettext-runtime/m4/intl-thread-locale.m4 \
   ../../gettext-runtime/m4/intldir.m4 \
   ../../gettext-runtime/m4/intlmacosx.m4 \
-  ../../gettext-runtime/m4/intlsolaris.m4 \
   ../../gettext-runtime/m4/intmax.m4 \
   ../../gettext-runtime/m4/inttypes_h.m4 \
   ../../gettext-runtime/m4/inttypes-pri.m4 \
index b2e8127dd1c4b17888ba1d566705e4395c217cde..c1086284e8ddd015dc7d411c53a148405f11eb73 100644 (file)
@@ -846,8 +846,8 @@ if test -n "$intldir" || test -z "$have_automake19"; then
     glibc21.m4
     intdiv0.m4
     intl.m4
+    intl-thread-locale.m4
     intldir.m4
-    intlsolaris.m4
     intmax.m4
     inttypes_h.m4
     inttypes-pri.m4