+2024-02-15 Bruno Haible <bruno@clisp.org>
+
+ localename: Speed up lookup of the LC_MESSAGES name on AIX ≥ 7.2.
+ * m4/intl-thread-locale.m4 (gt_INTL_THREAD_LOCALE_NAME): On AIX, test
+ for the 'locale_name' member.
+ * lib/localename.c (get_locale_t_name): For the LC_MESSAGES category,
+ use the 'locale_name' member if available.
+
2024-02-15 Bruno Haible <bruno@clisp.org>
localename: Add more comments.
/* Determine name of the currently selected locale.
Copyright (C) 1995-2024 Free Software Foundation, Inc.
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
+ This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
}
else
{
+# if HAVE_AIX72_LOCALES
+ if (category == LC_MESSAGES)
+ {
+ const char *name = ((__locale_t) locale)->locale_name;
+ if (name != NULL)
+ return struniq (name);
+ }
+# endif
/* Look up the names in the hash table. */
size_t hashcode = locale_hash_function (locale);
size_t slot = hashcode % LOCALE_HASH_TABLE_SIZE;
-# intl-thread-locale.m4 serial 11
+# intl-thread-locale.m4 serial 12
dnl Copyright (C) 2015-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl requires the gnulib overrides of 'newlocale', 'duplocale', 'freelocale',
dnl which is a problem for GNU libunistring. Therefore try hard to avoid
dnl enabling this code!
- dnl Expected result: HAVE_NAMELESS_LOCALES is defined on AIX.
+ dnl Expected result: HAVE_NAMELESS_LOCALES is defined on AIX,
+ dnl and HAVE_AIX72_LOCALES is defined on AIX ≥ 7.2.
gt_nameless_locales=no
case "$host_os" in
dnl It's needed on AIX 7.2.
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.])
+ dnl In AIX ≥ 7.2, a locale contains at least the name of the LC_MESSSAGES
+ dnl category (fix of defect 823926).
+ AC_CACHE_CHECK([for AIX locales with LC_MESSAGES name],
+ [gt_cv_locale_aix72],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[
+ #include <locale.h>
+ /* Include <sys/localedef.h>, which defines __locale_t. */
+ #include <stdlib.h>
+ locale_t x;
+ ]],
+ [[return ((__locale_t) x)->locale_name[0];]])],
+ [gt_cv_locale_aix72=yes],
+ [gt_cv_locale_aix72=no])
+ ])
+ if test $gt_cv_locale_aix72 = yes; then
+ AC_DEFINE([HAVE_AIX72_LOCALES], [1],
+ [Define if the __locale_t type contains the name of the LC_MESSAGES category.])
+ fi
;;
esac
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.])
+ [Define if the uselocale function exists, may be safely called, and returns sufficient information.])
else
gt_good_uselocale=no
fi