Bruno Haible [Wed, 23 Oct 2024 07:59:49 +0000 (09:59 +0200)]
Fix test failure of autopoint-3 on Cygwin.
It was broken since commit "tests: Use libtool in autopoint-3 test" (2014-09-05):
The Makefile specified to link the 'hello' program without libtool
(and thus Automake generated a direct link command without libtool),
but the LDADD variable used @LTLIBINTL@. On Cygwin, this led to a use of
the -R option, which the compiler does not understand:
x86_64-pc-cygwin-gcc: error: unrecognized command line option ‘-R’; did you mean ‘-R’?
* gettext-tools/tests/autopoint-3: Don't invoke LT_INIT. Use @LIBINTL@,
not @LTLIBINTL@. Don't touch ltmain.sh.
Bruno Haible [Sun, 20 Oct 2024 22:46:53 +0000 (00:46 +0200)]
doc: Update after Automake changed.
* gettext-tools/doc/gettextize.texi: Update now that Automake with option 'gnu'
no longer requires ABOUT-NLS. Cf.
<https://git.savannah.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=a2def8cdef>.
Bruno Haible [Thu, 17 Oct 2024 21:53:17 +0000 (23:53 +0200)]
doc: Clarify locale names and language names.
Reported by Arfrever <arfrever.fta@gmail.com>
at <https://savannah.gnu.org/bugs/?59062>.
* gettext-runtime/doc/nls.texi (INSTALL Matters, Using This Package): Mention
ll_CC as alterntive to ll, and that ll can be a 3-letter code.
* gettext-tools/doc/gettext.texi (Locale Names, Header Entry, Installers):
Likewise.
Bruno Haible [Tue, 15 Oct 2024 19:52:30 +0000 (21:52 +0200)]
intl: Fix a memory leak.
* gettext-runtime/intl/finddomain.c (_nl_find_domain): If there was an alias and
_nl_explode_name or _nl_make_l10nflist fails, free the allocated memory. Avoid
'goto'.
Bruno Haible [Tue, 15 Oct 2024 14:49:13 +0000 (16:49 +0200)]
gettext.h: Avoid "warning: ISO C++ forbids variable length array" with -pedantic.
Both "g++ -pedantic" and "clang++ -pedantic" warn about use of VLAs.
Since we cannot distinguish "g++" from "g++ -pedantic" through a preprocessor
macro, it's best to not use a VLA in C++.
Reported by Jens Seidel <jensseidel@users.sf.net>
via <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=547798>
at <https://savannah.gnu.org/bugs/index.php?55149>.
* gnulib-local/lib/gettext.h (_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS): Define
to 0 in C++ mode.
Bruno Haible [Tue, 15 Oct 2024 14:04:45 +0000 (16:04 +0200)]
msgen: Convert charset=CHARSET to charset=ASCII.
Reported at <https://savannah.gnu.org/bugs/index.php?20923>.
* gettext-tools/src/msgen.c: Include msgl-ascii.h, c-strstr.h, xalloc.h.
(fill_header): New function, based on fill_header in msginit.c.
(main): Invoke it.
* gettext-tools/tests/msgen-1: Provide as input a POT file with charset=CHARSET,
and verify that the output has charset=ASCII.
Bruno Haible [Tue, 15 Oct 2024 13:42:46 +0000 (15:42 +0200)]
Refactor.
* gettext-tools/src/msgl-header.h (header_set_charset): New declaration.
* gettext-tools/src/msgl-header.c (header_set_charset): New function.
* gettext-tools/src/msgl-iconv.c: Include msgl-header.h.
(iconv_message_list_internal): Use header_set_charset.
* gettext-tools/src/x-po.c: Include msgl-header.h.
(extract): Use header_set_charset.
* gettext-tools/src/FILES: Update.
Bruno Haible [Tue, 15 Oct 2024 00:37:28 +0000 (02:37 +0200)]
its: Add ability to check *.its and *.loc files with XML Schema 1.1.
* gettext-tools/src/its.xsd10: Renamed from gettext-tools/src/its.xsd.
(RulesType): Enumerate all possible rules in the ITS namespace, instead of using
a wildcard.
(OtherRuleType): New element.
* gettext-tools/src/its.xsd11: Copied from gettext-tools/src/its.xsd.
(LocNoteRuleType): Enable assertion.
* gettext-tools/src/locating-rules.xsd10: Renamed from
gettext-tools/src/locating-rules.xsd.
* gettext-tools/src/locating-rules.xsd11: Copied from
gettext-tools/src/locating-rules.xsd.
(LocatingRuleType): Enable assertion.
* gettext-tools/src/Makefile.am (schema_DATA): Add its.xsd10, its.xsd11,
locating-rules.xsd10, locating-rules.xsd11. Remove its.xsd, locating-rules.xsd.
* gettext-tools/build-aux/xml-validate-10.in: New file.
* gettext-tools/build-aux/xml-validate-11.in: New file.
* gettext-tools/configure.ac: Substitute HAVE_JAVAEXEC.
(AC_CONFIG_FILES): Create build-aux/xml-validate-10, build-aux/xml-validate-11.
* gettext-tools/Makefile.am (DISTCLEANFILES): Add build-aux/xml-validate-10,
build-aux/xml-validate-11.
* gettext-tools/its/Makefile.am: Revert last commit.
(check-local): Check each file both using the XML Schema 1.0 and the XML Schema
1.1.
* gettext-tools/doc/gettext.texi (ITS Rules): Mention the two versions of
its.xsd.
(Location Rules): Mention the two versions of locating-rules.xsd.
* HACKING: Mention Xerces2-J.
Bruno Haible [Sun, 13 Oct 2024 23:41:49 +0000 (01:41 +0200)]
po: Add a copyright and license notice to the Rules-quot auxiliary files.
Reported by Joël Krähemann <jkraehemann@gmail.com>
at <https://savannah.gnu.org/bugs/?57973>.
* gettext-runtime/po/quot.sed: Add a copyright and all-permissive license
notice.
* gettext-runtime/po/boldquot.sed: Likewise.
* gettext-runtime/po/en@quot.header: Likewise.
* gettext-runtime/po/en@boldquot.header: Likewise.
* gettext-runtime/po/insert-header.sed: Use an all-permissive license notice.
* gettext-runtime/po/Rules-quot: Likewise.
(.insert-header.po-update-en): After running the *.insert-header script,
eliminate lines that start with %%.
Bruno Haible [Sun, 13 Oct 2024 20:37:39 +0000 (22:37 +0200)]
po: Assume a 'sed' that supports '#' for introducing comments.
This is standardized in POSIX since POSIX:2001 (= SUSv3).
It is supported on all platforms that I could test:
GNU, macOS 10.5, FreeBSD 5, NetBSD 7, OpenBSD 6, AIX 7, Solaris 10 and 11,
busybox (2019).
* gettext-runtime/po/remove-potcdate.sed: Renamed from
gettext-runtime/po/remove-potcdate.sin.
* gettext-runtime/po/Makefile.in.in (DISTFILES.common): Update.
(.SUFFIXES): Remove .sin.
(.sin.sed): Remove rule.
($(DOMAIN).pot-update): Use remove-potcdate.sed in $(srcdir).
(mostlyclean): Don't remove remove-potcdate.sed.
* autogen.sh: Update.
* Makefile.am (distcheck-hook): Update.
* gettext-tools/examples/po/remove-potcdate.sed: Renamed from
gettext-tools/examples/po/remove-potcdate.sin.
* gettext-tools/examples/po/Makefile.am ($(DOMAIN).pot-update): Use
remove-potcdate.sed in $(srcdir).
(MOSTLYCLEANFILES): Don't add remove-potcdate.sed.
(EXTRA_DIST): Update.
* gettext-tools/examples/hello-*/po/Makefile.am ($(DOMAIN).pot-update): Use
remove-potcdate.sed in $(srcdir).
(MOSTLYCLEANFILES): Don't add remove-potcdate.sed.
(EXTRA_DIST): Update.
* gettext-tools/examples/hello-objc-gnustep/po/GNUmakefile
($(DOMAIN).pot-update): Remove dependency on remove-potcdate.sed.
(internal-clean): Remove rule.
* gettext-tools/examples/hello-*/autogen.sh: Update.
* gettext-tools/examples/hello-*/autoclean.sh: Update.
Bruno Haible [Sun, 13 Oct 2024 20:36:41 +0000 (22:36 +0200)]
po: Assume a 'sed' that supports '#' for introducing comments.
This is standardized in POSIX since POSIX:2001 (= SUSv3).
It is supported on all platforms that I could test:
GNU, macOS 10.5, FreeBSD 5, NetBSD 7, OpenBSD 6, AIX 7, Solaris 10 and 11,
busybox (2019).
* gettext-runtime/po/insert-header.sed: Renamed from
gettext-runtime/po/insert-header.sin.
* gettext-runtime/po/Rules-quot (DISTFILES.common.extra1): Update.
(en@quot.insert-header, en@boldquot.insert-header): Use insert-header.sed
instead of insert-header.sin.
* autogen.sh: Update.
* Makefile.am (distcheck-hook): Update.
* gettext-tools/examples/hello-*/autogen.sh: Update.
* gettext-tools/doc/gettext.texi (po/LINGUAS): Update.
Bruno Haible [Sun, 13 Oct 2024 18:18:15 +0000 (20:18 +0200)]
xgettext: Desktop: Correct the line numbers in the output and in error messages.
* gettext-tools/src/read-desktop.c (struct token_ty): Add a 'lineno' field.
(desktop_lex): Correct the line numbers in error messages. For a token of type
token_type_pair, store the line number.
(desktop_parse): Pass the line number from the token to
desktop_reader_handle_pair.
* gettext-tools/tests/xgettext-desktop-1: Update expected output.
* gettext-tools/tests/xgettext-desktop-2: Likewise.
* NEWS: Mention the change.
Bruno Haible [Sun, 13 Oct 2024 01:00:35 +0000 (03:00 +0200)]
its: Improve error handling.
* gettext-tools/src/its.c: Include libxml/xmlerror.h.
(structured_error): New function.
(its_rule_list_add_from_file, its_rule_list_add_from_string,
its_rule_list_extract, its_merge_context_alloc): Exit upon fatal error.
Set the structured_error for the rest of the function.
(its_merge_context_merge, its_merge_context_write): Set the structured_error.
Bruno Haible [Fri, 11 Oct 2024 10:55:42 +0000 (12:55 +0200)]
its: Allow a specific XML namespace for .metainfo.xml / .appdata.xml files.
Reported by Claude Paroz <claude@2xlibre.net>
at <https://savannah.gnu.org/bugs/?54472>.
* gettext-tools/its/metainfo.its: Duplicate the rules for XML instances that
use the metainfo namespace.
* gettext-tools/tests/xgettext-appdata-3: New file, based on
gettext-tools/tests/xgettext-appdata-2.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Wed, 9 Oct 2024 21:11:41 +0000 (23:11 +0200)]
build: Revert the revert, and use Sergey Poznyakoff's fix instead.
Sergey's fix is at
<https://debbugs.gnu.org/cgi/bugreport.cgi?msg=17;bug=73620> =
<https://lists.gnu.org/archive/html/bug-libtool/2024-10/msg00008.html>.
Bruno Haible [Wed, 9 Oct 2024 02:06:47 +0000 (04:06 +0200)]
C#: Add support for dotnet.
Reported by Michele Locati <mlocati@gmail.com>
at <https://savannah.gnu.org/bugs/index.php?66292>.
* DEPENDENCIES: Mention dotnet as an alternative to Mono.
* NEWS: Mention the change.
* PACKAGING: Mention the new file $prefix/lib/gettext/GNU.Gettext.dll.
* gettext-runtime/intl-csharp/Makefile.am (pkglibdir): New variable.
(CLEANFILES): Add GNU.Gettext.pdb.
(install-dll-no, install-dll-yes): Install also into $(pkglibdir).
(installdirs-dll, uninstall-dll): Update accordingly.
* gettext-runtime/intl-csharp/intl.cs (GettextResourceSet): Add field Table.
Override GetEnumerator, GetObject to handle it. Change the Keys method to handle
it as well.
* gettext-tools/tests/lang-csharp: In the program, on Windows, produce UTF-8
output with Unix end-of-lines and set the culture manually.
Bruno Haible [Mon, 7 Oct 2024 18:39:07 +0000 (20:39 +0200)]
Improve C# support on Cygwin.
* autogen.sh (GNULIB_MODULES_TOOLS_FOR_SRC): Add cygpath.
* gettext-tools/src/read-csharp.c: Include cygpath.h.
(msgdomain_read_csharp): Convert the directory passed to msgunfmt.net.exe from
Cygwin to Windows syntax.
* gettext-tools/src/read-resources.c: Include cygpath.h.
(read_resources_file): Convert the file name passed to msgunfmt.net.exe from
Cygwin to Windows syntax.
* gettext-tools/src/write-resources.c: Include cygpath.h.
(msgdomain_write_csharp_resources): Convert the file name passed to
msgfmt.net.exe from Cygwin to Windows syntax.
Bruno Haible [Sat, 5 Oct 2024 15:53:52 +0000 (17:53 +0200)]
doc: Document how to use custom *.its files.
Reported by Stefan Brüns <stefan.bruens@rwth-aachen.de>
at <https://savannah.gnu.org/bugs/?64026>.
* gettext-tools/src/search-path.c (get_search_path): Improve comments.
* gettext-tools/doc/xgettext.texi: New subsection "Options for XML input files".
Move the description of --its out of subsection "Output details".
* gettext-tools/doc/msgfmt.texi: Document GETTEXTDATADIRS.
* gettext-tools/doc/gettext.texi (Installers): Document the
PREFIX/share/gettext/its/ directory.
Bruno Haible [Thu, 3 Oct 2024 20:34:14 +0000 (22:34 +0200)]
its: Fix the value of the xml:lang attribute inserted by msgfmt.
Reported by Matthias Klumpp <matthias@tenstral.net>
at <https://savannah.gnu.org/bugs/?64025>.
* autogen.sh (GNULIB_MODULES_TOOLS_FOR_SRC): Add bcp47.
* gettext-tools/src/its.c: Include "bcp47.h".
(its_merge_context_merge_node): Convert the language / locale name to BCP 47
syntax before storing it in the xml:lang attribute.
* gettext-tools/tests/msgfmt-xml-3: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
* NEWS: Mention the change.
Bruno Haible [Tue, 1 Oct 2024 14:42:56 +0000 (16:42 +0200)]
its: Do escape handling during msgfmt merge, not during xgettext. Off by default.
Reported by Samy Mahmoudi <samy.mahmoudi@gmail.com>
at <https://savannah.gnu.org/bugs/?58643>.
* gettext-tools/src/its.c (its_localization_note_rule_constructor): Don't do
escaping while extracting a localization note.
(its_rule_list_extract_text): New local variable do_escape_during_extract. Don't
do escaping while extracting.
(starts_with_character_reference, _its_encode_special_chars_for_merge): New
functions.
(its_merge_context_merge_node): New local variables do_escape_during_extract,
do_escape_during_merge. Don't do escaping while extracting. Conditionally do
escaping while merging.
* gettext-tools/src/its-extensions.xsd: Mention that escape="no" is now the
default.
* gettext-tools/its/glade1.its: Add a comment.
* gettext-tools/its/glade2.its: Likewise.
* gettext-tools/its/gsettings.its: Likewise.
* gettext-tools/its/gtkbuilder.its: Likewise.
* gettext-tools/its/metainfo.its: Add a <gt:escapeRule>.
* gettext-tools/tests/xgettext-appdata-1: Add comment.
* gettext-tools/tests/xgettext-appdata-2: New file, based on
gettext-tools/tests/msgfmt-xml-1.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
* gettext-tools/tests/xgettext-its-1: Update expected results.
* gettext-tools/tests/msgfmt-xml-1: Test also character references and entity
references.
* gettext-tools/tests/msgfmt-xml-2: Likewise.
* gettext-tools/doc/gettext.texi (ITS Rules): Under "Escape Special Characters",
explain that it is no longer necessary to write a rule with escape="no".
Rewrite section "Two Use-cases of Translated Strings in XML".
* NEWS: Mention the changes.
Bruno Haible [Mon, 30 Sep 2024 19:03:47 +0000 (21:03 +0200)]
its: Refactor.
* gettext-tools/src/its.c (_its_collect_text_content, _its_get_content): Replace
the no_escape parameter with a do_escape parameter.
(its_localization_note_rule_constructor, its_rule_list_extract_text,
its_merge_context_merge_node): All callers changed.
Bruno Haible [Sun, 29 Sep 2024 14:47:30 +0000 (16:47 +0200)]
Provide XML schemas for .its and .loc files.
Suggested by Martin Blanchard <tchaik@gmx.com>
at <https://savannah.gnu.org/bugs/?56519>.
* gettext-tools/src/its.xsd: New file, reverse-engineered from its.c.
* gettext-tools/src/its-extensions.xsd: New file, reverse-engineered from its.c.
* gettext-tools/src/locating-rules.xsd: New file, reverse-engineered from
locating-rules.c.
* gettext-tools/src/Makefile.am (schemadir): New variable.
(schema_DATA): New variable.
(EXTRA_DIST): Distribute all of schema_DATA.
* gettext-tools/configure.ac: Check for xmllint, and set XMLLINT.
* gettext-tools/its/Makefile.am (ITS_FILES, LOC_FILES): New variables.
(dist_its_DATA): Rewrite.
(check-local): New rule.
* gettext-tools/doc/gettext.texi (Preparing ITS Rules): Split into two
subsections. Mention which schema the files have to obey.
* HACKING: Mention xmllint as maintainer prerequisite.
* PACKAGING: Mention the $prefix/share/gettext/schema/ directory.
* NEWS: Mention the change.
Bruno Haible [Sat, 28 Sep 2024 00:09:36 +0000 (02:09 +0200)]
xgettext: JavaScript: Support customized handling of tagged template literals.
Reported by Evan Welsh <contact@evanwelsh.com>
and Philip Chimento <philip.chimento@gmail.com>
at <https://savannah.gnu.org/bugs/index.php?60027>.
* gettext-tools/src/str-list.h (string_list_append_move): New declaration.
* gettext-tools/src/str-list.c (string_list_append_move): New function.
* gettext-tools/src/x-javascript.h (x_javascript_tag): New declaration.
* gettext-tools/src/x-javascript.c: Include str-list.h.
(tag_step1_fn): New type.
(gnome_step1, get_tag_step1_fn): New functions.
(struct tag_definition): New type.
(tags): New variable.
(x_javascript_tag): New function.
(struct token_ty): Add fields template_tag, template_parts.
(free_token): Update.
(struct level_info): New type.
(levels): Change element type to 'struct level_info'.
(new_level, level_type): Update.
(phase5_get, x_javascript_lex): Arrange to collect the parts of a template
literal in the last token's template_parts field.
(extract_balanced): Handle tagged template literals.
* gettext-tools/src/xgettext.c (long_options): Add option --tag.
(main): Handle option --tag.
(usage): Document ption --tag.
* gettext-tools/tests/xgettext-javascript-13: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
* gettext-tools/doc/gettext.texi (No string concatenation): Mention the tagged
template literals as alternative.
* gettext-tools/doc/xgettext.texi: Document the --tag option.
* gettext-tools/doc/lang-javascript.texi (JavaScript): Mention the tagged
template literals syntax.
* NEWS: Mention the change.
Reported by whiteinge <gnu-savannah@eseth.com>
at <https://savannah.gnu.org/bugs/?58407>
and by tuberry and Gianni Lerro <glerro@pm.me>
at <https://savannah.gnu.org/bugs/?62203>.
* gettext-tools/src/x-javascript.c (enum level_ty): New enum.
(levels, levels_alloc, level): New variables.
(new_level): New function.
(level_type): New macro.
(template_literal_depth, brace_depths, brace_depths_alloc): Remove variables.
(new_brace_depth_level): Remove function.
(xml_element_depth, inside_embedded_js_in_xml): Remove variables.
(phase5_get): Use the levels stack instead of the separate stack for braces and
XML.
(extract_javascript): Update.
* gettext-tools/tests/xgettext-javascript-6: Add test cases that mix JSX with
template literals.
* gettext-tools/src/x-php.c (process_dquote_or_heredoc): New function, extracted
from process_heredoc.
(process_heredoc): Allocate a php_extractor on the stack. Invoke
process_dquote_or_heredoc.
(phase4_get): Invoke process_dquote_or_heredoc.
Bruno Haible [Thu, 26 Sep 2024 00:30:57 +0000 (02:30 +0200)]
Modernize: Use gnulib's string-buffer module for accumulating strings.
* autogen.sh (GNULIB_MODULES_RUNTIME_FOR_SRC, GNULIB_MODULES_TOOLS_FOR_SRC): Add
xstring-buffer.
* gettext-runtime/src/envsubst.c: Include string-buffer.h.
(subst_from_stdin): Use a stack-allocated string_buffer instead of 3 local
variables and micro-optimized ad-hoc code.
* gettext-tools/src/cldr-plural.y: Include string-buffer.h.
(yylex): Use a stack-allocated string_buffer instead of 3 local variables and
micro-optimized ad-hoc code.
* gettext-tools/src/cldr-plurals.c: Include string-buffer.h instead of xalloc.h.
(extract_rules): Use a stack-allocated string_buffer instead of 3 local
variables and micro-optimized ad-hoc code.
* gettext-tools/src/its.c: Include string-buffer.h.
(_its_collect_text_content): Use a stack-allocated string_buffer instead of 3
local variables and micro-optimized ad-hoc code.
* gettext-tools/src/read-desktop.c: Include string-buffer.h.
(desktop_lex): Use a stack-allocated string_buffer instead of 3 local variables
and micro-optimized ad-hoc code.
* gettext-tools/src/read-properties.c: Include string-buffer.h.
(properties_parse): Use a stack-allocated string_buffer instead of 3 local
variables and micro-optimized ad-hoc code.
* gettext-tools/src/x-awk.c: Include string-buffer.h.
(phase2_getc, phase3_get): Use a stack-allocated string_buffer instead of 3
local variables and micro-optimized ad-hoc code.
* gettext-tools/src/x-c.c: Include string-buffer.h.
(phase5_get): Use a stack-allocated string_buffer instead of 3 local variables
and micro-optimized ad-hoc code.
* gettext-tools/src/x-java.c: Include string-buffer.h.
(phase5_get): Use a stack-allocated string_buffer instead of 3 local variables
and micro-optimized ad-hoc code.
* gettext-tools/src/x-javascript.c: Include string-buffer.h.
(phase5_get): Use a stack-allocated string_buffer instead of 3 local variables
and micro-optimized ad-hoc code.
* gettext-tools/src/x-lua.c: Include string-buffer.h.
(string_buf_length, string_buf_alloc, string_buf): Remove variables.
(string_start, string_add, string_end): Remove functions.
(phase3_get): Use a stack-allocated string_buffer instead of 3 local variables
and micro-optimized ad-hoc code.
* gettext-tools/src/x-perl.c: Include string-buffer.h.
(get_here_document, phase2_getc, extract_quotelike_pass1,
extract_quotelike_pass3, extract_variable, interpolate_keywords, x_perl_prelex):
Use a stack-allocated string_buffer instead of 3 local variables and
micro-optimized ad-hoc code.
* gettext-tools/src/x-php.c: Include string-buffer.h.
(process_heredoc, phase4_get): Use a stack-allocated string_buffer instead of 3
local variables and micro-optimized ad-hoc code.
* gettext-tools/src/x-python.c: Include string-buffer.h.
(phase5_get): Use a stack-allocated string_buffer instead of 3 local variables
and micro-optimized ad-hoc code.
* gettext-tools/src/x-rst.c: Include string-buffer.h.
(buffer, bufmax): Remove variables.
(buffer): New variable.
(extract_rst, parse_integer): Use a stack-allocated string_buffer instead of 3
local variables and micro-optimized ad-hoc code.
(extract_rsj): Update.
* gettext-tools/src/x-smalltalk.c: Include string-buffer.h.
(phase2_get): Use a stack-allocated string_buffer instead of 3 local variables
and micro-optimized ad-hoc code.
* gettext-tools/src/x-vala.c: Include string-buffer.h.
(phase3_get): Use a stack-allocated string_buffer instead of 3 local variables
and micro-optimized ad-hoc code.
* gettext-tools/src/x-ycp.c: Include string-buffer.h.
(phase2_getc, phase5_get): Use a stack-allocated string_buffer instead of 3
local variables and micro-optimized ad-hoc code.
Bruno Haible [Sat, 21 Sep 2024 13:11:51 +0000 (15:11 +0200)]
PHP: Support newer format string directives.
Reported by José Luis Jiménez Fernández <jjimenez@interhost.com> in
<https://lists.gnu.org/archive/html/bug-gettext/2023-05/msg00037.html>.
* gettext-tools/src/format-php.c (format_parse): Treat E, F, g, G, h, H like
e, f.
* gettext-tools/tests/format-php-1: Test the %E, %F, %g, %G, %h, %H directives.
* gettext-tools/tests/format-php-2: Update type compatibility tests.
* NEWS: Mention the change.
Bruno Haible [Sat, 21 Sep 2024 11:05:16 +0000 (13:05 +0200)]
xgettext: PHP: Support heredoc and nowdoc strings.
Reported:
by Bodo Graumann <mail@bodograumann.de> at <https://savannah.gnu.org/bugs/?27740>,
at <https://savannah.gnu.org/bugs/?35944>,
by Cédric Anne <canne@teclib.com> at <https://savannah.gnu.org/bugs/?62158>.
* gettext-tools/src/x-php.c (TAB_WIDTH): New macro.
(process_heredoc): New function.
(phase4_get): Process the heredoc or nowdoc string, instead of blindly skipping
it.
* gettext-tools/tests/xgettext-php-1: Add tests of heredoc strings with embedded
expressions.
* gettext-tools/tests/xgettext-php-2: Expect spaces before a heredoc end label
to be eaten. Add tests of heredoc strings and nowdoc strings.
* NEWS: Mention the improvement.
Bruno Haible [Thu, 19 Sep 2024 21:26:28 +0000 (23:26 +0200)]
doc: Expand section about preparing strings.
* gettext-tools/doc/gettext.texi (Triggering): Mention a few more Gnulib
modules.
(Preparing Strings): Turn subheadings into subsections.
(No string concatenation): Mention string concatenation operators and
strings with embedded expressions in various programming languages.
* NEWS: Mention it.
Bruno Haible [Thu, 19 Sep 2024 10:34:02 +0000 (12:34 +0200)]
xgettext: Perl: Report warnings instead of fatal errors.
* gettext-tools/doc/lang-perl.texi (Interpolation I, Interpolation II): Say
"unsupported" instead of "invalid". Say "warning" instead of "fatal error".
* gettext-tools/doc/gettext.texi: Update menu.
* gettext-tools/src/x-perl.c (token_type_string_interpol): New enum item.
(token2string): Handle token_type_string_interpol.
(extract_quotelike_pass3): Remove error_level parameter; use IF_SEVERITY_WARNING
instead. Say "unsupported" instead of "invalid". When encountering an
unsupported variable interpolation, change the token's type to
token_type_string_interpol.
(interpolate_keywords): After calling extract_quotelike_pass3, test the token's
type.
(prefer_regexp_over_division): Handle token_type_string_interpol.
(collect_message): Remove error_level parameter; use IF_SEVERITY_WARNING
instead. After calling extract_quotelike_pass3, test the token's type. Possibly
return NULL.
(extract_balanced): Handle token_type_string_interpol. Test the return value of
collect_message.
* NEWS: Mention the change.
Bruno Haible [Wed, 18 Sep 2024 15:00:04 +0000 (17:00 +0200)]
xgettext: C#: Recognize strings with embedded expressions.
* gettext-tools/src/x-csharp.c (token_type_template, token_type_ltemplate,
token_type_mtemplate, token_type_rtemplate): New enum items.
(free_token): Treat token_type_template like token_type_string_literal.
(accumulate_escaped): Accept a second delimiter argument. Return the delimiter.
(template_literal_depth, brace_depths, brace_depths_alloc): New variables,
copied from x-javascript.c.
(new_brace_depth_level): New function, copied from x-javascript.c.
(phase6_get): Recognize strings with embedded expressions. Handle braces in a
nested manner.
(extract_parenthesized): Handle the token types token_type_template,
token_type_ltemplate, token_type_mtemplate, token_type_rtemplate.
(extract_csharp): Initialize template_literal_depth and call
new_brace_depth_level.
* gettext-tools/tests/xgettext-csharp-5: Add tests of strings with embedded
expressions.
* NEWS: Mention the change.