]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
intl: Use a locale.alias file only on glibc systems.
authorBruno Haible <bruno@clisp.org>
Wed, 13 Sep 2023 12:03:21 +0000 (14:03 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 13 Sep 2023 12:29:51 +0000 (14:29 +0200)
On systems without glibc, it makes no sense if libintl supports locale name
aliases that the system's setlocale() does not support. Therefore better
disable the locale.alias processing on these platforms.

Also, stop installing locale.alias, because on systems without glibc we won't
read it any more, and on systems with glibc we need to use the preinstalled
one in /usr/share/locale/locale.alias.

* gettext-runtime/intl/localealias.c: Don't include relocatable.h.
(relocate, relocate2): Remove macros.
(LOCALE_ALIAS_PATH): Define a fallback.
(_nl_expand_alias): Simplify on systems without glibc.
(read_alias_file, extend_alias_table, alias_compare): Don't define on systems
without glibc.
* gettext-runtime/intl/Makefile.am (AM_CPPFLAGS): Don't set LOCALE_ALIAS_PATH.
(EXTRA_DIST): Remove locale.alias, ref-add.sin, ref-del.sin.
(MOSTLYCLEANFILES): Remove ref-add.sed, red-del.sed.
(ref-add.sed, ref-del.sed, install-data-aliasfile, installdirs-aliasfile,
uninstall-aliasfile): Remove rules.
* gettext-runtime/intl/locale.alias: Remove file.
* gettext-runtime/intl/ref-add.sin: Remove file.
* gettext-runtime/intl/ref-del.sin: Remove file.
* gettext-tools/src/Makefile.am (aliaspath): Remove variable.
(DEFS): Don't set LOCALE_ALIAS_PATH.
* PACKAGING: Don't mention locale.alias.

PACKAGING
gettext-runtime/intl/Makefile.am
gettext-runtime/intl/locale.alias [deleted file]
gettext-runtime/intl/localealias.c
gettext-runtime/intl/ref-add.sin [deleted file]
gettext-runtime/intl/ref-del.sin [deleted file]
gettext-tools/src/Makefile.am

index 079c76e0936d78c18e469a71f827371e40027d04..162b142eb2711358cc856afd77237fd6f423f520 100644 (file)
--- a/PACKAGING
+++ b/PACKAGING
@@ -74,7 +74,6 @@ is according to the following file list.
       $prefix/share/locale/*/LC_MESSAGES/gettext-runtime.mo
 
       $prefix/lib/libintl.*               (not installed on glibc and Solaris 11 systems)
-      $prefix/share/locale/locale.alias   (not installed on glibc and Solaris 11 systems)
       $prefix/include/libintl.h           (not installed on glibc and Solaris 11 systems)
       $prefix/share/man/man3/*
       $prefix/share/doc/gettext/*.3.html
index 9e56978bc527720fe881fe630126be06c1ca779c..b2e62801543643a8c8d9e2675bee19bfb82fd826 100644 (file)
@@ -35,7 +35,7 @@ SUFFIXES =
 # -DBUILDING_DLL: Change expansion of RELOCATABLE_DLL_EXPORTED macro.
 AM_CPPFLAGS = \
   -Ignulib-lib -I$(srcdir)/gnulib-lib \
-  -DLOCALEDIR=$(localedir_c_make) -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \
+  -DLOCALEDIR=$(localedir_c_make) \
   -DLIBDIR=\"$(libdir)\" -DBUILDING_LIBINTL
 
 if WOE32
@@ -507,57 +507,6 @@ uninstall-preloadable:
 endif
 
 
-# Installation of locale.alias.
-
-EXTRA_DIST += locale.alias ref-add.sin ref-del.sin
-
-if USE_INCLUDED_LIBINTL
-
-all-local: ref-add.sed ref-del.sed
-
-ref-add.sed: $(srcdir)/ref-add.sin
-       sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $(srcdir)/ref-add.sin > t-ref-add.sed
-       mv t-ref-add.sed ref-add.sed
-MOSTLYCLEANFILES += ref-add.sed
-
-ref-del.sed: $(srcdir)/ref-del.sin
-       sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $(srcdir)/ref-del.sin > t-ref-del.sed
-       mv t-ref-del.sed ref-del.sed
-MOSTLYCLEANFILES += ref-del.sed
-
-install-data-local: install-data-aliasfile
-install-data-aliasfile: ref-add.sed
-       $(mkdir_p) $(DESTDIR)$(localedir)
-       test -f $(DESTDIR)$(localedir)/locale.alias \
-         && orig=$(DESTDIR)$(localedir)/locale.alias \
-         || orig=$(srcdir)/locale.alias; \
-       temp=$(DESTDIR)$(localedir)/t-locale.alias; \
-       dest=$(DESTDIR)$(localedir)/locale.alias; \
-       sed -f ref-add.sed $$orig > $$temp; \
-       $(INSTALL_DATA) $$temp $$dest; \
-       rm -f $$temp
-
-installdirs-local: installdirs-aliasfile
-installdirs-aliasfile:
-       $(mkdir_p) $(DESTDIR)$(localedir)
-
-uninstall-local: uninstall-aliasfile
-uninstall-aliasfile: ref-del.sed
-       if test -f $(DESTDIR)$(localedir)/locale.alias; then \
-         temp=$(DESTDIR)$(localedir)/t-locale.alias; \
-         dest=$(DESTDIR)$(localedir)/locale.alias; \
-         sed -f ref-del.sed $$dest > $$temp; \
-         if grep '^# Packages using this file: $$' $$temp > /dev/null; then \
-           rm -f $$dest; \
-         else \
-           $(INSTALL_DATA) $$temp $$dest; \
-         fi; \
-         rm -f $$temp; \
-       fi
-
-endif
-
-
 # Allow users to use "gnulib-tool --update".
 EXTRA_DIST += gnulib-m4/gnulib-cache.m4
 
diff --git a/gettext-runtime/intl/locale.alias b/gettext-runtime/intl/locale.alias
deleted file mode 100644 (file)
index 583c4df..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-# Locale name alias data base.
-# Copyright (C) 1996-2001, 2003, 2007, 2015 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 program 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.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program.  If not, see <https://www.gnu.org/licenses/>.
-
-# The format of this file is the same as for the corresponding file of
-# the X Window System, which normally can be found in
-#      /usr/lib/X11/locale/locale.alias
-# A single line contains two fields: an alias and a substitution value.
-# All entries are case independent.
-
-# Note: This file is obsolete and is kept around for the time being for
-# backward compatibility.  Nobody should rely on the names defined here.
-# Locales should always be specified by their full name.
-
-# Note: This file used to contain the following lines:
-#      bokmaal         nb_NO.ISO-8859-1
-#      franc,ais       fr_FR.ISO-8859-1
-# except that the "aa" was actually the byte '\0xE5' (the Latin-1
-# encoding for U+00E5 LATIN SMALL LETTER A WITH RING ABOVE) and the
-# "c," was actually the byte '\xE7' (the Latin-1 encoding for U+00E7
-# LATIN SMALL LETTER C WITH CEDILLA).  These lines were removed
-# because they caused 'locale -a' to output text encoded in Latin-1,
-# which broke applications in UTF-8 locales.  See:
-# https://sourceware.org/bugzilla/show_bug.cgi?id=18412
-
-# Packages using this file: 
-
-bokmal         nb_NO.ISO-8859-1
-catalan                ca_ES.ISO-8859-1
-croatian       hr_HR.ISO-8859-2
-czech          cs_CZ.ISO-8859-2
-danish          da_DK.ISO-8859-1
-dansk          da_DK.ISO-8859-1
-deutsch                de_DE.ISO-8859-1
-dutch          nl_NL.ISO-8859-1
-eesti          et_EE.ISO-8859-1
-estonian       et_EE.ISO-8859-1
-finnish         fi_FI.ISO-8859-1
-french         fr_FR.ISO-8859-1
-galego         gl_ES.ISO-8859-1
-galician       gl_ES.ISO-8859-1
-german         de_DE.ISO-8859-1
-greek           el_GR.ISO-8859-7
-hebrew          he_IL.ISO-8859-8
-hrvatski       hr_HR.ISO-8859-2
-hungarian       hu_HU.ISO-8859-2
-icelandic       is_IS.ISO-8859-1
-italian         it_IT.ISO-8859-1
-japanese       ja_JP.eucJP
-japanese.euc   ja_JP.eucJP
-ja_JP          ja_JP.eucJP
-ja_JP.ujis     ja_JP.eucJP
-japanese.sjis  ja_JP.SJIS
-korean         ko_KR.eucKR
-korean.euc     ko_KR.eucKR
-ko_KR          ko_KR.eucKR
-lithuanian      lt_LT.ISO-8859-13
-no_NO          nb_NO.ISO-8859-1
-no_NO.ISO-8859-1 nb_NO.ISO-8859-1
-norwegian       nb_NO.ISO-8859-1
-nynorsk                nn_NO.ISO-8859-1
-polish          pl_PL.ISO-8859-2
-portuguese      pt_PT.ISO-8859-1
-romanian        ro_RO.ISO-8859-2
-russian         ru_RU.ISO-8859-5
-slovak          sk_SK.ISO-8859-2
-slovene         sl_SI.ISO-8859-2
-slovenian       sl_SI.ISO-8859-2
-spanish         es_ES.ISO-8859-1
-swedish         sv_SE.ISO-8859-1
-thai           th_TH.TIS-620
-turkish         tr_TR.ISO-8859-9
index 65a803071dabe83e4bcc1dd1eb9901bcec047482..df32388806c37b4797d64016c8a1924405cd4778 100644 (file)
@@ -85,13 +85,6 @@ char *alloca ();
 
 #include "gettextP.h"
 
-#ifdef ENABLE_RELOCATABLE
-# include "relocatable.h"
-#else
-# define relocate(pathname) (pathname)
-# define relocate2(pathname,allocatedp) (*(allocatedp) = NULL, (pathname))
-#endif
-
 /* @@ end of prolog @@ */
 
 #ifdef _LIBC
@@ -148,6 +141,22 @@ char *alloca ();
 #endif
 
 
+/* We do the alias processing only on systems with glibc, because
+     - Its purpose (described above) is to let the user use locale names
+       that are not directly supported by libc, during transition periods.
+     - On systems without glibc, the use of these locale names would be
+       limited to the LC_MESSAGES and LANGUAGE environment variables,
+       because these systems don't use any alias file during setlocale().
+       This makes no sense: It would make the locale handling inconsistent
+       and users would still need to adjust their scripts when a locale
+       name supported by the system has changed.  */
+
+#if defined _LIBC || __GLIBC__ >= 2
+
+# ifndef LOCALE_ALIAS_PATH
+#  define LOCALE_ALIAS_PATH "/usr/share/locale"
+# endif
+
 __libc_lock_define_initialized (static, lock)
 
 
@@ -158,9 +167,9 @@ struct alias_map
 };
 
 
