Bruno Haible [Sat, 30 Sep 2023 18:03:47 +0000 (20:03 +0200)]
intl: Remove use of alloca() for wdirname handling.
* autogen.sh (GNULIB_MODULES_LIBINTL): Add wgetcwd-lgpl.
* gettext-runtime/intl/dcigettext.c: Include <wchar.h>.
(DCIGETTEXT): Allocate resolved_wdirname through malloc() instead of through
alloca().
Bruno Haible [Sat, 30 Sep 2023 13:08:26 +0000 (15:08 +0200)]
intl: Merge from glibc.
Apply commits
2017-06-21 Florian Weimer <fweimer@redhat.com>
DCIGETTEXT: Use getcwd, asprintf to construct absolute pathname
and
2018-12-21 Florian Weimer <fweimer@redhat.com>
intl: Do not return NULL on asprintf failure in gettext [BZ #24018]
Bruno Haible [Wed, 20 Sep 2023 09:03:35 +0000 (11:03 +0200)]
Fix intl-7 test failure on Solaris 11.
* gettext-tools/tests/init.cfg (prepare_locale_): Preserve the existing contents
of "$2".
* gettext-tools/tests/intl-7: While calling prepare_locale_, ensure that fr_FR
has higher priority than fr.
Bruno Haible [Mon, 18 Sep 2023 19:28:25 +0000 (21:28 +0200)]
libgettextpo: Fix compilation error on FreeBSD (regression 2023-09-16).
* gettext-tools/libgettextpo/gettext-po.c (po_file_write, po_error_logger,
po_message_check_format): Use orig_error, orig_error_at_line instead of the
error, error_at_line symbols.
* gettext-tools/src/x-perl.c: Ensure the top-level extract_balanced call returns
when a closing paren or bracket is seen.
(token_type_r_any): New enum item.
(prefer_regexp_over_division, extract_balanced): Handle it.
(extract_perl): Pass token_type_r_any instead of token_type_rbrace.
Bruno Haible [Mon, 18 Sep 2023 18:26:48 +0000 (20:26 +0200)]
xgettext: Perl: Add test against unbounded nesting_depth growth.
Reported by Gavin D. Smith <gavinsmith0123@gmail.com> at
<https://lists.gnu.org/archive/html/bug-gettext/2023-07/msg00008.html>
and <https://savannah.gnu.org/bugs/?64552>.
* gettext-tools/tests/xgettext-perl-stackovfl-5: New file.
* gettext-tools/tests/testdata/xg-pl-so-5.pl: New file, taken from
https://git.savannah.gnu.org/gitweb/?p=texinfo.git;a=blob;f=tp/Texinfo/Convert/HTML.pm;hb=c8d9edd94d9b1a3e675e811208d9e66eaf9a7daa
* gettext-tools/tests/Makefile.am (TESTS): Add xgettext-perl-stackovfl-5.
(EXTRA_DIST): Add testdata/xg-pl-so-5.pl.
Bruno Haible [Mon, 18 Sep 2023 18:04:47 +0000 (20:04 +0200)]
xgettext: Perl: Avoid unbounded nesting_depth growth, part 4.
* gettext-tools/src/x-perl.c: Improve parsing of array dereferences.
(extract_variable): After parsing a braced {variable_name}, increment
varbody_length, so as to not parse the following character. If this character
is a closing parenthesis, is would disturb the enclosing extract_balanced call.
Test case:
==========================================
sub in_multi_expanded($)
{
if (@{$self}) {
}
}
==========================================
Bruno Haible [Mon, 18 Sep 2023 17:26:54 +0000 (19:26 +0200)]
xgettext: Perl: Avoid unbounded nesting_depth growth, part 3.
* gettext-tools/src/x-perl.c: Return from extract_balanced when a subroutine's
definition terminates and that subroutine was defined after a declaration that
ended with a semicolon.
(extract_perl): Pass semicolon_delim=true.
Test case:
==========================================
my %a = 4;
sub b
{
}
==========================================
Bruno Haible [Mon, 18 Sep 2023 17:02:01 +0000 (19:02 +0200)]
xgettext: Perl: Avoid unbounded nesting_depth growth, part 2.
* gettext-tools/src/x-perl.c: Return from extract_balanced when a subroutine's
definition terminates.
(extract_balanced): Test whether the first token is 'sub'. If so, don't use
the usual symbol parsing and return when a token_type_lbrace was seen.
Test cases:
==========================================
sub import {
}
==========================================
sub import {
if (!$module_loaded) {
Texinfo::XSLoader::override("", "");
Texinfo::XSLoader::override("", "");
$module_loaded = 1;
}
goto &Exporter::import;
}
==========================================
Bruno Haible [Mon, 18 Sep 2023 14:18:23 +0000 (16:18 +0200)]
xgettext: Perl: Avoid unbounded nesting_depth growth, part 1.
* gettext-tools/src/x-perl.c: Return from extract_balanced when a semicolon
outside parentheses is seen.
(extract_balanced): Add parameters semicolon_delim, eat_semicolon_delim.
All callers changed.
Test case:
=================
use strict;
=================
Bruno Haible [Sun, 17 Sep 2023 19:11:09 +0000 (21:11 +0200)]
build: Fix "make install" failure on Android.
This patch fixes two problems with "make install" on Android:
1) On this platform, libtool is configured to relink libraries during
"make install".
This leads to a problem during the installation of libgettextsrc: The relink
command that libtool emits has the form
The option -lgettextlib resolves to $(libdir)/libgettextlib.a, not to
$(libdir)/libgettextlib-@VERSION@.so.
Thus the linker attempts to include many object files from libgettextlib.a
into libgettextsrc-@VERSION@.soT, but some of these reference global variables
in a non-PIC way, and the linker thus complains
ld.lld: error: relocation R_ARM_REL32 cannot be used against symbol 'program_name'; recompile with -fPIC
2) The installed executables don't have a RUNPATH property that points to the
directory that contains the shared libraries. Thus these executables don't run.
Reported at <https://savannah.gnu.org/patch/index.php?10393>.
* m4/libtool.m4: On Android, fix library_names_spec and
hardcode_libdir_flag_spec.
Bruno Haible [Sat, 16 Sep 2023 22:18:47 +0000 (00:18 +0200)]
xgettext: Avoid error 'present charset "CHARSET" is not a portable encoding name' when possible.
Reported by Arsen Arsenović <arsen@aarsen.me>
at <https://savannah.gnu.org/bugs/?64490>.
This changes the behaviour back to the one from gettext 0.21.1, where this
xgettext invocation produced just a warning.
* gettext-tools/src/msgl-iconv.c (iconv_message_list_internal): Don't give an
error when a PO file has a header entry with charset=CHARSET and is entirely
ASCII.
* gettext-tools/src/msgl-cat.c (catenate_msgdomain_list): Likewise.
* gettext-tools/tests/xgettext-combine-1: New file.
* gettext-tools/tests/xgettext-combine-2: New file.
* gettext-tools/tests/xgettext-combine-3: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.
Bruno Haible [Sat, 16 Sep 2023 15:49:23 +0000 (17:49 +0200)]
libgettextpo: Fix compilation error on Android.
* gettext-tools/libgettextpo/gettext-po.c: Include error.h second.
(orig_error, orig_error_at_line): New variables.
(error, error_at_line): Undefine afterwards.
(po_file_read_v2): Use these variables instead of the error, error_at_line
symbols.
Bruno Haible [Sat, 16 Sep 2023 10:32:25 +0000 (12:32 +0200)]
Fix a misnomer.
* gettext-runtime/configure.ac: Prefer the term "shared library", since the term
"DLL" applies only to Windows.
* gettext-runtime/intl/configure.ac: Likewise.
* gettext-tools/configure.ac: Likewise.
* gettext-runtime/intl/export.h (LIBINTL_SHLIB_EXPORTED): Renamed from
LIBINTL_DLL_EXPORTED. Prefer the term "shared library", since the term "DLL"
applies only to Windows.
* gettext-runtime/intl/Makefile.am (AM_CPPFLAGS): Update comment.
(libgnuintl.h): Insert LIBINTL_SHLIB_EXPORTED instead of LIBINTL_DLL_EXPORTED.
* gettext-runtime/intl/gettextP.h: Use LIBGLOCALE_SHLIB_EXPORTED instead of
LIBGLOCALE_DLL_EXPORTED. Use LIBINTL_SHLIB_EXPORTED instead of
LIBINTL_DLL_EXPORTED.
* gettext-runtime/intl/loadinfo.h (LIBINTL_SHLIB_EXPORTED): Renamed from
LIBINTL_DLL_EXPORTED.
* gettext-runtime/intl/intl-compat.c (SHLIB_EXPORTED): Renamed from
DLL_EXPORTED. Prefer the term "shared library", since the term "DLL" applies
only to Windows.
* gettext-runtime/intl/printf.c (SHLIB_EXPORTED): Likewise.
* gettext-runtime/intl/setlocale.c (SHLIB_EXPORTED): Likewise.
* gettext-tools/woe32dll/export.h: Update comment.
Bruno Haible [Fri, 15 Sep 2023 21:06:11 +0000 (23:06 +0200)]
intl: Fix list of exported symbols (regression 2021-06-19).
Reported by <fxcoudert@gcc.gnu.org>
and Christian Weisgerber <naddy@mips.inka.de>
in <https://savannah.gnu.org/bugs/?64323>
and <https://lists.gnu.org/archive/html/bug-gettext/2023-07/msg00005.html>.
Analyzed by Christian Weisgerber <naddy@mips.inka.de> and
Tijl Coosemans <tijl@FreeBSD.org>.
* gettext-runtime/intl/Makefile.am (AM_CPPFLAGS): Set BUILDING_DLL.
* gettext-runtime/intl/intl-compat.c: Update comments.
Bruno Haible [Fri, 15 Sep 2023 18:54:32 +0000 (20:54 +0200)]
intl: Fix a build error on Android.
The declaration in Android's <math.h>
long double frexpl(long double, int*) __RENAME_LDBL(frexp, 3, 21);
has the effect that frexpl.o defines the symbol _libintl_frexp, not
_libintl_frexpl, if config.h contains
#define frexp _libintl_frexp
#define frexpl _libintl_frexpl
* gettext-runtime/intl/configure.ac:
If REPLACE_FREXP is 1, don't redirect frexp to _libintl_frexp.
If REPLACE_FREXPL is 1, don't redirect frexpl to _libintl_frexp.
Bruno Haible [Wed, 13 Sep 2023 21:11:52 +0000 (23:11 +0200)]
intl: Don't compile relocatable.c any more.
The library does not need relocatable.h any more since today.
As a side effect, libintl.la gets installed again and "make uninstall" erases
the installed libintl.{a,so} again (regressions from 2021-06-20).
Reported by David Bohman <debohman@gmail.com> at
<https://savannah.gnu.org/bugs/?64536>.
* autogen.sh (GNULIB_MODULES_LIBINTL): Remove relocatable-lib-lgpl.
* gnulib-local/modules/gettext-runtime-intl-misc (Makefile.am): Don't augment
AM_CPPFLAGS.
* gettext-runtime/intl/configure.ac: Don't set enable_relocatable.
Don't define the C symbols relocate, relocate2.
* gettext-runtime/intl/compat.c: New file.
* gettext-runtime/intl/Makefile.am: Update comments.
(LIBINTLSOURCES): Add compat.c.
(compat.lo): New rule.
Bruno Haible [Wed, 13 Sep 2023 12:03:21 +0000 (14:03 +0200)]
intl: Use a locale.alias file only on glibc systems.
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.
Bruno Haible [Sun, 10 Sep 2023 18:33:09 +0000 (20:33 +0200)]
intl: Treat C.UTF-8 locale like C locale.
The wiki page https://sourceware.org/glibc/wiki/Proposals/C.UTF-8
says that "Setting LC_ALL=C.UTF-8 will ignore LANGUAGE just like it
does with LC_ALL=C." This is now implemented in glibc. Implement it
for other platforms as well.
* gettext-runtime/intl/dcigettext.c (DCIGETTEXT, guess_category_value): Treat
C.<encoding> locale like the C locale.
* gettext-runtime/NEWS: Mention it.
* NEWS: Likewise.
* gettext-tools/tests/intl-0: New file, based on gettext-tools/tests/intl-1.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Wed, 6 Sep 2023 19:13:25 +0000 (21:13 +0200)]
Don't export symbols from static object files on Windows.
* gettext-tools/configure.ac (DLL_VARIABLE): Test DLL_EXPORT, not WOE32DLL.
(WOE32DLL): Don't define as a C macro.
* gettext-runtime/configure.ac: Likewise.
(DLL_VARIABLE): Drop special assumption regarding 'exit_failure'.
Bruno Haible [Wed, 6 Sep 2023 18:59:36 +0000 (20:59 +0200)]
libtextstyle: Don't export symbols from static MSVC .obj files.
* libtextstyle/lib/Makefile.am (config.h): Don't alias isatty to
libtextstyle_isatty here, before the Windows header files have been included.
* libtextstyle/gnulib-local/lib/isatty.c.diff: New file.
* libtextstyle/Makefile.am (EXTRA_DIST): Add it.
Bruno Haible [Wed, 6 Sep 2023 18:59:03 +0000 (20:59 +0200)]
intl: Don't export symbols from static MSVC .obj files.
* gettext-runtime/intl/configure.ac (WOE32DLL): Set to 1 or 0, not 'yes' or
'no'. Don't define as C macro any more.
(DLL_VARIABLE): Test DLL_EXPORT, not _DLL.
* gettext-runtime/intl/export.h: Use the value of WOE32DLL at configure time.
Set LIBINTL_DLL_EXPORTED to empty on MSVC when DLL_EXPORT is not defined.
* gettext-runtime/intl/Makefile.am (libgnuintl.h): Substitute the value of
@WOE32DLL@.
* gettext-runtime/intl/intl-compat.c (DLL_EXPORTED): Set to empty on MSVC when
DLL_EXPORT is not defined.
* gettext-runtime/intl/printf.c (DLL_EXPORTED): Likewise.
* gettext-runtime/intl/setlocale.c (DLL_EXPORTED): Likewise.
Bruno Haible [Fri, 14 Jul 2023 16:23:06 +0000 (18:23 +0200)]
msgmerge: Deprecate option '--sort-output'.
Reported by Ben Siemerink <gnu@mail.qoben.com> in
<https://savannah.gnu.org/bugs/?61249>.
* gettext-tools/src/msgmerge.c (main): Warn when option '--sort-output' is used.
(usage): Mark the option '--sort-output' deprecated.
* gettext-tools/doc/msgmerge.texi: Likewise.
* NEWS: Mention it.
Bruno Haible [Mon, 19 Jun 2023 16:33:36 +0000 (18:33 +0200)]
Fix lang-python-* failures when a traditional French locale is present.
This is caused by the new UTF-8 encoded messages in .mo files, together
with a bug in gettext.py from Python 2.7 that prohibits reencoding of the
looked-up messages at run time.
* gettext-tools/tests/lang-python-1: Instead of conditionally skipping the test
in the $LOCALE_FR_UTF8 locale, conditionally skip the test in the $LOCALE_FR
locale.
* gettext-tools/tests/lang-python-2: Likewise.
Bruno Haible [Mon, 19 Jun 2023 11:22:19 +0000 (13:22 +0200)]
build: Remove redundant .m4 file.
* gettext-runtime/m4/intlmacosx.m4: Remove file.
* gettext-runtime/m4/Makefile.am (EXTRA_DIST): Remove it.
* Makefile.am (distcheck-hook): Don't check it.
* gettext-tools/m4/Makefile.am (aclocal_DATA): Take it from the
gettext-runtime/gnulib-m4/ directory.
Bruno Haible [Mon, 19 Jun 2023 10:52:46 +0000 (12:52 +0200)]
build: Remove redundant .m4 file.
* autogen.sh (GNULIB_MODULES_LIBINTL): Add iconv.
* gettext-runtime/m4/iconv.m4: Remove file.
* gettext-runtime/m4/Makefile.am (EXTRA_DIST): Remove it.
* Makefile.am (distcheck-hook): Don't check it.
* gettext-tools/m4/Makefile.am (aclocal_DATA): Take it from the
gettext-runtime/gnulib-m4/ directory.
Bruno Haible [Sun, 18 Jun 2023 13:50:06 +0000 (15:50 +0200)]
build: Install auxiliary programs in $(libexecdir), not $(libdir).
The GNU Coding Standards say that auxiliary programs should be installed in a
subdir of $(libexecdir).
<https://www.gnu.org/prep/standards/html_node/Directory-Variables.html>
Originally, I did not do this because I also wanted to follow the Linux
Filesystem Hierarchy Standard, which in version 2 did not support /usr/libexec.
This has changed in 2015: The FHS version 3 now allows installation into
/usr/libexec.
<https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s07.html>
Reported by Bastien Roucariès <rouca@debian.org> in
<https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1032010>.
* gettext-tools/src/Makefile.am (pkglibexecdir): New variable.
(DEFS): Pass a LIBEXECDIR macro.
(hostname_CPPFLAGS, urlget_CPPFLAGS, cldr_plurals_CPPFLAGS, hostname_LDFLAGS,
urlget_LDFLAGS, cldr_plurals_LDFLAGS, install-exec-local, installdirs-local,
uninstall-local): Use pkglibexecdir instead of pkglibdir.
* gettext-tools/src/msginit.c (project_id, project_id_version, plural_forms):
Test $GETTEXTLIBEXECDIR_SRCDIR instead of $GETTEXTLIBDIR_SRCDIR. Use LIBEXECDIR
instead of LIBDIR.
(get_user_email, language_team_address): Use LIBEXECDIR instead of LIBDIR.
* gettext-tools/tests/msginit-3: Set GETTEXTLIBEXECDIR_SRCDIR instead of
GETTEXTLIBDIR_SRCDIR.
* gettext-tools/tests/msginit-4: Likewise. Set GETTEXTLIBEXECDIR_BUILDDIR
instead of GETTEXTLIBDIR_BUILDDIR.
Bruno Haible [Sat, 17 Jun 2023 08:49:04 +0000 (10:49 +0200)]
intl: Fix translation lookup failure when wbindtextdomain is used.
Reported by Luca Bacci <luca.bacci@outlook.com> at
<https://savannah.gnu.org/bugs/index.php?64311>.
The bug showed up when a call to bindtextdomain() with an absolute directory
and a call to wbindtextdomain() for a different domain was in effect.
Translations in the first referenced domain worked, translations in the second
referenced domain did not.
* gettext-runtime/intl/loadinfo.h (struct loaded_l10nfile, _nl_make_l10nflist):
Improve comments.
* gettext-runtime/intl/finddomain.c (_nl_loaded_domains): Likewise.
* gettext-runtime/intl/l10nflist.c (_nl_make_l10nflist): Fix code that looks up
the loaded_l10nfile in the given list, and make it more maintainable.
* gettext-tools/tests/intl-6: Improve comments.
* gettext-tools/tests/intl-6-prg.c (main): Restructure.
* gettext-tools/tests/intl-7: New file, based on gettext-tools/tests/intl-6.
* gettext-tools/tests/intl-6-prg.c: New file, based on
gettext-tools/tests/intl-6-prg.c.
* gettext-tools/tests/Makefile.am (TESTS): Add intl-7.
(check_PROGRAMS): Add intl-7-prg.
(intl_7_prg_SOURCES, intl_7_prg_LDADD): New variables.
Bruno Haible [Thu, 15 Jun 2023 15:00:56 +0000 (17:00 +0200)]
Make internationalization tests stricter on Solaris 11 systems.
* gettext-tools/tests/format-c-5-prg.c (main): Don't expect an Arabic digit
output in a locale other than Farsi.
* gettext-tools/tests/format-c-5: Try an Arabic locale as well.
Bruno Haible [Thu, 15 Jun 2023 21:33:50 +0000 (23:33 +0200)]
Fix a bug in the last commit.
* gettext-tools/src/write-mo.c (write_table): Include the number of system
dependent string pairs in the computation of the hash table's size.
* gettext-tools/tests/msgfmt-20: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Thu, 15 Jun 2023 07:47:15 +0000 (09:47 +0200)]
Make translations of strings with <inttypes.h> macros work with musl libc.
* gettext-tools/src/write-mo.h (no_redundancy): New declaration.
* gettext-tools/src/write-mo.c (SIZEOF): New macro.
(no_redundancy): New variable.
(struct sysdep_instantiation_rule): New type.
(useful_instantiation_rules): New variable.
(concat_prefix_cs, get_sysdep_segment_value): New functions.
(write_table): Add a second pass, that instantiates system dependent string
pairs.
* gettext-tools/src/msgfmt.c (long_options): Add --no-redundancy.
(main): Handle the --no-redundancy option.
(usage): Document the --no-redundancy option.
* gettext-tools/doc/msgfmt.texi: Document the --no-redundancy option.
* gettext-tools/tests/msgfmt-12: Test the msgfmt result with and without
--no-redundancy.
* gettext-tools/tests/msgunfmt-2: Pass option --no-redundancy to msgfmt.
* NEWS: Mention the change.
* gettext-tools/tests/format-c-3: Include the redundant instantiations in the
expected result of msgunfmt.
* gettext-tools/tests/format-c-4: Likewise.