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.
Bruno Haible [Mon, 16 Sep 2024 16:43:22 +0000 (18:43 +0200)]
build: Fix "make distcheck" after the line-breaking algorithm changed.
* gettext-runtime/po/Makefile.in.in (.po.gmo, $(POFILES)): In the gettext-tools
package, when not cross-compiling, use the locally built msg* programs.
* gettext-tools/configure.ac: When not cross-compiling, set MSGMERGE and
MSGMERGE_FOR_MSGFMT_OPTION to point to locally built msgmerge program.
Bruno Haible [Wed, 11 Sep 2024 12:09:34 +0000 (14:09 +0200)]
xgettext: awk: Recognize string concatenation.
* gettext-tools/src/x-awk.c (SIZEOF): New macro.
(phase3_pushback, phase3_pushback_length): New variables.
(phase3_get): Renamed from x_awk_lex. Return pushed-back token if present.
(phase3_unget): New function.
(string_concat_free1): New function.
(phase4_get): New function.
(extract_parenthesized): Invoke phase4_get instead of x_awk_lex.
(extract_awk): Initialize phase3_pushback_length.
* gettext-tools/tests/xgettext-awk-1: Add test cases for string concatenation.
* NEWS: Mention the improvement.
* gettext-tools/src/x-smalltalk.c (struct token_ty): Add field 'comment'.
(free_token): New function.
(phase2_get): Fill in tp->comment.
(phase3_pushback): Increase size.
(phase3_get): Fill in tp->comment. Do reference counting.
(string_concat_free1): New function.
(phase4_pushback, phase4_pushback_length): New variables.
(phase4_get, phase4_unget): New functions.
(extract_smalltalk): Initialize phase4_pushback_length. Call phase4_get instead
of phase3_get, phase4_unget instead of phase3_unget. Use the comment stored in
the token. Call free_token.
* gettext-tools/tests/xgettext-smalltalk-1: Add a test case of string
concatenation.
* NEWS: Mention the improvement.
Bruno Haible [Wed, 11 Sep 2024 12:09:08 +0000 (14:09 +0200)]
xgettext: Refactor.
* gettext-tools/src/x-awk.c (SE_QUOTES): Renamed from P7_QUOTES.
(get_string_element): Renamed from phase7_getc.
(x_awk_lex): Update.
* gettext-tools/src/x-c.c (SE_EOF): Renamed from P7_EOF.
(SE_QUOTES): Renamed from P7_QUOTES.
(SE_QUOTE): Renamed from P7_QUOTE.
(SE_NEWLINE): Renamed from P7_NEWLINE.
(get_string_element): Renamed from phase7_getc.
(unget_string_element): Renamed from phase7_ungetc.
(phase5_get): Update.
* gettext-tools/src/x-vala.c (SE_EOF): Renamed from P7_EOF.
(SE_QUOTES): Renamed from P7_QUOTES.
(SE_QUOTE): Renamed from P7_QUOTE.
(SE_NEWLINE): Renamed from P7_NEWLINE.
(get_string_element): Renamed from phase7_getc.
(unget_string_element): Renamed from phase7_ungetc.
(phase3_get): Update.
* gettext-tools/src/x-ycp.c (SE_QUOTES): Renamed from P7_QUOTES.
(get_string_element): Renamed from phase7_getc.
(phase5_get): Update.
Bruno Haible [Tue, 10 Sep 2024 01:58:05 +0000 (03:58 +0200)]
xgettext: C: Fix undefined behaviour.
* gettext-tools/src/x-c.c (phase7_getc): Declare n as 'unsigned int', to avoid
signed integer overflow.
* gettext-tools/tests/xg-c-escape-3.c: Add two more test cases.
* gettext-tools/tests/xgettext-c-escape-3: Update expected test result.
Bruno Haible [Sun, 8 Sep 2024 15:25:27 +0000 (17:25 +0200)]
doc: Update regarding PO file editors.
* gettext-tools/doc/gettext.texi (Editing): Add some text.
(Web based localization): New section.
(Lokalize): Renamed from KBabel. Add some text.
(Gtranslator): Add some text.
(Poedit): New section.
Bruno Haible [Fri, 16 Aug 2024 23:50:27 +0000 (01:50 +0200)]
tests: Improve portability.
* gettext-tools/tests/lang-javascript: Don't use '${DIFF} -u', since AIX diff
does not support the -u option.
* gettext-tools/tests/xgettext-vala-6: Likewise.
Bruno Haible [Fri, 16 Aug 2024 23:29:02 +0000 (01:29 +0200)]
xgettext: Scheme: Recognize hexadecimal escape sequences in string literals.
* gettext-tools/src/x-scheme.c (accumulate_escaped): Recognize \x, \u, \U escape
sequences.
* gettext-tools/tests/xgettext-scheme-7: Test also some \x escape sequences.
* gettext-tools/tests/xgettext-scheme-8: Test also some \x, \u, \U escape
sequences.
Bruno Haible [Fri, 16 Aug 2024 21:44:53 +0000 (23:44 +0200)]
xgettext: Scheme: Prepare for recognizing more escape sequences in string literals.
* gettext-tools/src/x-scheme.c (accumulate_escaped): New function, extracted
from read_object.
(struct object): Add field 'mixed_string'.
(free_object): Free field 'mixed_string'.
(string_of_object): Implement differently for objects of type t_string.
(read_object): Use accumulate_escaped. Invoke mixed_string_alloc_utf8 instead of
mixed_string_alloc_simple.
Bruno Haible [Fri, 16 Aug 2024 20:40:10 +0000 (22:40 +0200)]
xgettext: Scheme: In language Scheme, handle backslash-newline as specified in R6RS.
Reported by Florent Angly <florent.angly@gmail.com>
at <https://savannah.gnu.org/bugs/?59262>.
* gettext-tools/src/x-scheme.c (read_object): Do R6RS-compliant interpretation
of backslash-newline if follow_guile is false.
* gettext-tools/tests/xgettext-scheme-7: New file.
* gettext-tools/tests/xgettext-scheme-8: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.
Bruno Haible [Fri, 16 Aug 2024 20:36:30 +0000 (22:36 +0200)]
xgettext: Scheme: #!fold-case and #!no-fold-case directives.
Reported by Florent Angly <florent.angly@gmail.com>
at <https://savannah.gnu.org/bugs/?61987>.
* autogen.sh (GNULIB_MODULES_TOOLS_FOR_SRC): Add unicase/u8-casefold,
uninorm/nfc.
* gettext-tools/src/x-scheme.c: Include unicase.h, uninorm.h.
(SIZEOF): New macro.
(phase0_getc): Renamed from do_getc. Remove line_number handling.
(phase0_ungetc): Renamed from do_ungetc. Remove line_number handling.
(MAX_PHASE1_PUSHBACK): New macro.
(phase1_pushback, phase1_pushback_length): New variables.
(phase1_getc, phase1_ungetc): New functions.
(casefold): New variable.
(read_token): Use phase1_getc, phase1_ungetc instead of do_getc, do_ungetc.
(read_object): Likewise. If casefold is true, apply Unicode case-folding to
symbols before looking them up in the hash table. Recognize all #! directives
supported by Guile.
(extract_whole_file): Initialize phase1_pushback_length, casefold.
* gettext-tools/tests/xgettext-scheme-6: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Fri, 16 Aug 2024 20:32:58 +0000 (22:32 +0200)]
xgettext: Scheme: Recognize datum-comments.
Reported by Florent Angly <florent.angly@gmail.com>
at <https://savannah.gnu.org/bugs/?61882>.
* gettext-tools/src/x-scheme.c (datum_comment_nesting_depth): New variable.
(read_object): Omit the normal processing of list elements if
datum_comment_nesting_depth is non-zero. Recognize datum comments.
(extract_whole_file): Initialize datum_comment_nesting_depth.
* gettext-tools/tests/xgettext-scheme-1: Add a test case with a datum comment.
* NEWS: Mention the change.
Bruno Haible [Fri, 16 Aug 2024 19:05:47 +0000 (21:05 +0200)]
xgettext: Scheme: Understand both '-L Scheme' and '-L Guile'.
* gettext-tools/src/x-scheme.h (EXTENSIONS_SCHEME): Associate the language
Guile, not Scheme, with the extension .scm.
(SCANNERS_SCHEME): Add info about the 'Guile' language.
(extract_guile): New declaration.
* gettext-tools/src/x-scheme.c (follow_guile): New variable.
(extract_whole_file): Renamed from extract_scheme.
(extract_scheme, extract_guile): New functions.
* gettext-tools/src/xgettext.c (usage): List Guile as a possible argument for
the '-L' option.
* gettext-tools/doc/xgettext.texi: Document 'Guile' as possible argument for
the '-L' option.
* gettext-tools/doc/lang-scheme.texi (Scheme): Explain the difference between
'-L Scheme' and '-L Guile'.
* NEWS: Mention the change.
Bruno Haible [Fri, 16 Aug 2024 14:54:49 +0000 (16:54 +0200)]
msginit: Update information about zh_TW translation team.
Reported by Buug Worm <buugworm@gmail.com>
at <https://savannah.gnu.org/bugs/?66094>.
* gettext-tools/projects/KDE/teams.url: Update URL.
* gettext-tools/projects/KDE/teams.html: Update information about zh_TW
translation team.
* gettext-tools/projects/TP/teams.html: Likewise.
Bruno Haible [Wed, 14 Aug 2024 16:18:37 +0000 (18:18 +0200)]
xgettext: Python: Change escape sequences interpretation to follow Python 3.
Reported by Serhii Tereshchenko <serg.partizan@gmail.com> at
<https://savannah.gnu.org/bugs/?65778>.
* gettext-tools/src/x-python.c (phase7_getuc): Update comments for Python 3.
Don't interpret \u sequences in raw bytes and raw strings.
(phase5_get): Recognize bytes prefixes 'b' and 'B'. For f-strings, invoke
phase7_getuc with interpret_unicode = true, not false.
* gettext-tools/tests/xgettext-python-1: Update for Python 3.
* gettext-tools/tests/xgettext-python-5: Likewise.
* NEWS: Mention the change.
Bruno Haible [Mon, 12 Aug 2024 20:06:10 +0000 (22:06 +0200)]
Improve handling of non-BMP characters with Tcl 9.0.
* gettext-tools/src/write-tcl.c (hexdigit): New variable.
(write_tcl8_string): Renamed from write_tcl_string. Enable the escaping of
braces.
(write_tcl9_string, is_entirely_ucs2, write_tcl_string): New functions.
* gettext-tools/tests/msgfmt-tcl-1: New file.
* gettext-tools/tests/testdata/tcltest_pl.po: New file.
* gettext-tools/tests/testdata/tcltest_pl.msg: New file.
* gettext-tools/tests/msgfmt-tcl-2: New file.
* gettext-tools/tests/testdata/tcltest_cs.po: New file.
* gettext-tools/tests/testdata/tcltest_cs.msg: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add msgfmt-tcl-1, msgfmt-tcl-2.
(EXTRA_DIST): Add the new testdata files.
* NEWS: Mention the change.
Bruno Haible [Wed, 7 Aug 2024 18:04:26 +0000 (20:04 +0200)]
libgettextpo: Use a multithread-safe alternative to strerror().
* autogen.sh (GNULIB_MODULES_LIBGETTEXTPO): Add xstrerror.
* gnulib-local/lib/markup.c: Include xstrerror.h.
(unescape_string_inplace): Use xstrerror instead of strerror.
* gnulib-local/modules/markup (Depends-on): Add xstrerror.
* gettext-tools/src/read-po-lex.c: Include xstrerror.h.
(mbfile_getc, lex_getc): Use xstrerror instead of strerror.
* gettext-tools/src/read-properties.c: Include xstrerror.h.
(properties_parse): Use xstrerror instead of strerror.
* gettext-tools/src/read-stringtable.c: Include xstrerror.h.
(phase1_getc): Use xstrerror instead of strerror.
* gettext-tools/src/write-catalog.c: Include xstrerror.h.
(msgdomain_list_print): Use xstrerror instead of strerror.
Bruno Haible [Sun, 4 Aug 2024 23:32:32 +0000 (01:32 +0200)]
libgettextpo: Make function po_format_list() multithread-safe.
* autogen.sh (GNULIB_MODULES_LIBGETTEXTPO): Add 'once'.
* gettext-tools/libgettextpo/gettext-po.c: Include glthread/once.h.
(all_formats): New variable.
(all_formats_init): New function, extracted from po_format_list.
(all_formats_init_once): New variable.
(po_format_list): Invoke all_formats_init once.
Bruno Haible [Sat, 3 Aug 2024 10:14:48 +0000 (12:14 +0200)]
Add an xerror_handler parameter to check_message and check_message_list.
* gettext-tools/src/msgl-check.h: Include xerror-handler.h.
(check_plural_eval, check_message, check_message_list): Add xerror_handler_ty
parameter.
* gettext-tools/src/msgl-check.c (check_plural_eval, check_plural, check_pair,
check_header_entry, check_message, check_message_list): Add xerror_handler_ty
parameter. Use it for error handling.
(struct formatstring_error_logger_locals): Add xeh field.
(formatstring_error_logger): Use it for error handling.
* gettext-tools/libgettextpo/gettext-po.c: Don't include po-xerror.h.
(po_file_check_all, po_message_check_all): Pass a stack-allocated xerror_handler
to check_message_list.
(po_message_check_format): Pass a stack-allocated xerror_handler to
check_message.
* gettext-tools/src/msgfmt.c (main, msgfmt_operand_list_add_from_directory): Use
the default xerror_handler.
* gettext-tools/src/msgmerge.c (match_domain): Likewise.
Bruno Haible [Sat, 3 Aug 2024 09:40:26 +0000 (11:40 +0200)]
Add an xerror_handler parameter to msgdomain_list_print.
* gettext-tools/src/write-catalog.h: Include xerror-handler.h.
(struct catalog_output_format): Add xerror_handler_ty parameter to the print
method.
(msgdomain_list_print): Add xerror_handler_ty parameter.
* gettext-tools/src/write-catalog.c: Include xerror-handler.h instead of
po-xerror.h.
(msgdomain_list_print): Add xerror_handler_ty parameter. Use it for error
handling.
* gettext-tools/src/write-po.c: Include xerror-handler.h instead of po-xerror.h.
(wrap, message_print, message_print_obsolete, msgdomain_list_print_po): Add
xerror_handler_ty parameter. Use it for error handling.
* gettext-tools/src/write-properties.c: Include xerror-handler.h.
(write_properties, msgdomain_list_print_properties): Add xerror_handler_ty
parameter. Use it for error handling.
* gettext-tools/src/write-stringtable.c: Include xerror-handler.h.
(write_stringtable, msgdomain_list_print_stringtable): Add xerror_handler_ty
parameter. Use it for error handling.
* gettext-tools/libgettextpo/gettext-po.c (po_file_write): Pass a
stack-allocated xerror_handler to msgdomain_list_print.
* gettext-tools/src/msgl-iconv.h: Include xerror-handler.h.
(iconv_message_list, iconv_msgdomain_list): Add xerror_handler_ty parameter.
* gettext-tools/src/msgl-iconv.c: Include xerror-handler.h instead of
po-xerror.h.
(conversion_error, convert_string, convert_string_list, convert_prev_msgid,
convert_msgid, convert_msgstr, iconv_message_list_internal, iconv_message_list,
iconv_msgdomain_list): Add xerror_handler_ty parameter. Use it for error
handling.
(convert_string_directly, convert_string_desc_directly): Use the default
xerror_handler.
* gettext-tools/src/msgattrib.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msgcat.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msgcmp.c: Include xerror-handler.h.
(compare): Use the default xerror_handler.
* gettext-tools/src/msgcomm.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msgconv.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msgen.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msgfilter.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msgfmt.c: Include xerror-handler.h.
(msgfmt_operand_list_add_from_directory): Use the default xerror_handler.
* gettext-tools/src/msggrep.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msginit.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msgl-cat.c: Include xerror-handler.h.
(catenate_msgdomain_list): Use the default xerror_handler.
* gettext-tools/src/msgmerge.c: Include xerror-handler.h.
(main, merge): Use the default xerror_handler.
* gettext-tools/src/msgunfmt.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msguniq.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/write-csharp.c: Include xerror-handler.h.
(msgdomain_write_csharp): Use the default xerror_handler.
* gettext-tools/src/write-desktop.c: Include xerror-handler.h.
(msgdomain_write_desktop): Use the default xerror_handler.
* gettext-tools/src/write-java.c: Include xerror-handler.h.
(msgdomain_write_java): Use the default xerror_handler.
* gettext-tools/src/write-mo.c: Include xerror-handler.h.
(msgdomain_write_mo): Use the default xerror_handler.
* gettext-tools/src/write-qt.c: Include xerror-handler.h.
(msgdomain_write_qt): Use the default xerror_handler.
* gettext-tools/src/write-resources.c: Include xerror-handler.h.
(msgdomain_write_csharp_resources): Use the default xerror_handler.
* gettext-tools/src/write-tcl.c: Include xerror-handler.h.
(msgdomain_write_tcl): Use the default xerror_handler.
* gettext-tools/src/write-xml.c: Include xerror-handler.h.
(msgdomain_write_xml): Use the default xerror_handler.
* gettext-tools/src/x-po.c (extract): Use the default xerror_handler.
* gettext-tools/src/xgettext.c: Include xerror-handler.h.
(main, finalize_header): Use the default xerror_handler.
Bruno Haible [Sat, 3 Aug 2024 01:11:18 +0000 (03:11 +0200)]
Add an xerror_handler parameter to read_catalog_stream.
* gettext-tools/src/read-catalog-abstract.h: Include xerror-handler.h.
(ABSTRACT_CATALOG_READER_TY): Add xeh field.
(catalog_reader_alloc): Add xerror_handler parameter.
* gettext-tools/src/read-catalog-abstract.c: Include xerror-handler.h instead of
po-xerror.h.
(catalog_reader_alloc): Add xerror_handler parameter.
(catalog_reader_parse): Use catr->xeh for error handling.
* gettext-tools/src/read-catalog.h: Include xerror-handler.h.
(default_catalog_reader_alloc, read_catalog_stream): Add xerror_handler
parameter.
* gettext-tools/src/read-catalog.c: Include xerror-handler.h instead of
po-xerror.h.
(default_set_domain, default_add_message): Use catr->xeh for error handling.
(default_catalog_reader_alloc, read_catalog_stream): Add xerror_handler
parameter.
* gettext-tools/src/read-po-lex.h: Include read-catalog-abstract.h.
(po_gram_error_at_line): Add catr parameter.
* gettext-tools/src/read-po-lex.c: Include xerror-handler.h instead of
po-xerror.h.
(po_gram_error): Use ps->catr->xeh for error handling.
(po_gram_error_at_line): Add catr parameter. Use catr->xeh for error handling.
(po_lex_charset_set, mbfile_getc, lex_getc): Use ps->catr->xeh for error
handling.
(keyword_p, po_gram_lex): Update invocations of po_gram_error_at_line.
* gettext-tools/src/read-po-gram.y: Update invocations of po_gram_error_at_line.
* gettext-tools/src/read-properties.c: Include xerror-handler.h instead of
po-xerror.h.
(phase4_getuc, read_escaped_string): Add catr parameter. Use catr->xeh for error
handling.
(properties_parse): Use catr->xeh for error handling.
* gettext-tools/src/read-stringtable.c: Include xerror-handler.h instead of
po-xerror.h.
(phase1_getc, phase2_getc, phase3_getc): Add catr parameter. Use catr->xeh for
error handling.
(phase4_getc): Update.
(read_string, stringtable_parse): Use catr->xeh for error handling.
* gettext-tools/libgettextpo/gettext-po.c (po_file_read): Pass a stack-allocated
xerror_handler to read_catalog_stream.
* gettext-tools/src/msgfmt.c: Include xerror-handler.h.
(read_catalog_file_msgfmt): Use the default xerror_handler.
* gettext-tools/src/read-catalog-file.c: Include xerror-handler.h.
(read_catalog_file): Use the default xerror_handler.
* gettext-tools/src/read-csharp.c: Include xerror-handler.h.
(execute_and_read_po_output): Use the default xerror_handler.
* gettext-tools/src/read-java.c: Include xerror-handler.h.
(execute_and_read_po_output): Use the default xerror_handler.
* gettext-tools/src/read-resources.c: Include xerror-handler.h.
(execute_and_read_po_output): Use the default xerror_handler.
* gettext-tools/src/read-tcl.c: Include xerror-handler.h.
(msgdomain_read_tcl): Use the default xerror_handler.
* gettext-tools/src/x-po.c: Include xerror-handler.h.
(extract): Use the default xerror_handler.
* gettext-tools/src/xgettext.c: Include xerror-handler.h.
(read_exclusion_file): Use the default xerror_handler.
Bruno Haible [Fri, 2 Aug 2024 22:40:17 +0000 (00:40 +0200)]
Add xerror-handler.
* gettext-tools/src/xerror-handler.h: New file, based on gettext-tools/src/po-xerror.h.
* gettext-tools/src/xerror-handler.c: New file, based on gettext-tools/src/po-xerror.c.
* gettext-tools/src/Makefile.am (noinst_HEADERS): Add xerror-handler.h.
(COMMON_SOURCE): Add xerror-handler.c.
* gettext-tools/src/FILES: Update.
* gettext-tools/woe32dll/gettextsrc-exports.c (textmode_xerror_handler_struct):
New export.