-#ifndef _LIBC
-# define libc_freeres_ptr(decl) decl
-#endif
+# ifndef _LIBC
+#  define libc_freeres_ptr(decl) decl
+# endif
 
 libc_freeres_ptr (static char *string_space);
 static size_t string_space_act;
@@ -177,13 +186,17 @@ static int extend_alias_table (void);
 static int alias_compare (const struct alias_map *map1,
                          const struct alias_map *map2);
 
+#endif
+
 
 const char *
 _nl_expand_alias (const char *name)
 {
+  const char *result = NULL;
+
+#if defined _LIBC || __GLIBC__ >= 2
   static const char *locale_alias_path;
   struct alias_map *retval;
-  const char *result = NULL;
   size_t added;
 
   __libc_lock_lock (lock);
@@ -234,16 +247,19 @@ _nl_expand_alias (const char *name)
   while (added != 0);
 
   __libc_lock_unlock (lock);
+#endif
 
   return result;
 }
 
 
+#if defined _LIBC || __GLIBC__ >= 2
+
 /* Silence a bogus GCC warning.
    <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109990>  */
-#if __GNUC__ >= 12
-# pragma GCC diagnostic ignored "-Wuse-after-free"
-#endif
+# if __GNUC__ >= 12
+#  pragma GCC diagnostic ignored "-Wuse-after-free"
+# endif
 
 static size_t
 internal_function
