]> Savannah Git Hosting - gnulib.git/commitdiff
duplocale: Don't attempt to override if locale_t does not exist.
authorBruno Haible <bruno@clisp.org>
Thu, 12 Dec 2019 12:52:50 +0000 (13:52 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 12 Dec 2019 12:52:50 +0000 (13:52 +0100)
Reported by Daniel Richard G. in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00039.html>.

* m4/duplocale.m4 (gl_FUNC_DUPLOCALE): If locale_t does not exist, set
HAVE_DUPLOCALE to 0.

ChangeLog
m4/duplocale.m4

index 5d1df96cfd2dae45e18aad1d47055efffb7b9267..d5091849410131ee378b7ea7c4dce3d305aeceb8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-12-12  Bruno Haible  <bruno@clisp.org>
+
+       duplocale: Don't attempt to override if locale_t does not exist.
+       Reported by Daniel Richard G. in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00039.html>.
+       * m4/duplocale.m4 (gl_FUNC_DUPLOCALE): If locale_t does not exist, set
+       HAVE_DUPLOCALE to 0.
+
 2019-12-12  Bruno Haible  <bruno@clisp.org>
 
        wcwidth: Avoid test failure on AIX 7.2.
index c2c95dd652607e92ecce9ba2e7b1a1eff10a9300..fb5e602a09687f8dc5dbf5ccc2f193ca9a80022d 100644 (file)
@@ -1,4 +1,4 @@
-# duplocale.m4 serial 10
+# duplocale.m4 serial 11
 dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,11 +17,12 @@ AC_DEFUN([gl_FUNC_DUPLOCALE],
     dnl Also, on NetBSD 7.0, duplocale(LC_GLOBAL_LOCALE) returns a locale that
     dnl corresponds to the C locale.
     AC_REQUIRE([gl_LOCALE_H])
-    AC_CHECK_FUNCS_ONCE([snprintf_l nl_langinfo_l])
-    AC_CACHE_CHECK([whether duplocale(LC_GLOBAL_LOCALE) works],
-      [gl_cv_func_duplocale_works],
-      [AC_RUN_IFELSE(
-         [AC_LANG_SOURCE([[
+    if test $HAVE_LOCALE_T = 1; then
+      AC_CHECK_FUNCS_ONCE([snprintf_l nl_langinfo_l])
+      AC_CACHE_CHECK([whether duplocale(LC_GLOBAL_LOCALE) works],
+        [gl_cv_func_duplocale_works],
+        [AC_RUN_IFELSE(
+           [AC_LANG_SOURCE([[
 #include <locale.h>
 #if HAVE_XLOCALE_H
 # include <xlocale.h>
@@ -72,13 +73,13 @@ int main ()
   freelocale (loc);
   return 0;
 }]])],
-         [gl_cv_func_duplocale_works=yes],
-         [gl_cv_func_duplocale_works=no],
-         [dnl Guess it works except on glibc < 2.12, uClibc, AIX, and NetBSD.
-          case "$host_os" in
-            aix* | netbsd*) gl_cv_func_duplocale_works="guessing no";;
-            *-gnu* | gnu*)
-              AC_EGREP_CPP([Unlucky], [
+           [gl_cv_func_duplocale_works=yes],
+           [gl_cv_func_duplocale_works=no],
+           [dnl Guess it works except on glibc < 2.12, uClibc, AIX, and NetBSD.
+            case "$host_os" in
+              aix* | netbsd*) gl_cv_func_duplocale_works="guessing no";;
+              *-gnu* | gnu*)
+                AC_EGREP_CPP([Unlucky], [
 #include <features.h>
 #ifdef __GNU_LIBRARY__
  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 12)
@@ -88,17 +89,23 @@ int main ()
 #ifdef __UCLIBC__
  Unlucky user
 #endif
-                ],
-                [gl_cv_func_duplocale_works="guessing no"],
-                [gl_cv_func_duplocale_works="guessing yes"])
-              ;;
-            *) gl_cv_func_duplocale_works="guessing yes";;
-          esac
-         ])
-      ])
-    case "$gl_cv_func_duplocale_works" in
-      *no) REPLACE_DUPLOCALE=1 ;;
-    esac
+                  ],
+                  [gl_cv_func_duplocale_works="guessing no"],
+                  [gl_cv_func_duplocale_works="guessing yes"])
+                ;;
+              *) gl_cv_func_duplocale_works="guessing yes";;
+            esac
+           ])
+        ])
+      case "$gl_cv_func_duplocale_works" in
+        *no) REPLACE_DUPLOCALE=1 ;;
+      esac
+    else
+      dnl In 2019, some versions of z/OS lack the locale_t type and have broken
+      dnl newlocale, duplocale, freelocale functions. In this situation, we
+      dnl cannot use nor override duplocale.
+      HAVE_DUPLOCALE=0
+    fi
   else
     HAVE_DUPLOCALE=0
   fi