* gettext-tools/misc/autopoint.in: Instead of failing with "Missing version",
use version 0.23.1. Set omitintl=yes if there is no AM_GNU_GETTEXT invocation.
Bruno Haible [Mon, 30 Jun 2025 11:50:51 +0000 (13:50 +0200)]
Support reading PO files with '#=' lines.
* gettext-tools/src/read-catalog-abstract.c
(catalog_reader_seen_generic_comment): Treat '=' like ','.
* gettext-tools/src/read-catalog.c (default_comment_special): Allow several
calls to this method to make side effects on dcatr.
* gettext-tools/src/read-catalog-special.h: Update comment.
* gettext-tools/src/read-catalog-special.c: Likewise.
* gettext-tools/tests/msgcat-24: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Sun, 29 Jun 2025 07:08:45 +0000 (09:08 +0200)]
examples: Extend the hello-sh example, part 2.
* gettext-tools/examples/hello-sh/hello-2.sh: New file, based on
gettext-tools/examples/hello-sh/hello-1.sh.
* gettext-tools/examples/hello-sh/hello-3.sh: New file, based on
gettext-tools/examples/hello-sh/hello-2.sh.
Bruno Haible [Fri, 27 Jun 2025 21:19:00 +0000 (23:19 +0200)]
Shell: Document two more approaches.
* gettext-tools/doc/lang-sh.texi (sh): Tweaks.
(sh - Three approaches): New subsubsection.
(The gettext.sh approach): New subsubsection, incorporating the "gettext.sh"
subsubsection.
(The printf approach, The printf_gettext approach): New subsubsections.
(Preparing for gettext.sh): Renamed from "Preparing Shell Scripts".
(Preparing for printf, Preparing for printf_gettext): New subsubsections.
* gettext-tools/doc/gettext.texi: Update detailed node list.
* NEWS: Mention the change.
* gettext-tools/src/x-sh.c (init_keywords, init_flag_table_sh): Add knowledge
about printf_gettext and printf_ngettext.
(read_command): Recognize '-c' option of printf_gettext and printf_ngettext.
* gettext-tools/tests/xgettext-sh-1: Add test cases with printf_gettext and
printf_ngettext.
* gettext-tools/doc/xgettext.texi: Document it.
Bruno Haible [Tue, 24 Jun 2025 10:28:21 +0000 (12:28 +0200)]
C++: Add another unit test.
* gettext-tools/tests/lang-c++-boost: New file, based on
gettext-tools/tests/lang-c++26.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
* gettext-tools/doc/lang-c.texi: Mention how to use C++ with the Boost library.
* HACKING: Mention the Boost library.
Bruno Haible [Tue, 24 Jun 2025 05:23:56 +0000 (07:23 +0200)]
Shell: Add another unit test.
* gettext-tools/tests/lang-sh-1: Renamed from gettext-tools/tests/lang-sh.
* gettext-tools/tests/lang-sh-2: New file, based on
gettext-tools/tests/lang-sh-1.
* gettext-tools/tests/Makefile.am (TESTS): Remove lang-sh. Add lang-sh-1,
lang-sh-2.
* gettext-tools/src/format-python-brace.c (struct toplevel_counters): New type.
(parse_directive): Take a 'struct toplevel_counters *' parameter. Allow empty
argument names at the top-level. But reject format strings with both absolute
argument numbers and unnamed arguments at the top-level.
(parse_upto): Take a 'struct toplevel_counters *' parameter.
(format_parse): Pass a 'struct toplevel_counters *' to parse_upto.
* gettext-tools/tests/format-python-brace-1: Update.
* gettext-tools/tests/format-python-brace-2: Add another test case.
* gettext-tools/doc/lang-python.texi: Add more examples of formatting with
positions.
Bruno Haible [Mon, 23 Jun 2025 19:19:56 +0000 (21:19 +0200)]
Add support for Shell printf format strings, part 2.
* gettext-tools/po/POTFILES.in: Add src/format-sh-printf.c.
* gettext-tools/tests/format-sh-printf-1: Use 'printf' instead of 'echo',
because 'echo' processes escape sequences on macOS, OpenBSD, Solaris.
Bruno Haible [Sun, 22 Jun 2025 08:56:33 +0000 (10:56 +0200)]
Add support for Shell printf format strings.
* gettext-tools/src/message.h (enum format_type): Add format_sh_printf.
(NFORMATS): Increment.
* gettext-tools/src/message.c (format_language, format_language_pretty): Add an
entry for format_sh_printf.
* gettext-tools/src/format.h (formatstring_sh_printf): New declaration.
* gettext-tools/src/format.c (formatstring_parsers): Add an entry for
format_sh_printf.
* gettext-tools/src/format-sh-printf.c: New file, based on
gettext-tools/src/format-awk.c.
* gettext-tools/src/FILES: Mention it.
* gettext-tools/src/x-sh.h (SCANNERS_SH): Use formatstring_sh_printf as
secondary format string type.
* gettext-tools/src/xgettext.c (xgettext_record_flag): Update accordingly.
* gettext-tools/src/x-sh.c (init_flag_table_sh): Register gettext, ngettext with
flag 'pass-sh-printf-format'. Register 'printf' with flag 'sh-printf-format'.
* gettext-tools/src/Makefile.am (FORMAT_SOURCE): Add format-sh-printf.c.
* gettext-tools/libgettextpo/Makefile.am (libgettextpo_la_AUXSOURCES): Likewise.
* gettext-tools/doc/gettext.texi (PO Files): Mention sh-printf-format.
(sh-format): Document also the sh-printf-format strings.
* gettext-tools/doc/lang-sh.texi (sh): Mention the coreutils 'printf' command.
* gettext-tools/tests/xgettext-sh-1: Add a test case with a printf invocation.
* gettext-tools/tests/format-sh-printf-1: New file, based on
gettext-tools/tests/format-awk-1.
* gettext-tools/tests/format-sh-printf-2: New file, based on
gettext-tools/tests/format-awk-2.
* gettext-tools/tests/Makefile.am (TESTS): Add them.
* NEWS: Mention the change.
Bruno Haible [Sun, 22 Jun 2025 00:11:33 +0000 (02:11 +0200)]
pascal-format: Accept null precision.
Proof that it's valid:
------------------------- foo.pp -------------------------
program foo;
uses sysutils;
begin
writeln(format('%.f', [3.1415926535]));
end.
----------------------------------------------------------
* gettext-tools/src/format-pascal.c: Fix comment regarding the precision.
(format_parse): Accept a null precision after '.'.
* gettext-tools/tests/format-pascal-1: Add a test case with null precision.
Bruno Haible [Sat, 21 Jun 2025 23:37:58 +0000 (01:37 +0200)]
lua-format: Accept null precision. Limit width and precision to two digits.
Proof that it's valid:
$ lua
print(string.format("%.f", 3.1415926535))
* gettext-tools/src/format-lua.c: Fix comment regarding the width and the
precision.
(format_parse): Recognize at most two digits for the width. Recognize at most
two digits for the precision.
* gettext-tools/tests/format-lua-1: Add test cases with large width, null
precision, and large precision.
Bruno Haible [Sat, 21 Jun 2025 23:20:32 +0000 (01:20 +0200)]
javascript-format: Reject null precision.
Proof that it's invalid:
------------------------------- foo.js -------------------------------
const Format = imports.format;
String.prototype.format = Format.format;
print("%.f".format(3.1415916535));
----------------------------------------------------------------------
$ gjs foo.js
* gettext-tools/src/format-invalid.h (INVALID_PRECISION_MISSING): New macro.
* gettext-tools/src/format-java-printf.c (INVALID_PRECISION_MISSING): Remove
macro.
* gettext-tools/src/format-javascript.c: Fix comment regarding the precision.
(format_parse): Report an error if the precision is null (empty).
* gettext-tools/tests/format-javascript-1: Add a test case with null precision.
Bruno Haible [Sat, 21 Jun 2025 23:08:15 +0000 (01:08 +0200)]
go-format: Accept null precision.
* gettext-tools/src/format-go.c: Clarify comment regarding the precision.
(format_parse): Accept a null precision after '.'.
* gettext-tools/tests/format-go-1: Add a test case with null precision.
Bruno Haible [Sat, 21 Jun 2025 21:49:24 +0000 (23:49 +0200)]
c-format: Accept null precision.
* gettext-tools/src/format-c-parse.h: Fix comment regarding the precision and
the ISO C23 size specifiers.
* gettext-tools/tests/format-c-1: Add a test case with null precision.
Bruno Haible [Sat, 21 Jun 2025 00:53:23 +0000 (02:53 +0200)]
xgettext: Shell: Recognize \u and \U escape sequences in $'...' strings.
* gettext-tools/src/xg-mixed-string.h (mixed_string_remove_prefix,
mixed_string_buffer_equals, mixed_string_buffer_startswith,
mixed_string_buffer_cloned_result): New declarations.
* gettext-tools/src/xg-mixed-string.c (mixed_string_remove_prefix): New
function.
(mixed_string_buffer_is_empty): Also test the absence of utf16_surr.
(mixed_string_buffer_equals, mixed_string_buffer_startswith,
mixed_string_buffer_cloned_result): New functions.
* gettext-tools/src/x-sh.c (struct token): Remove type.
(init_token, free_token, grow_token, string_of_token): Remove functions.
(struct word): Change type of 'token' field.
(free_word): Update.
(string_of_word, substring_of_word): Remove functions.
(read_word): Call mixed_string_buffer_init instead of init_token,
mixed_string_buffer_destroy instead of free_token,
mixed_string_buffer_append_char instead of grow_token. Update accesses to
wp->token. Recognize \u and \U escape sequences in $'...' strings.
(read_command): Call mixed_string_buffer_cloned_result instead of
string_of_word. Update accesses to inner.token.
* gettext-tools/tests/xgettext-sh-7: Use --from-code option.
* gettext-tools/tests/xgettext-sh-9: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
* NEWS: Mention this and the previous change.
Bruno Haible [Thu, 19 Jun 2025 11:36:10 +0000 (13:36 +0200)]
Deprecate the gfc-internal-format flag.
* gettext-tools/src/format-gfc-internal.c: Update comment.
* gettext-tools/doc/gettext.texi (PO Files): Mark gfc-internal-format as
deprecated.
(gfc-internal-format): Mention "up to GCC 14".
Bruno Haible [Thu, 19 Jun 2025 11:35:46 +0000 (13:35 +0200)]
Update gcc-internal-format for GCC 15.
Reported by Roland Illig, Andrew Pinski, Jakub Jelinek in
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119684>.
Also reported by Roland Illig in
<https://savannah.gnu.org/bugs/?50450>, <https://savannah.gnu.org/bugs/?50461>.
Bruno Haible [Thu, 5 Jun 2025 19:43:27 +0000 (21:43 +0200)]
build: Fix "make install" in MSVC builds with --enable-shared.
The problem was that intl-8.dll was not installed with execute permissions.
* gettext-runtime/intl/Makefile.am (install-exec-libintl): Use $(INSTALL),
not $(INSTALL_DATA), with libtool --mode=install.
* INSTALL.windows: Remove constraint to use --disable-shared on MSVC.
Thanks to Kirill Makurin <maiddaisuki@outlook.com> for fruitful discussions.
* autogen.sh: Among the gnulib-tests, avoid the modules array-map-tests,
array-oset-tests, carray-list-tests, and uninorm/decomposing-form-tests, since
they use variables from libgettextlib.
* gettext-tools/configure.ac (GL_GNULIB_LIBUNISTRING_DLL_VARIABLE_NAME): New
variable.
(WOE32DLL): New C macro.
(DLL_VARIABLE): On MSVC with --enable-shared, define to '__declspec(dllexport)'
when compiling libgettextlib, and define to '__declspec(dllimport)' when
compiling the programs in src/.
(LIBGETTEXTSRC_DLL_VARIABLE): New C macro.
* gettext-tools/gnulib-lib/Makefile.am (AM_CPPFLAGS): Define the C macro
IN_LIBGETTEXTLIB.
* gettext-tools/src/Makefile.am (libgettextsrc_la_CPPFLAGS): Define the C macro
IN_LIBGETTEXTSRC.
* gettext-tools/src/format.h: Use LIBGETTEXTSRC_DLL_VARIABLE instead of
DLL_VARIABLE.
* gettext-tools/src/message.h: Likewise.
* gettext-tools/src/msgl-cat.h: Likewise.
* gettext-tools/src/plural-table.h: Likewise.
* gettext-tools/src/po-charset.h: Likewise.
* gettext-tools/src/po-error.h: Likewise.
* gettext-tools/src/read-catalog.h: Likewise.
* gettext-tools/src/read-po.h: Likewise.
* gettext-tools/src/read-properties.h: Likewise.
* gettext-tools/src/read-stringtable.h: Likewise.
* gettext-tools/src/sentence.h: Likewise.
* gettext-tools/src/write-po.h: Likewise.
* gettext-tools/src/write-properties.h: Likewise.
* gettext-tools/src/write-stringtable.h: Likewise.
* gettext-tools/src/xerror-handler.h: Likewise.
* gettext-tools/libgettextpo/Makefile.am (config.h): Override the value of
LIBGETTEXTSRC_DLL_VARIABLE.
* gettext-runtime/configure.ac (WOE32DLL): New C macro.
(DLL_VARIABLE): Define to empty always.
Bruno Haible [Sun, 1 Jun 2025 23:39:20 +0000 (01:39 +0200)]
xgettext: Tcl: Improve heuristic for format strings.
* gettext-tools/src/format-tcl.c (struct spec): Add field
'likely_intentional_directives'.
(format_parse): Set it to the number of directives that don't contain a space.
(format_is_unlikely_intentional): New function.
(formatstring_tcl): Use it.
* gettext-tools/tests/format-tcl-3: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Sun, 1 Jun 2025 23:36:07 +0000 (01:36 +0200)]
xgettext: Ruby: Improve heuristic for format strings.
* gettext-tools/src/format-ruby.c (struct spec): Add field
'likely_intentional_directives'.
(format_parse): Set it to the number of directives that don't contain a space.
(format_is_unlikely_intentional): New function.
(formatstring_ruby): Use it.
* gettext-tools/tests/format-ruby-3: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Sun, 1 Jun 2025 23:26:23 +0000 (01:26 +0200)]
xgettext: Python: Improve heuristic for format strings.
* gettext-tools/src/format-python.c (struct spec): Add field
'likely_intentional_directives'.
(format_parse): Set it to the number of directives that don't contain a space.
(format_is_unlikely_intentional): New function.
(formatstring_python): Use it.
* gettext-tools/tests/format-python-3: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Sun, 1 Jun 2025 23:23:13 +0000 (01:23 +0200)]
xgettext: PHP: Improve heuristic for format strings.
* gettext-tools/src/format-php.c (struct spec): Add field
'likely_intentional_directives'.
(format_parse): Set it to the number of directives that don't contain a space.
(format_is_unlikely_intentional): New function.
(formatstring_php): Use it.
* gettext-tools/tests/format-php-3: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Sun, 1 Jun 2025 23:16:11 +0000 (01:16 +0200)]
xgettext: Perl: Improve heuristic for format strings.
* gettext-tools/src/format-perl.c (struct spec): Add field
'likely_intentional_directives'.
(format_parse): Set it to the number of directives that don't contain a space.
(format_is_unlikely_intentional): New function.
(formatstring_perl): Use it.
* gettext-tools/tests/format-perl-3: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Sun, 1 Jun 2025 23:10:52 +0000 (01:10 +0200)]
xgettext: librep: Improve heuristic for format strings.
* gettext-tools/src/format-librep.c (struct spec): Add field
'likely_intentional_directives'.
(format_parse): Set it to the number of directives that don't contain a space.
(format_is_unlikely_intentional): New function.
(formatstring_librep): Use it.
* gettext-tools/tests/format-librep-3: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Sun, 1 Jun 2025 23:52:49 +0000 (01:52 +0200)]
xgettext: JavaScript: Improve heuristic for format strings.
* gettext-tools/src/format-javascript.c (struct spec): Add field
'likely_intentional_directives'.
(format_parse): Set it to the number of directives that don't contain a space.
(format_is_unlikely_intentional): New function.
(formatstring_javascript): Use it.
* gettext-tools/tests/format-javascript-3: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Sun, 1 Jun 2025 23:01:50 +0000 (01:01 +0200)]
xgettext: Go: Improve heuristic for format strings.
* gettext-tools/src/format-go.c (struct spec): Add field
'likely_intentional_directives'.
(format_parse): Set it to the number of directives that don't contain a space.
(format_is_unlikely_intentional): New function.
(formatstring_go): Use it.
* gettext-tools/tests/format-go-3: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Sun, 1 Jun 2025 22:35:16 +0000 (00:35 +0200)]
xgettext: Emacs Lisp: Improve heuristic for format strings.
* gettext-tools/src/format-elisp.c (struct spec): Add field
'likely_intentional_directives'.
(format_parse): Set it to the number of directives that don't contain a space.
(format_is_unlikely_intentional): New function.
(formatstring_elisp): Use it.
* gettext-tools/tests/format-elisp-3: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Sun, 1 Jun 2025 22:32:14 +0000 (00:32 +0200)]
xgettext: D: Improve heuristic for format strings.
* gettext-tools/src/format-d.c (struct spec): Add field
'likely_intentional_directives'.
(parse_upto): Increment it for each directive that don't contain a space.
(format_parse): Initialize it.
(format_is_unlikely_intentional): New function.
(formatstring_d): Use it.
* gettext-tools/tests/format-d-3: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Sun, 1 Jun 2025 22:17:32 +0000 (00:17 +0200)]
xgettext: C++: Improve heuristic for Boost format strings.
* gettext-tools/src/format-boost.c (struct spec): Add field
'likely_intentional_directives'.
(format_parse): Set it to the number of directives that don't contain a space.
(format_is_unlikely_intentional): New function.
(formatstring_boost): Use it.
* gettext-tools/tests/format-boost-3: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.