Bruno Haible [Wed, 21 Feb 2024 10:21:31 +0000 (11:21 +0100)]
xgettext: Vala: Don't flag printf arguments as c-format.
Reported by Anders Jonsson <anders.jonsson@norsjovallen.se>
at <https://savannah.gnu.org/bugs/?64921>.
* gettext-tools/src/xgettext.c (xgettext_record_flag: Recognize also
"undecided-...-format".
* gettext-tools/src/x-vala.c (init_flag_table_vala): Flag the printf function as
'undecided-c-format', not 'c-format'.
* gettext-tools/tests/xgettext-vala-5: Use vprintf instead of printf.
* gettext-tools/tests/xgettext-vala-6: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
* NEWS: Mention the fix.
Bruno Haible [Fri, 17 Nov 2023 11:46:33 +0000 (12:46 +0100)]
gettext.m4: Recognize a statically built libintl on macOS and AIX.
Reported by David Edelsohn <dje.gcc@gmail.com> in
<https://gcc.gnu.org/pipermail/gcc-patches/2023-November/636558.html>.
* gettext-runtime/m4/gettext.m4 (AM_GNU_GETTEXT): In the
"checking for GNU gettext in libintl..." test, add also the special
system library dependencies needed on macOS and AIX.
Bruno Haible [Fri, 17 Nov 2023 11:40:54 +0000 (12:40 +0100)]
build: Fix a build issue on AIX.
How to reproduce:
$ cd gettext-20231111
$ ~/build-64-gcc --disable-shared
$ (cd build-64-gcc && gmake install)
$ cd ..
$ cd gettext-0.22.3
$ ~/build-64-gcc
=> Fails with "ERROR: Undefined symbol: .syntax_check_message_list"
because the link uses $PREFIX/lib/libgettextsrc.a, which is a non-shared
library that does not export 'syntax_check_message_list'.
* gettext-tools/configure.ac (INSTALL_PRIVATE_LIBRARIES): New conditional.
* gettext-tools/src/Makefile.am (noinst_LTLIBRARIES): Define as alternative to
lib_LTLIBRARIES.
(install-exec-clean): Remove rule.
* gettext-tools/gnulib-lib/Makefile.am (lib_LTLIBRARIES): Initialize.
* gnulib-local/modules/gettext-tools-misc (Makefile.am): Define
noinst_LTLIBRARIES as alternative to lib_LTLIBRARIES. Remove
'install-exec-clean' rule.
Bruno Haible [Wed, 4 Oct 2023 14:12:43 +0000 (16:12 +0200)]
Avoid crash on macOS 14.
Reported by Shupeng Xue <dspxue@gmail.com> at
<https://lists.gnu.org/archive/html/bug-gettext/2023-10/msg00001.html>.
Cf <https://github.com/aria2/aria2/issues/2083#issuecomment-1694662007>.
* gettext-runtime/m4/intlmacosx.m4 (gt_INTL_MACOSX): Link with the CoreServices
framework in addition to the CoreFoundation framework.
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.
* 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, po_file_write, po_error_logger, po_message_check_format): Use
these variables instead of the error, error_at_line symbols.
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, 6 Sep 2023 18:59:03 +0000 (20:59 +0200)]
intl: Don't export symbols from static MSVC .obj files.
* 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 [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.
Bruno Haible [Thu, 15 Jun 2023 07:30:44 +0000 (09:30 +0200)]
mem-hash-map: Fix a left-over from 2001-11-20.
* gnulib-local/lib/mem-hash-map.h (hash_init): Fix comment.
* gnulib-local/lib/mem-hash-map.c (hash_init): Likewise.
* gettext-tools/src/msgl-fsearch.c (message_fuzzy_index_alloc): Don't test the
return value of hash_init.
Bruno Haible [Wed, 14 Jun 2023 11:56:24 +0000 (13:56 +0200)]
Avoid the need for charset conversion at run time on musl libc.
This fixes 1 system-tests failure (intl-2) and 3 tests failures (lang-c,
lang-c++, lang-sh).
* gettext-tools/src/write-mo.h (no_convert_to_utf8): New declaration.
(msgdomain_write_mo): Add a 4th parameter.
* gettext-tools/src/write-mo.c: Include po-charset.h, msgl-iconv.h.
(no_convert_to_utf8): New variable.
(msgdomain_write_mo): Add a 4th parameter. Convert the message list to UTF-8.
* gettext-tools/src/msgfmt.c (long_options): Add --no-convert.
(main): Handle the --no-convert option. Pass a 4th argument to
msgdomain_write_mo.
(usage): Document the --no-convert option.
* gettext-tools/doc/msgfmt.texi: Document the --no-convert option.
* gettext-tools/doc/gettext.texi (MO Files): Document the character encoding of
strings in MO files.
* gettext-tools/tests/msgfmt-5: Use msgfmt option --no-convert.
* gettext-tools/tests/msgfmt-12: Likewise.
* gettext-tools/tests/lang-pascal: Likewise.
* NEWS: Mention the change.
Bruno Haible [Thu, 8 Jun 2023 18:41:14 +0000 (20:41 +0200)]
Add support for C++ format strings.
* gettext-tools/src/message.h (enum format_type): New enum item
format_cplusplus_brace.
(NFORMATS): Increment.
* gettext-tools/src/message.c (format_language, format_language_pretty): Add
entries for format_cplusplus_brace.
* gettext-tools/src/format.h (formatstring_cplusplus_brace): New declaration.
* gettext-tools/src/format-c++-brace.c: New file, based on
gettext-tools/src/format-awk.c.
* gettext-tools/src/format.c (formatstring_parsers): Add an entry for
format_cplusplus_brace.
* gettext-tools/src/Makefile.am (FORMAT_SOURCE): Add format-c++-brace.c.
* gettext-tools/src/FILES: Update.
* gettext-tools/src/x-c.h (SCANNERS_C): In language C++, use
formatstring_cplusplus_brace as second format string parser.
* gettext-tools/src/x-c.c (init_flag_table_c): Initialize flags related to
c++-format.
* gettext-tools/src/xgettext.c (xgettext_record_flag): Handle
format_cplusplus_brace.
(recognize_qt_formatstrings, language_to_extractor): Update.
* gettext-tools/src/xg-arglist-parser.c (arglist_parser_done): Update.
* gettext-tools/libgettextpo/Makefile.am (libgettextpo_la_AUXSOURCES): Add
format-c++-brace.c.
* gettext-tools/tests/format-c++-brace-1: New file, based on
gettext-tools/tests/format-c-1.
* gettext-tools/tests/format-c++-brace-2: New file, based on
gettext-tools/tests/format-c-2.
* gettext-tools/tests/lang-c++20: New file, based on
gettext-tools/tests/lang-c++.
* gettext-tools/tests/Makefile.am (TESTS): Add them.
* gettext-tools/doc/gettext.texi (PO Files): Mention c++-format and
no-c++-format.
(Preparing strings): Add subheading "No programmer-defined format string
directives".
(Mark Keywords): Mention the need to use std::vformat instead of std::format.
(c++-format): New subsection.
* gettext-tools/doc/lang-c.texi: Mention the syntax for C++ format strings.
* NEWS: Mention the change.
Bruno Haible [Wed, 7 Jun 2023 16:57:37 +0000 (18:57 +0200)]
xgettext: Avoid side effects of the Vala extractor on the C extractor.
* gettext-tools/src/xgettext.h (xgettext_record_flag): Add more comments.
* gettext-tools/src/xgettext.c (xgettext_record_flag): Parse an optional
'!BACKEND' suffix. When present, limit the effects of c-format related flags to
the specified flag table(s).
* gettext-tools/src/x-vala.c (init_flag_table_vala): Append '!Vala' to all
xgettext_record_flag arguments.
* gettext-tools/tests/xgettext-c-format-6: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Wed, 7 Jun 2023 15:51:18 +0000 (17:51 +0200)]
xgettext: In language Python, fix a format string handling bug.
The option --flag=my_new_format:1:python-brace-format used to mark strings
inside my_new_format invocations as being 'python-format' instead of
'python-brace-format'.
* gettext-tools/src/xgettext.c (xgettext_record_flag): Use the correct index
into flag_table_python.
* gettext-tools/tests/xgettext-python-7: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Wed, 7 Jun 2023 15:22:03 +0000 (17:22 +0200)]
xgettext: In language Vala, fix a format string handling bug.
* gettext-tools/src/xgettext.c (xgettext_record_flag): Store format_c related
flags also in flag_table_vala.
* gettext-tools/tests/xgettext-vala-5: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Wed, 7 Jun 2023 13:50:03 +0000 (15:50 +0200)]
xgettext: Reduce code duplication.
* gettext-tools/src/xg-arglist-context.h (flag_context_list_table_add): Add
comment.
* gettext-tools/src/xg-arglist-context.c (set_flags_for_formatstring_type): New
function, extracted from flag_context_list_table_add.
(flag_context_list_table_add): Use it.
Bruno Haible [Sun, 4 Jun 2023 15:34:25 +0000 (17:34 +0200)]
build: Don't rename error{_at_line} to rpl_error{_at_line} on native Windows.
* gettext-tools/configure.ac (GNULIB_REPLACE_ERROR): Define only on Cygwin and
Android.
* gettext-tools/woe32dll/gettextlib-exports.c: Don't assume that
GNULIB_DEFINED_ERROR implies GNULIB_REPLACE_ERROR.
* libtextstyle/autogen.sh (GNULIB_MODULES): Add manywarnings.
Copy also more-warnings.m4.
* gnulib-local/modules/libxml (Makefile.am): New variable libxml_rpl_la_CFLAGS.
* libtextstyle/gnulib-local/modules/libcroco (Makefile.am): New variable
libcroco_rpl_la_CFLAGS.
* libtextstyle/gnulib-local/modules/libglib (Makefile.am): New variable
libglib_rpl_la_CFLAGS.
* libtextstyle/configure.ac: Invoke gt_MORE_WARNINGS, gl_CC_INHIBIT_WARNINGS.
* libtextstyle/lib/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
(config.h): Do the compilations with GL_CFLAG_INHIBIT_WARNINGS.
* gettext-runtime/configure.ac: Invoke gt_MORE_WARNINGS.
* gettext-runtime/src/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
* gnulib-local/modules/gettext-runtime-misc (Makefile.am): Add WARN_CFLAGS to
AM_CFLAGS.
* gettext-runtime/libasprintf/configure.ac: Invoke gt_MORE_WARNINGS.
* gettext-runtime/libasprintf/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
* gettext-tools/configure.ac: Invoke gt_MORE_WARNINGS, gl_CC_INHIBIT_WARNINGS.
* gettext-tools/gnulib-lib/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
* gettext-tools/libgrep/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
* gettext-tools/src/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
* gettext-tools/libgettextpo/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
(config.h): Do the compilations with GL_CFLAG_INHIBIT_WARNINGS.
Bruno Haible [Sat, 3 Jun 2023 11:27:03 +0000 (13:27 +0200)]
Enable better malloc/free checking in a few cases.
Pinpointed by gcc 13 warning:
warning: function might be candidate for attribute 'malloc' [-Wsuggest-attribute=malloc]
* gettext-tools/src/po-time.h: Include attribute.h.
(po_strftime): Mark with attribute 'malloc'.
* gettext-tools/src/write-po.h: Include attribute.h.
(make_range_description_string): Mark with attribute 'malloc'.