From 6047713aff39dc8a9f94952ecf3b136223605eec Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 7 Jan 2021 22:55:41 +0100 Subject: [PATCH] localename: Fix link error with duplocale on AIX 7.2 (regr. 2019-12-18). * m4/locale_h.m4 (gl_LOCALE_H_DEFAULTS): Initialize LOCALENAME_ENHANCE_LOCALE_FUNCS. * m4/intl-thread-locale.m4 (gt_FUNC_USELOCALE): Set gt_working_uselocale. (gt_INTL_THREAD_LOCALE_NAME): Set gt_fake_locales, gt_good_uselocale, gt_localename_enhances_locale_funcs, LOCALENAME_ENHANCE_LOCALE_FUNCS. Define HAVE_GOOD_USELOCALE, LOCALENAME_ENHANCE_LOCALE_FUNCS. * m4/localename.m4 (gl_LOCALENAME): Test gt_localename_enhances_locale_funcs instead of gt_nameless_locales. * modules/locale (Makefile.am): Substitute LOCALENAME_ENHANCE_LOCALE_FUNCS. * lib/locale.in.h (newlocale, duplocale, freelocale): Don't override if module 'localename' is in use but LOCALENAME_ENHANCE_LOCALE_FUNCS is 0. * lib/localename.c (HAVE_GOOD_USELOCALE): Don't define here. (get_locale_t_name, newlocale, duplocale, freelocale): Define if LOCALENAME_ENHANCE_LOCALE_FUNCS. --- ChangeLog | 20 ++++++++++++++++++++ lib/locale.in.h | 6 +++--- lib/localename.c | 8 +------- m4/intl-thread-locale.m4 | 37 ++++++++++++++++++++++++++++++++++--- m4/locale_h.m4 | 3 ++- m4/localename.m4 | 4 ++-- modules/locale | 1 + 7 files changed, 63 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0831c85e1c..3eab13d228 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2021-01-07 Bruno Haible + + localename: Fix link error with duplocale on AIX 7.2 (regr. 2019-12-18). + * m4/locale_h.m4 (gl_LOCALE_H_DEFAULTS): Initialize + LOCALENAME_ENHANCE_LOCALE_FUNCS. + * m4/intl-thread-locale.m4 (gt_FUNC_USELOCALE): + Set gt_working_uselocale. + (gt_INTL_THREAD_LOCALE_NAME): Set gt_fake_locales, gt_good_uselocale, + gt_localename_enhances_locale_funcs, LOCALENAME_ENHANCE_LOCALE_FUNCS. + Define HAVE_GOOD_USELOCALE, LOCALENAME_ENHANCE_LOCALE_FUNCS. + * m4/localename.m4 (gl_LOCALENAME): Test + gt_localename_enhances_locale_funcs instead of gt_nameless_locales. + * modules/locale (Makefile.am): Substitute + LOCALENAME_ENHANCE_LOCALE_FUNCS. + * lib/locale.in.h (newlocale, duplocale, freelocale): Don't override if + module 'localename' is in use but LOCALENAME_ENHANCE_LOCALE_FUNCS is 0. + * lib/localename.c (HAVE_GOOD_USELOCALE): Don't define here. + (get_locale_t_name, newlocale, duplocale, freelocale): Define if + LOCALENAME_ENHANCE_LOCALE_FUNCS. + 2021-01-06 Bruno Haible logb: Fix test failure on glibc/powerpc. diff --git a/lib/locale.in.h b/lib/locale.in.h index df8474798c..13d1cf2fe9 100644 --- a/lib/locale.in.h +++ b/lib/locale.in.h @@ -211,7 +211,7 @@ _GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - " # include "setlocale_null.h" #endif -#if /*@GNULIB_NEWLOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @HAVE_NEWLOCALE@) +#if /*@GNULIB_NEWLOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_NEWLOCALE@) # if @REPLACE_NEWLOCALE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef newlocale @@ -244,7 +244,7 @@ _GL_WARN_ON_USE (newlocale, "newlocale is not portable"); # endif #endif -#if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME@ && @HAVE_DUPLOCALE@) +#if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_DUPLOCALE@) # if @REPLACE_DUPLOCALE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef duplocale @@ -274,7 +274,7 @@ _GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - " # endif #endif -#if /*@GNULIB_FREELOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @HAVE_FREELOCALE@) +#if /*@GNULIB_FREELOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_FREELOCALE@) # if @REPLACE_FREELOCALE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef freelocale diff --git a/lib/localename.c b/lib/localename.c index 4c785f11f0..0e63da4d4b 100644 --- a/lib/localename.c +++ b/lib/localename.c @@ -38,12 +38,6 @@ #include "setlocale_null.h" #include "thread-optim.h" -/* We cannot support uselocale() on platforms where the locale_t type is fake. - See intl-thread-locale.m4 for details. */ -#if HAVE_WORKING_USELOCALE && !HAVE_FAKE_LOCALES -# define HAVE_GOOD_USELOCALE 1 -#endif - #if HAVE_GOOD_USELOCALE /* Mac OS X 10.5 defines the locale_t type in . */ # if defined __APPLE__ && defined __MACH__ @@ -2726,7 +2720,7 @@ struniq (const char *string) #endif -#if HAVE_GOOD_USELOCALE && HAVE_NAMELESS_LOCALES +#if LOCALENAME_ENHANCE_LOCALE_FUNCS /* 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. diff --git a/m4/intl-thread-locale.m4 b/m4/intl-thread-locale.m4 index 65ac371cd0..890fec00ef 100644 --- a/m4/intl-thread-locale.m4 +++ b/m4/intl-thread-locale.m4 @@ -1,4 +1,4 @@ -# intl-thread-locale.m4 serial 8 +# intl-thread-locale.m4 serial 9 dnl Copyright (C) 2015-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -72,9 +72,13 @@ int main () esac case "$gt_cv_locale_fake" in *yes) + gt_fake_locales=yes AC_DEFINE([HAVE_FAKE_LOCALES], [1], [Define if the locale_t type contains insufficient information, as on OpenBSD.]) ;; + *) + gt_fake_locales=no + ;; esac case "$gt_cv_func_uselocale_works" in @@ -133,10 +137,33 @@ int main () [Define if the locale_t type does not contain the name of each locale category.]) ;; esac + + dnl We cannot support uselocale() on platforms where the locale_t type is + dnl fake. So, set + dnl gt_good_uselocale = gt_working_uselocale && !gt_fake_locales. + if test $gt_working_uselocale = yes && test $gt_fake_locales = no; then + gt_good_uselocale=yes + AC_DEFINE([HAVE_GOOD_USELOCALE], [1], + [Define if the uselocale exists, may be safely called, and returns sufficient information.]) + else + gt_good_uselocale=no + fi + + dnl Set gt_localename_enhances_locale_funcs to indicate whether localename.c + dnl overrides newlocale(), duplocale(), freelocale() to keep track of locale + dnl names. + if test $gt_good_uselocale = yes && test $gt_nameless_locales = yes; then + gt_localename_enhances_locale_funcs=yes + LOCALENAME_ENHANCE_LOCALE_FUNCS=1 + AC_DEFINE([LOCALENAME_ENHANCE_LOCALE_FUNCS], [1], + [Define if localename.c overrides newlocale(), duplocale(), freelocale().]) + else + gt_localename_enhances_locale_funcs=no + fi ]) dnl Tests whether uselocale() exists and is usable. -dnl Sets gt_cv_func_uselocale_works. Defines HAVE_WORKING_USELOCALE. +dnl Sets gt_working_uselocale and defines HAVE_WORKING_USELOCALE. AC_DEFUN([gt_FUNC_USELOCALE], [ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles @@ -181,8 +208,12 @@ int main () fi case "$gt_cv_func_uselocale_works" in *yes) + gt_working_uselocale=yes AC_DEFINE([HAVE_WORKING_USELOCALE], [1], - [Define if the uselocale function exists any may safely be called.]) + [Define if the uselocale function exists and may safely be called.]) + ;; + *) + gt_working_uselocale=no ;; esac ]) diff --git a/m4/locale_h.m4 b/m4/locale_h.m4 index a95379a86e..7b50aa7a86 100644 --- a/m4/locale_h.m4 +++ b/m4/locale_h.m4 @@ -1,4 +1,4 @@ -# locale_h.m4 serial 24 +# locale_h.m4 serial 25 dnl Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -155,4 +155,5 @@ AC_DEFUN([gl_LOCALE_H_DEFAULTS], REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE]) REPLACE_FREELOCALE=0; AC_SUBST([REPLACE_FREELOCALE]) REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV]) + LOCALENAME_ENHANCE_LOCALE_FUNCS=0; AC_SUBST([LOCALENAME_ENHANCE_LOCALE_FUNCS]) ]) diff --git a/m4/localename.m4 b/m4/localename.m4 index 5c1ea0e2c5..2bff33d735 100644 --- a/m4/localename.m4 +++ b/m4/localename.m4 @@ -1,4 +1,4 @@ -# localename.m4 serial 7 +# localename.m4 serial 8 dnl Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -33,7 +33,7 @@ AC_DEFUN([gl_LOCALENAME], if test $gl_func_freelocale != yes; then HAVE_FREELOCALE=0 fi - if test $gt_nameless_locales = yes; then + if test $gt_localename_enhances_locale_funcs = yes; then REPLACE_NEWLOCALE=1 REPLACE_DUPLOCALE=1 REPLACE_FREELOCALE=1 diff --git a/modules/locale b/modules/locale index aac463cd67..cd045c3781 100644 --- a/modules/locale +++ b/modules/locale @@ -44,6 +44,7 @@ locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \ -e 's|@''REPLACE_FREELOCALE''@|$(REPLACE_FREELOCALE)|g' \ -e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|g' \ + -e 's|@''LOCALENAME_ENHANCE_LOCALE_FUNCS''@|$(LOCALENAME_ENHANCE_LOCALE_FUNCS)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ -- 2.39.5