@@ -251,35 +267,28 @@ read_alias_file (const char *fname, int fname_len)
 {
   FILE *fp;
   char *full_fname;
-  char *malloc_full_fname;
   size_t added;
   static const char aliasfile[] = "/locale.alias";
 
   full_fname = (char *) alloca (fname_len + sizeof aliasfile);
-#ifdef HAVE_MEMPCPY
   mempcpy (mempcpy (full_fname, fname, fname_len),
           aliasfile, sizeof aliasfile);
-#else
-  memcpy (full_fname, fname, fname_len);
-  memcpy (&full_fname[fname_len], aliasfile, sizeof aliasfile);
-#endif
 
-#ifdef _LIBC
+# ifdef _LIBC
   /* Note the file is opened with cancellation in the I/O functions
      disabled.  */
-  fp = fopen (relocate2 (full_fname, &malloc_full_fname), "rce");
-#else
-  fp = fopen (relocate2 (full_fname, &malloc_full_fname), "r");
-#endif
-  free (malloc_full_fname);
+  fp = fopen (full_fname, "rce");
+# else
+  fp = fopen (full_fname, "r");
+# endif
   freea (full_fname);
   if (fp == NULL)
     return 0;
 
-#ifdef HAVE___FSETLOCKING
+# ifdef HAVE___FSETLOCKING
   /* No threads present.  */
   __fsetlocking (fp, FSETLOCKING_BYCALLER);
-#endif
+# endif
 
   added = 0;
   while (!FEOF (fp))
@@ -340,13 +349,13 @@ read_alias_file (const char *fname, int fname_len)
              else if (cp[0] != '\0')
                *cp++ = '\0';
 
-#ifdef IN_LIBGLOCALE
+# ifdef IN_LIBGLOCALE
              /* glibc's locale.alias contains entries for ja_JP and ko_KR
                 that make it impossible to use a Japanese or Korean UTF-8
                 locale under the name "ja_JP" or "ko_KR".  Ignore these
                 entries.  */
              if (strchr (alias, '_') == NULL)
-#endif
+# endif
                {
                  size_t alias_len;
                  size_t value_len;
@@ -445,29 +454,7 @@ extend_alias_table (void)
 static int
 alias_compare (const struct alias_map *map1, const struct alias_map *map2)
 {
-#if defined _LIBC || defined HAVE_STRCASECMP
   return strcasecmp (map1->alias, map2->alias);
-#else
-  const unsigned char *p1 = (const unsigned char *) map1->alias;
-  const unsigned char *p2 = (const unsigned char *) map2->alias;
-  unsigned char c1, c2;
-
-  if (p1 == p2)
-    return 0;
-
-  do
-    {
-      /* I know this seems to be odd but the tolower() function in
-        some systems libc cannot handle nonalpha characters.  */
-      c1 = isupper (*p1) ? tolower (*p1) : *p1;
-      c2 = isupper (*p2) ? tolower (*p2) : *p2;
-      if (c1 == '\0')
-       break;
-      ++p1;
-      ++p2;
-    }
-  while (c1 == c2);
+}
 
-  return c1 - c2;
 #endif
-}
diff --git a/gettext-runtime/intl/ref-add.sin b/gettext-runtime/intl/ref-add.sin
deleted file mode 100644 (file)
index d986cd9..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-# Add this package to a list of references stored in a text file.
-#
-#   Copyright (C) 2000 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 program 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.
-#
-#   You should have received a copy of the GNU Lesser General Public License
-#   along with this program.  If not, see <https://www.gnu.org/licenses/>.
-#
-# Written by Bruno Haible <haible@clisp.cons.org>.
-#
-/^# Packages using this file: / {
-  s/# Packages using this file://
-  ta
-  :a
-  s/ @PACKAGE@ / @PACKAGE@ /
-  tb
-  s/ $/ @PACKAGE@ /
-  :b
-  s/^/# Packages using this file:/
-}
diff --git a/gettext-runtime/intl/ref-del.sin b/gettext-runtime/intl/ref-del.sin
deleted file mode 100644 (file)
index 29aafdf..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-# Remove this package from a list of references stored in a text file.
-#
-#   Copyright (C) 2000 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 program 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.
-#
-#   You should have received a copy of the GNU Lesser General Public License
-#   along with this program.  If not, see <https://www.gnu.org/licenses/>.
-#
-# Written by Bruno Haible <haible@clisp.cons.org>.
-#
-/^# Packages using this file: / {
-  s/# Packages using this file://
-  s/ @PACKAGE@ / /
-  s/^/# Packages using this file:/
-}
index aa5da9c19e292a8ec73dccc84a4c51ae7eef56a9..a537d0cf66de6bad005b1ecacfd588f4aa570a55 100644 (file)
@@ -84,7 +84,6 @@ noinst_HEADERS = \
 
 EXTRA_DIST += FILES project-id
 
-aliaspath = $(localedir)
 jardir = $(datadir)/gettext
 pkgdatadir = $(datadir)/gettext
 projectsdir = $(pkgdatadir)/projects
@@ -99,7 +98,6 @@ AM_CPPFLAGS = \
   -I../../gettext-runtime/intl -I$(top_srcdir)/../gettext-runtime/intl
 DEFS = \
   -DLOCALEDIR=$(localedir_c_make) -DBISON_LOCALEDIR=\"$(BISON_LOCALEDIR)\" \
-  -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \
   -DUSEJAVA=$(USEJAVA) \
   -DGETTEXTJAR=\"$(jardir)/gettext.jar\" \
   -DLIBDIR=\"$(libdir)\" \