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.
Bruno Haible [Fri, 2 Aug 2024 20:33:13 +0000 (22:33 +0200)]
Refactor: Don't use po_gram_error_at_line outside the PO file reader.
* gettext-tools/src/msgcmp.c: Include po-xerror.h, xvasprintf.h.
(match_domain, compare): Use po_xerror, po_xerror2 instead of
po_gram_error_at_line.
* gettext-tools/src/msgfmt.c: Include po-xerror.h.
(msgfmt_set_domain): Use po_xerror instead of po_gram_error_at_line.
* gettext-tools/src/msgmerge.c: Include xvasprintf.h.
(match_domain): Use po_xerror, po_xerror2 instead of po_gram_error_at_line.
* gettext-tools/src/read-catalog.c (default_set_domain): Use po_xerror instead
of po_gram_error_at_line.
* gettext-tools/src/xgettext.c: Include po-xerror.h.
(exclude_directive_domain): Use po_xerror instead of po_gram_error_at_line.
Bruno Haible [Thu, 1 Aug 2024 21:08:21 +0000 (23:08 +0200)]
Remove some uses of global variable gram_pos.
* gettext-tools/src/msgfmt.c (msgfmt_comment_special): Use the file name from
the catalog reader instead of gram_pos.
* gettext-tools/src/read-desktop.c (gram_pos): Remove declaration.
(pos): New variable.
(phase2_getc, phase2_ungetc, desktop_lex, desktop_parse): Use it instead of
gram_pos.
* gettext-tools/src/read-properties.c (gram_pos): Remove declaration.
(pos): New variable.
(phase2_getc, phase2_ungetc, phase4_getuc, read_escaped_string,
properties_parse): Use it instead of gram_pos.
* gettext-tools/src/read-stringtable.c (gram_pos): Remove declaration.
(pos): New variable.
(phase3_getc, phase3_ungetc, stringtable_parse): Use it instead of gram_pos.
(read_string): Likewise. Rename a parameter.
(conv_from_ucs4): Rename a local variable.
Bruno Haible [Thu, 1 Aug 2024 15:27:36 +0000 (17:27 +0200)]
build: Enable Automake's dependency tracking.
Quite often, after changing a struct defined in a .h file, I see "make check"
fail. After "make clean; make", "make check" passes again. This wastes my time.
Unlike 20 years ago, I don't want think about which .o files I need to erase
and rebuild. Build times are now much smaller than they were 20 years ago,
especially when configuring with --disable-shared and CFLAGS="-ggdb".
Bruno Haible [Sun, 28 Jul 2024 20:00:01 +0000 (22:00 +0200)]
Refactor: Rename local variables of type '*_catalog_reader_ty *'.
* gettext-tools/src/xgettext.c (read_exclusion_file): Rename local variable
'pop' to 'catr'.
* gettext-tools/src/read-catalog.c (read_catalog_stream): Rename local variable
'pop' to 'dcatr'.
Bruno Haible [Sun, 28 Jul 2024 18:34:25 +0000 (20:34 +0200)]
Refactor read-catalog-special.[hc], part 2.
* gettext-tools/src/read-catalog.c: Include read-catalog-special.h.
* gettext-tools/src/xg-message.c: Include read-catalog-special.h instead of
read-catalog-abstract.h.
* gettext-tools/src/x-ruby.c: Likewise.
Bruno Haible [Sun, 28 Jul 2024 12:29:22 +0000 (14:29 +0200)]
Refactor.
Rename the parameter of type 'abstract_catalog_reader_ty *' to catr.
Rename the parameter of type 'default_catalog_reader_ty *' to dcatr.
Rename the parameter of type 'msgfmt_catalog_reader_ty *' to mcatr.
* gettext-tools/src/read-catalog-abstract.h (abstract_catalog_reader_class_ty):
Change first parameter name of all methods.
(struct catalog_input_format): Likewise.
(catalog_reader_parse, catalog_reader_free): Change first parameter name.
* gettext-tools/src/read-catalog-abstract.c (catalog_reader_alloc): Rename local
variable 'pop'.
(catalog_reader_free, call_parse_brief, call_parse_debrief,
call_directive_domain, call_directive_message, call_comment, call_comment_dot,
call_comment_filepos, call_comment_special, parse_start, parse_end,
catalog_reader_parse): Change first parameter name.
* gettext-tools/src/read-catalog.h (default_constructor, default_destructor,
default_parse_brief, default_parse_debrief, default_directive_domain,
default_directive_message, default_comment, default_comment_dot,
default_comment_filepos, default_comment_special, default_set_domain,
default_add_message): Change first parameter name.
* gettext-tools/src/read-catalog.c (call_set_domain, call_add_message,
call_frob_new_message, default_constructor, default_destructor,
default_parse_brief, default_parse_debrief, default_copy_comment_state,
default_reset_comment_state, default_directive_domain,
default_directive_message, default_comment, default_comment_dot,
default_comment_filepos, default_comment_special, default_set_domain,
default_add_message): Change first parameter name.
* gettext-tools/src/msgfmt.c (msgfmt_constructor, msgfmt_parse_debrief,
msgfmt_set_domain, msgfmt_add_message, msgfmt_frob_new_message,
msgfmt_comment_special): Change first parameter name.
(read_catalog_file_msgfmt): Rename local variable 'pop'.
* gettext-tools/src/x-po.c (extract): Rename local variable 'pop'.
* gettext-tools/src/xgettext.c (exclude_directive_domain,
exclude_directive_message): Change first parameter name.
* gettext-tools/src/read-po.c (po_parse): Change first parameter name.
* gettext-tools/src/read-properties.c (properties_parse): Likewise.
* gettext-tools/src/read-stringtable.c (stringtable_parse): Likewise.
Bruno Haible [Sat, 27 Jul 2024 19:05:27 +0000 (21:05 +0200)]
xgettext: PO: Fix error when a --exclude-file option is present (regression 2023-03-10).
Reported by Nicolas Peugnet <n.peugnet@free.fr> via Santiago Vila
at <https://lists.gnu.org/archive/html/bug-gettext/2024-07/msg00030.html>.
* gettext-tools/src/x-po.c (extract_add_message): If the message is the header
entry and is among the messages to exclude, save the header charset from it
before discarding it.
* gettext-tools/tests/xgettext-po-5: New file, based on
gettext-tools/tests/xgettext-po-3.
* gettext-tools/tests/Makefile.am (TESTS): Add it.