From: Bruno Haible Date: Mon, 18 Nov 2019 00:17:49 +0000 (+0100) Subject: locale, localename: Improve z/OS support. X-Git-Tag: v1.0~4601 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=a2342a9b531d5c603da86335636fd86789e56f61;p=gnulib.git locale, localename: Improve z/OS support. Reported by Daniel Richard G. in . * 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. --- diff --git a/ChangeLog b/ChangeLog index 2c5b818c65..7f1c8ddde6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2019-11-17 Bruno Haible + + locale, localename: Improve z/OS support. + Reported by Daniel Richard G. in + . + * 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 havelib: Make libdirstems processing more flexible. diff --git a/m4/intl-thread-locale.m4 b/m4/intl-thread-locale.m4 index 3ecba86aff..e43f602dae 100644 --- a/m4/intl-thread-locale.m4 +++ b/m4/intl-thread-locale.m4 @@ -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 to define 'locale_t'. + dnl Persuade glibc and Solaris 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 #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 ]) ]) diff --git a/m4/locale_h.m4 b/m4/locale_h.m4 index d28ba0c2df..380e40b00e 100644 --- a/m4/locale_h.m4 +++ b/m4/locale_h.m4 @@ -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 is replaced, then 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 . - 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 , - dnl e.g. on Mac OS X 10.5. If does not define locale_t by - dnl itself, we assume that 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_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 to define locale_t. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + dnl Check whether use of locale_t requires inclusion of , + dnl e.g. on Mac OS X 10.5. If does not define locale_t by + dnl itself, we assume that 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_t x;]], + [[]])], + [gl_cv_header_locale_has_locale_t=yes], + [gl_cv_header_locale_has_locale_t=no]) + ]) + + dnl Check for . + 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. diff --git a/m4/localename.m4 b/m4/localename.m4 index a9f629dd17..8e8d249c1c 100644 --- a/m4/localename.m4 +++ b/m4/localename.m4 @@ -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