]> Savannah Git Hosting - gnulib.git/commitdiff
locale, localename: Improve z/OS support.
authorBruno Haible <bruno@clisp.org>
Mon, 18 Nov 2019 00:17:49 +0000 (01:17 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 18 Nov 2019 00:17:49 +0000 (01:17 +0100)
Reported by Daniel Richard G. in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00001.html>.

* m4/locale_h.m4 (gl_LOCALE_T): New macro, partially extracted from
gl_LOCALE_H.
(gl_LOCALE_H): Require it.
* m4/localename.m4 (gl_LOCALENAME): Likewise. If locale_t is not
defined, don't even check for newlocale, duplocale, freelocale.
* m4/intl-thread-locale.m4 (gt_FUNC_USELOCALE): Make the test fail when
locale_t is not defined.

ChangeLog
m4/intl-thread-locale.m4
m4/locale_h.m4
m4/localename.m4

index 2c5b818c65f50d538d0fcc3f7bfa78231d5c323d..7f1c8ddde6dd641decb2522d0eef5a53e2834573 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2019-11-17  Bruno Haible  <bruno@clisp.org>
+
+       locale, localename: Improve z/OS support.
+       Reported by Daniel Richard G. in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00001.html>.
+       * m4/locale_h.m4 (gl_LOCALE_T): New macro, partially extracted from
+       gl_LOCALE_H.
+       (gl_LOCALE_H): Require it.
+       * m4/localename.m4 (gl_LOCALENAME): Likewise. If locale_t is not
+       defined, don't even check for newlocale, duplocale, freelocale.
+       * m4/intl-thread-locale.m4 (gt_FUNC_USELOCALE): Make the test fail when
+       locale_t is not defined.
+
 2019-11-17  Bruno Haible  <bruno@clisp.org>
 
        havelib: Make libdirstems processing more flexible.
index 3ecba86aff780f712b6cf55f7d0d9650068b1e0f..e43f602dae1693cb8e41a9d40e612cce0baecd50 100644 (file)
@@ -1,4 +1,4 @@
-# intl-thread-locale.m4 serial 4
+# intl-thread-locale.m4 serial 5
 dnl Copyright (C) 2015-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,
@@ -139,13 +139,15 @@ AC_DEFUN([gt_FUNC_USELOCALE],
 [
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
 
-  dnl Persuade Solaris <locale.h> to define 'locale_t'.
+  dnl Persuade glibc and Solaris <locale.h> to define 'locale_t'.
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
   AC_CHECK_FUNCS_ONCE([uselocale])
 
   dnl On AIX 7.2, the uselocale() function is not documented and leads to
   dnl crashes in subsequent setlocale() invocations.
+  dnl In 2019, some versions of z/OS lack the locale_t type and have a broken
+  dnl uselocale function.
   if test $ac_cv_func_uselocale = yes; then
     AC_CHECK_HEADERS_ONCE([xlocale.h])
     AC_CACHE_CHECK([whether uselocale works],
@@ -156,6 +158,7 @@ AC_DEFUN([gt_FUNC_USELOCALE],
 #if HAVE_XLOCALE_H
 # include <xlocale.h>
 #endif
+locale_t loc1;
 int main ()
 {
   uselocale (NULL);
@@ -164,10 +167,10 @@ int main ()
 }]])],
          [gt_cv_func_uselocale_works=yes],
          [gt_cv_func_uselocale_works=no],
-         [# Guess no on AIX, yes otherwise.
+         [# Guess no on AIX and z/OS, yes otherwise.
           case "$host_os" in
-            aix*) gt_cv_func_uselocale_works="guessing no" ;;
-            *)    gt_cv_func_uselocale_works="guessing yes" ;;
+            aix* | mvs*) gt_cv_func_uselocale_works="guessing no" ;;
+            *)           gt_cv_func_uselocale_works="guessing yes" ;;
           esac
          ])
       ])
index d28ba0c2df59739204f1d84bcd2302846b267ab4..380e40b00e3ba7393f6b6872efa577f71d3d56a6 100644 (file)
@@ -1,4 +1,4 @@
-# locale_h.m4 serial 21
+# locale_h.m4 serial 22
 dnl Copyright (C) 2007, 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,6 +17,8 @@ AC_DEFUN([gl_LOCALE_H],
   dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
   AC_REQUIRE([gl_STDDEF_H])
 
+  AC_REQUIRE([gl_LOCALE_T])
+
   dnl Solaris 11.0 defines the int_p_*, int_n_* members of 'struct lconv'
   dnl only if _LCONV_C99 is defined.
   AC_REQUIRE([AC_CANONICAL_HOST])
@@ -37,34 +39,6 @@ AC_DEFUN([gl_LOCALE_H],
        [gl_cv_header_locale_h_posix2001=yes],
        [gl_cv_header_locale_h_posix2001=no])])
 
