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.
Bruno Haible [Sat, 27 Jul 2024 17:12:51 +0000 (19:12 +0200)]
xgettext: Vala: Improve the support of the method .printf().
* gettext-tools/src/x-vala.c (enum token_type_ty): New enum item
token_type_compound_assign.
(phase3_get): Recognize the compound assignment operators as
token_type_compound_assign instead of token_type_assign.
(extract_balanced): Invoke new_sub_region instead of inheriting_region. Invoke
set_format_flag_on_region instead of iterating through the region. When
encountering an operator, close the inner_region and open a new inner_region.
After 'return', use the passthrough_context_list_iterator, not the
null_context_list_iterator.
* gettext-tools/tests/xgettext-vala-6: Add many more test cases.
Bruno Haible [Sat, 27 Jul 2024 14:32:16 +0000 (16:32 +0200)]
xgettext: Java: Improve the support of the method .formatted().
* gettext-tools/src/x-java.c (enum token_type_ty): New enum items
token_type_conditional, token_type_colon, token_type_assign,
token_type_operator.
(phase5_get): Recognize all kinds of operators that may occur in expressions.
(extract_parenthesized): Invoke new_sub_region instead of inheriting_region.
Handle 'return' keyword specially. Invoke set_format_flag_on_region instead of
iterating through the region. When encountering an operator, close the
inner_region and open a new inner_region.
* gettext-tools/tests/xgettext-java-8: Add many more test cases.
Bruno Haible [Sun, 21 Jul 2024 16:24:48 +0000 (18:24 +0200)]
doc: Small updates.
* DEPENDENCIES: Document --with-libncurses-prefix instead of
--with-ncurses-prefix, since that is what the option would be if
AC_LIB_LINKFLAGS_BODY([ncurses]) was actually in use.
* HACKING: Stop suggesting Java 7 implementations, since Java 7 support has
ended. Suggest to create 3 more locales, needed to avoid SKIPs of gnulib tests.
Bruno Haible [Tue, 16 Jul 2024 03:24:27 +0000 (05:24 +0200)]
Find the Objective-C compiler out-of-the-box on AlmaLinux 9 systems.
* gettext-tools/configure.ac: Invoke AC_PROG_OBJC with a customized search list.
* gettext-tools/tests/init-env.in (OBJC, OBJCFLAGS): Set to the configure-
determined values.
* gettext-tools/tests/lang-objc: Use OBJC instead of CC, and OBJCFLAGS instead
of CFLAGS.
* gettext-tools/examples/hello-objc/configure.ac: Invoke AC_PROG_OBJC with a
customized search list. Don't invoke AC_PROC_CC.
Bruno Haible [Mon, 1 Jul 2024 11:26:43 +0000 (13:26 +0200)]
msgunfmt: Fix msgunfmt-tcl-1 failure with tcl version 9.0 beta2.
Reported by Jeffrey Cliff <jeffrey.cliff@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gettext/2024-07/msg00000.html>.
* gettext-tools/src/msgunfmt.tcl: Access the ::msgcat::header variable through
an absolute name syntax, not a relative name syntax.
Rationale: <https://core.tcl-lang.org/tcl/wiki?name=Migrating+scripts+to+Tcl+9>
says:
"In Tcl 8 variable names that are not absolute are resolved by looking
first in the current namespace, and then in the global namespace.
In Tcl 9 such variables are always interpreted as relative to the current
namespace."
Bruno Haible [Mon, 10 Jun 2024 18:59:55 +0000 (20:59 +0200)]
Modernize Java compiler invocations.
The currently used Java version in the industry is Java 8 or newer, since 2022.
See <https://en.wikipedia.org/wiki/Java_version_history>. And on macOS 11..13,
I'm seeing the "error: Source option 6 is no longer supported. Use 8 or later."
* gettext-runtime/configure.ac: Search for a Java compiler with source and
target 1.8.
* gettext-tools/configure.ac: Search for a Java compiler with source 1.8.
* gettext-tools/examples/hello-java/configure.ac: Likewise.
* gettext-tools/examples/hello-java-awt/configure.ac: Likewise.
* gettext-tools/examples/hello-java-swing/configure.ac: Likewise.
Bruno Haible [Wed, 28 Feb 2024 22:15:35 +0000 (23:15 +0100)]
libtextstyle: Avoid crashing the terminal emulator when using ncurses.
Reported by Adriaan de Groot <adridg@freebsd.org> in
<https://lists.gnu.org/archive/html/bug-gettext/2021-12/msg00023.html>.
Long explanation: <https://euroquis.nl/freebsd/2021/11/24/bison.html>
* libtextstyle/gnulib-local/lib/term-ostream.oo.c (out_data_string,
out_data_string_unchecked): New functions.
(out_hyperlink_change): Don't use tputs on strings that are not escape
sequences.
Bruno Haible [Mon, 26 Feb 2024 19:26:13 +0000 (20:26 +0100)]
build: Improve handling of divergences between gnulib and gettext.
* autogen.sh: Detect divergence also of gettext.m4, nls.m4, progtest.m4.
When there is a divergence without a serial number bump, assume it's a copyright
year update and copy the file from gnulib to gettext.
Bruno Haible [Mon, 19 Feb 2024 22:25:12 +0000 (23:25 +0100)]
Remove support for OS/2 (based on EMX directly).
Nowadays, KO Myung-Hun <komh78@gmail.com> uses an approach based on kLIBC
instead of emx+gcc. This kLIBC (https://github.com/bitwiseworks/libc) contains
iconv already.
Bruno Haible [Wed, 14 Feb 2024 23:00:56 +0000 (00:00 +0100)]
Don't treat Apple's new Citrus/FreeBSD-based iconv like GNU libiconv.
* libtextstyle/gnulib-local/lib/iconv-ostream.oo.c (iconv_ostream::write_mem):
Don't treat the bastard Apple iconv like GNU libiconv.
* gettext-tools/src/po-charset.c (po_lex_charset_set): Likewise.
Bruno Haible [Mon, 29 Jan 2024 10:05:57 +0000 (11:05 +0100)]
libtextstyle: Update a few URLs.
* libtextstyle/doc/libtextstyle.texi (Terminal emulators): Update URL. From
Simon Sobisch.
(Style rules): Update URL.
(Hyperlinks): Reference new state-of-the-art document. From Simon Sobisch.
Bruno Haible [Mon, 29 Jan 2024 09:32:34 +0000 (10:32 +0100)]
intl: Revert "Add special hack for GCC" from 2022-06-21.
The added option --enable-host-shared has the same effect as the
libtool-provided option --with-pic, and gcc's Makefile.def actually
uses --with-pic, not --enable-host-shared.
* gettext-runtime/intl/configure.ac: Don't accept option --enable-host-shared.
Don't set PICFLAG.
* gettext-runtime/intl/Makefile.am (AM_CFLAGS): Remove the PICFLAG.
* gnulib-local/modules/gettext-runtime-intl-misc (Makefile.am): Remove the
PICFLAG from AM_CFLAGS.
Bruno Haible [Mon, 8 Jan 2024 05:51:40 +0000 (06:51 +0100)]
intl: Fix the Windows MUI code, so that it works on Windows 10.
Reported by <lrn1986@gmail.com> at <https://savannah.gnu.org/bugs/?65128>.
* gettext-runtime/intl/langprefs.c (_nl_language_preferences_win32_mui): Make
GetUserPreferredUILanguages prototype with Microsoft's current documentation.
Allow the first GetUserPreferredUILanguages call to succeed.
Bruno Haible [Tue, 5 Dec 2023 15:07:38 +0000 (16:07 +0100)]
xgettext: Java: Flag strings on which the method 'formatted' is used as java-printf-format.
* gettext-tools/src/x-java.c (token_type_semicolon): New enum item.
(phase5_get): Recognize semicolon tokens.
(extract_parenthesized): Handle method invocation .formatted. Return when a
semicolon was seen.
* gettext-tools/tests/xgettext-java-8: New file, based on
gettext-tools/tests/xgettext-vala-6.
* gettext-tools/tests/xgettext-java-9: New file, based on
gettext-tools/tests/xgettext-vala-7.
* gettext-tools/tests/Makefile.am (TESTS): Add them.
* NEWS: Mention the change.
Bruno Haible [Tue, 5 Dec 2023 13:15:42 +0000 (14:15 +0100)]
xgettext: Python: Add support for f-strings.
Reported by Ben <gnu@mail.qoben.com>
at <https://savannah.gnu.org/bugs/?61596>.
* gettext-tools/src/x-python.c (P7_498_START_OF_EXPRESSION): New macro.
(token_type_498, token_type_l498, token_type_m498, token_type_r498): New enum
items.
(free_token): Treat token_type_498 like token_type_string.
(phase7_getuc): Accept an f_string parameter. Use it to combine {{ to { and
}} to }.
(f_string_depth): New variable.
(struct f_string_level): New type.
(f_string_stack, f_string_stack_alloc): New variables.
(new_f_string_level): New function.
(open_pb): Renamed from open_pbb.
(phase5_get): Consider also the f_string_stack. Accept f"...", fr"...", rf"..."
syntax. Recognize tokens of type token_type_498, token_type_l498,
token_type_m498, token_type_r498.
(x_python_lex): Treat token_type_498 like token_type_string.
(extract_balanced): Handle the new token types.
(extract_python): Initialize f_string_depth and the f_string_stack.
* gettext-tools/tests/xgettext-python-1: Test also the backslash handling in
f-strings.
* gettext-tools/tests/xgettext-python-8: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
* gettext-tools/doc/lang-python.texi (Python): Explain the limitations of
f-string support.
* NEWS: Mention the change.
Bruno Haible [Thu, 30 Nov 2023 16:16:36 +0000 (17:16 +0100)]
xgettext: Vala: Flag strings on which the method 'printf' is used as c-format.
* gettext-tools/src/x-vala.c (token_type_semicolon): New enum item.
(phase3_get): Recognize semicolon tokens.
(phase4_pushback, phase4_pushback_length): New variables.
(phase4_get): Renamed from x_vala_lex. Handle pushback.
(phase4_unget, x_vala_lex, x_vala_unlex): New functions.
(extract_balanced): Handle method invocations .printf and .vprintf. Return when
a semicolon was seen.
(extract_vala): Initialize phase4_pushback_length.
* gettext-tools/tests/xgettext-vala-6: Add tests for printf used as method.
* gettext-tools/tests/xgettext-vala-7: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
* NEWS: Mention the change.
Bruno Haible [Thu, 30 Nov 2023 15:55:42 +0000 (16:55 +0100)]
xgettext: Vala: Don't flag printf arguments as c-format.
Reported by Anders Jonsson <anders.jonsson@norsjovallen.se>
at <https://savannah.gnu.org/bugs/?64921>.
* gettext-tools/src/xgettext.c (xgettext_record_flag: Recognize also
"undecided-...-format".
* gettext-tools/src/x-vala.c (init_flag_table_vala): Flag the printf function as
'undecided-c-format', not 'c-format'.
* gettext-tools/tests/xgettext-vala-5: Use vprintf instead of printf.
* gettext-tools/tests/xgettext-vala-6: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Thu, 30 Nov 2023 07:43:16 +0000 (08:43 +0100)]
xgettext: Refactor the formatstring code.
* gettext-tools/src/xg-formatstring.h (NXFORMATS, XFORMAT_PRIMARY,
XFORMAT_SECONDARY, XFORMAT_TERTIARY, XFORMAT_FOURTH): New macros.
(current_formatstring_parser1, current_formatstring_parser2,
current_formatstring_parser3, current_formatstring_parser4): Remove
declarations.
(current_formatstring_parser): New declaration.
* gettext-tools/src/xg-formatstring.c (current_formatstring_parser1,
current_formatstring_parser2, current_formatstring_parser3,
current_formatstring_parser4): Remove variables.
(current_formatstring_parser): New variable.
* gettext-tools/src/xg-arglist-context.h: Include xg-formatstring.h.
(struct formatstring_context_ty): New type.
(struct flag_context_ty): Replace individual fields with an array.
(flag_context_list_table_add): Rename parameter 'index' to 'fi'.
* gettext-tools/src/xg-arglist-context.c (null_context, passthrough_context):
Update.
(inherited_context): Loop over the four formatstring types.
(passthrough_context_circular_list): Update.
(set_flags_for_formatstring_type): Simplify.
(flag_context_list_table_add): Rename parameter 'index' to 'fi'.
* gettext-tools/src/xg-arglist-parser.c (arglist_parser_done): Update.
* gettext-tools/src/xg-message.c (set_format_flags_from_context): Loop over the
four formatstring types.
(is_relevant): New function.
(decide_is_format, remember_a_message_plural): Use it.
* gettext-tools/src/xgettext.c (struct extractor_ty): Replace individual fields
with an array.
(main): Update.
(flag_context_list_table_insert): Rename parameter 'index' to 'fi'.
(xgettext_record_flag): Use XFORMAT_* macros.
(extract_from_file): Loop over the four formatstring types.
(recognize_qt_formatstrings): Update.
(language_to_extractor): Use XFORMAT_* macros and a loop.