-  dnl Check for <xlocale.h>.
-  AC_CHECK_HEADERS_ONCE([xlocale.h])
-  if test $ac_cv_header_xlocale_h = yes; then
-    HAVE_XLOCALE_H=1
-    dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
-    dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
-    dnl itself, we assume that <xlocale.h> will do so.
-    AC_CACHE_CHECK([whether locale.h defines locale_t],
-      [gl_cv_header_locale_has_locale_t],
-      [AC_COMPILE_IFELSE(
-         [AC_LANG_PROGRAM(
-            [[#include <locale.h>
-              locale_t x;]],
-            [[]])],
-         [gl_cv_header_locale_has_locale_t=yes],
-         [gl_cv_header_locale_has_locale_t=no])
-      ])
-    if test $gl_cv_header_locale_has_locale_t = yes; then
-      gl_cv_header_locale_h_needs_xlocale_h=no
-    else
-      gl_cv_header_locale_h_needs_xlocale_h=yes
-    fi
-  else
-    HAVE_XLOCALE_H=0
-    gl_cv_header_locale_h_needs_xlocale_h=no
-  fi
-  AC_SUBST([HAVE_XLOCALE_H])
-
   dnl Check whether 'struct lconv' is complete.
   dnl Bionic libc's 'struct lconv' is just a dummy.
   dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x,
@@ -99,6 +73,49 @@ AC_DEFUN([gl_LOCALE_H],
     [setlocale newlocale duplocale freelocale])
 ])
 
+dnl Checks to determine whether the system has the locale_t type,
+dnl and how to obtain it.
+AC_DEFUN([gl_LOCALE_T],
+[
+  dnl Persuade glibc and Solaris <locale.h> to define locale_t.
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+  dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
+  dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
+  dnl itself, we assume that <xlocale.h> will do so.
+  AC_CACHE_CHECK([whether locale.h defines locale_t],
+    [gl_cv_header_locale_has_locale_t],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <locale.h>
+            locale_t x;]],
+          [[]])],
+       [gl_cv_header_locale_has_locale_t=yes],
+       [gl_cv_header_locale_has_locale_t=no])
+    ])
+
+  dnl Check for <xlocale.h>.
+  AC_CHECK_HEADERS_ONCE([xlocale.h])
+  if test $ac_cv_header_xlocale_h = yes; then
+    HAVE_XLOCALE_H=1
+    if test $gl_cv_header_locale_has_locale_t = yes; then
+      gl_cv_header_locale_h_needs_xlocale_h=no
+    else
+      gl_cv_header_locale_h_needs_xlocale_h=yes
+    fi
+    HAVE_LOCALE_T=1
+  else
+    HAVE_XLOCALE_H=0
+    gl_cv_header_locale_h_needs_xlocale_h=no
+    if test $gl_cv_header_locale_has_locale_t = yes; then
+      HAVE_LOCALE_T=1
+    else
+      HAVE_LOCALE_T=0
+    fi
+  fi
+  AC_SUBST([HAVE_XLOCALE_H])
+])
+
 AC_DEFUN([gl_LOCALE_MODULE_INDICATOR],
 [
   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
index a9f629dd17762850a4032ee3171d02623c598087..8e8d249c1c11ee167aa029032ea422494f702e74 100644 (file)
@@ -1,4 +1,4 @@
-# localename.m4 serial 6
+# localename.m4 serial 7
 dnl Copyright (C) 2007, 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,
@@ -7,11 +7,20 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_LOCALENAME],
 [
   AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
+  AC_REQUIRE([gl_LOCALE_T])
   AC_REQUIRE([gt_LC_MESSAGES])
   AC_REQUIRE([gt_INTL_THREAD_LOCALE_NAME])
   AC_REQUIRE([gt_INTL_MACOSX])
   AC_CHECK_HEADERS_ONCE([langinfo.h])
-  AC_CHECK_FUNCS_ONCE([newlocale duplocale freelocale])
+  if test $HAVE_LOCALE_T = 1; then
+    AC_CHECK_FUNCS_ONCE([newlocale duplocale freelocale])
+  else
+    dnl In 2019, some versions of z/OS lack the locale_t type and have broken
+    dnl newlocale, duplocale, freelocale functions.
+    ac_cv_func_newlocale=no
+    ac_cv_func_duplocale=no
+    ac_cv_func_freelocale=no
+  fi
   if test $ac_cv_func_newlocale != yes; then
     HAVE_NEWLOCALE=0
   fi