]> git.ipfire.org Git - thirdparty/gettext.git/log
thirdparty/gettext.git
2 years agoxgettext: Support up to 4 format string parsers at the same time.
Bruno Haible [Mon, 5 Jun 2023 10:31:30 +0000 (12:31 +0200)] 
xgettext: Support up to 4 format string parsers at the same time.

* gettext-tools/src/xg-arglist-context.h (struct flag_context_ty): Add fields
is_format4, pass_format4.
* gettext-tools/src/xg-arglist-context.c (null_context, passthrough_context,
inherited_context, passthrough_context_circular_list,
flag_context_list_table_add): Update.
* gettext-tools/src/xg-message.c (set_format_flags_from_context,
decide_is_format, remember_a_message_plural): Update.
* gettext-tools/src/xgettext.h (current_formatstring_parser4): New declaration.
* gettext-tools/src/xgettext.c (struct extractor_ty): Add field
formatstring_parser4.
(current_formatstring_parser4): New variable.
(main, extract_from_file, language_to_extractor): Update.

2 years agoFix libintl exports.
Bruno Haible [Sun, 4 Jun 2023 18:48:28 +0000 (20:48 +0200)] 
Fix libintl exports.

On mingw, rpl_mbrtowc, rpl_mbsinit, hard_locale were exported.
On Cygwin, rpl_mbrtowc, rpl_vasnprintf were exported.

* gettext-runtime/intl/configure.ac: Map more rpl_* symbols to _libintl_*.

2 years agoUpdate to the newest gnulib.
Bruno Haible [Mon, 5 Jun 2023 09:28:53 +0000 (11:28 +0200)] 
Update to the newest gnulib.

2 years agobuild: Don't rename error{_at_line} to rpl_error{_at_line} on native Windows.
Bruno Haible [Sun, 4 Jun 2023 15:34:25 +0000 (17:34 +0200)] 
build: Don't rename error{_at_line} to rpl_error{_at_line} on native Windows.

* gettext-tools/configure.ac (GNULIB_REPLACE_ERROR): Define only on Cygwin and
Android.
* gettext-tools/woe32dll/gettextlib-exports.c: Don't assume that
GNULIB_DEFINED_ERROR implies GNULIB_REPLACE_ERROR.

2 years agobuild: Make the Windows exports lists more maintainable.
Bruno Haible [Sun, 4 Jun 2023 15:33:32 +0000 (17:33 +0200)] 
build: Make the Windows exports lists more maintainable.

* gettext-tools/woe32dll/gettextlib-exports.c: Fix file title.
* gettext-tools/woe32dll/gettextsrc-exports.c: Likewise.
* gettext-tools/woe32dll/gettextpo-exports.c: Likewise.

2 years agobuild: Take advantage of gcc warning options not included in -Wall.
Bruno Haible [Fri, 2 Jun 2023 23:34:14 +0000 (01:34 +0200)] 
build: Take advantage of gcc warning options not included in -Wall.

* autogen.sh (GNULIB_MODULES_RUNTIME_OTHER, GNULIB_MODULES_LIBINTL,
GNULIB_MODULES_LIBASPRINTF, GNULIB_MODULES_TOOLS_OTHER): Add manywarnings.
* m4/more-warnings.m4: New file.

* libtextstyle/autogen.sh (GNULIB_MODULES): Add manywarnings.
Copy also more-warnings.m4.
* gnulib-local/modules/libxml (Makefile.am): New variable libxml_rpl_la_CFLAGS.
* libtextstyle/gnulib-local/modules/libcroco (Makefile.am): New variable
libcroco_rpl_la_CFLAGS.
* libtextstyle/gnulib-local/modules/libglib (Makefile.am): New variable
libglib_rpl_la_CFLAGS.
* libtextstyle/configure.ac: Invoke gt_MORE_WARNINGS, gl_CC_INHIBIT_WARNINGS.
* libtextstyle/lib/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
(config.h): Do the compilations with GL_CFLAG_INHIBIT_WARNINGS.

* gettext-runtime/configure.ac: Invoke gt_MORE_WARNINGS.
* gettext-runtime/src/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
* gnulib-local/modules/gettext-runtime-misc (Makefile.am): Add WARN_CFLAGS to
AM_CFLAGS.

* gettext-runtime/intl/configure.ac: Invoke gt_MORE_WARNINGS.
* gettext-runtime/intl/Makefile.am (AM_CFLAGS): Add WARN_CFLAGS.
* gnulib-local/modules/gettext-runtime-intl-misc (Makefile.am): Add WARN_CFLAGS
to AM_CFLAGS.

* gettext-runtime/libasprintf/configure.ac: Invoke gt_MORE_WARNINGS.
* gettext-runtime/libasprintf/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.

* gettext-tools/configure.ac: Invoke gt_MORE_WARNINGS, gl_CC_INHIBIT_WARNINGS.
* gettext-tools/gnulib-lib/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
* gettext-tools/libgrep/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
* gettext-tools/src/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
* gettext-tools/libgettextpo/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
(config.h): Do the compilations with GL_CFLAG_INHIBIT_WARNINGS.

2 years agoUpdate after gnulib changed.
Bruno Haible [Sun, 4 Jun 2023 18:00:59 +0000 (20:00 +0200)] 
Update after gnulib changed.

* gettext-tools/src/po-error.c (_GL_NO_INLINE_ERROR): New macro.
* gettext-tools/libgettextpo/gettext-po.c (_GL_NO_INLINE_ERROR): Likewise.

2 years agoUpdate to the newest gnulib.
Bruno Haible [Sun, 4 Jun 2023 17:59:02 +0000 (19:59 +0200)] 
Update to the newest gnulib.

2 years agoSilence "inlining failed" warnings.
Bruno Haible [Sat, 3 Jun 2023 12:53:54 +0000 (14:53 +0200)] 
Silence "inlining failed" warnings.

* gettext-tools/src/read-stringtable.c (comment_line_end): Remove 'inline'
marker.
* gettext-tools/src/x-scheme.c (is_other_number_syntax): Likewise.

2 years agoEnable better malloc/free checking in a few cases.
Bruno Haible [Sat, 3 Jun 2023 11:27:03 +0000 (13:27 +0200)] 
Enable better malloc/free checking in a few cases.

Pinpointed by gcc 13 warning:
warning: function might be candidate for attribute 'malloc' [-Wsuggest-attribute=malloc]

* gettext-tools/src/po-time.h: Include attribute.h.
(po_strftime): Mark with attribute 'malloc'.
* gettext-tools/src/write-po.h: Include attribute.h.
(make_range_description_string): Mark with attribute 'malloc'.

2 years agoSilence "potential null pointer dereference" warnings.
Bruno Haible [Sat, 3 Jun 2023 11:56:37 +0000 (13:56 +0200)] 
Silence "potential null pointer dereference" warnings.

Pinpointed by gcc 13 warning:
warning: potential null pointer dereference [-Wnull-dereference]

* gettext-tools/src/xg-arglist-context.c: Include verify.h.
(flag_context_list_table_add): Assert that the entry is non-NULL.

2 years agoSilence "use of possibly-NULL ‘class_name’" warnings.
Bruno Haible [Sat, 3 Jun 2023 12:12:02 +0000 (14:12 +0200)] 
Silence "use of possibly-NULL ‘class_name’" warnings.

* gettext-tools/src/write-java.c: Include verify.h.
(msgdomain_write_java): Assume that this xasprintf call returns non-NULL.

2 years agoSilence "use of possibly-NULL ‘string’ where non-null expected" warning.
Bruno Haible [Fri, 2 Jun 2023 23:33:22 +0000 (01:33 +0200)] 
Silence "use of possibly-NULL ‘string’ where non-null expected" warning.

* gettext-tools/src/write-po.c (make_range_description_string): Assume that this
xasprintf call returns non-NULL.

2 years agoSilence "use of possibly-NULL ‘msgstr’" warnings.
Bruno Haible [Fri, 2 Jun 2023 23:33:08 +0000 (01:33 +0200)] 
Silence "use of possibly-NULL ‘msgstr’" warnings.

* gettext-tools/src/write-po.c: Include verify.h.
(message_print_comment_filepos): Assume that this xasprintf call returns
non-NULL.
* gettext-tools/src/xg-message.c: Include verify.h.
(remember_a_message, remember_a_message_plural): Assume that this xasprintf call
returns non-NULL.
* gettext-tools/src/xgettext.c: Include verify.h.
(construct_header): Assume that this xasprintf call returns non-NULL.

2 years agoSilence "assignment discards ‘const’ qualifier from pointer target type" warnings.
Bruno Haible [Fri, 2 Jun 2023 23:32:23 +0000 (01:32 +0200)] 
Silence "assignment discards ‘const’ qualifier from pointer target type" warnings.

* gettext-tools/src/msginit.c (language_team_address): New local variable
'result'.
(plural_forms): Adjust type of local variable 'dirs'.
* gettext-tools/src/xg-message.c (remember_a_message): Reduce scope and adjust
type of local variable 'msgstr'.
(remember_a_message_plural): New local variable 'msgstr1_malloc'.
* gettext-tools/src/xgettext.c (main): New local variable
'defaulted_output_dir'.

2 years agoSilence "initialization discards ‘const’ qualifier from pointer target type" warnings.
Bruno Haible [Fri, 2 Jun 2023 23:31:33 +0000 (01:31 +0200)] 
Silence "initialization discards ‘const’ qualifier from pointer target type" warnings.

* gettext-tools/src/pos.h (struct lex_pos_ty): Change type of file_name field to
'const char *'.
* gettext-tools/src/read-catalog.c (default_destructor,
default_reset_comment_state): Cast file_name to 'char *' before free()ing it.
* gettext-tools/src/xg-arglist-parser.h (arglist_parser_remember,
arglist_parser_remember_msgctxt): Change type of file_name parameter.
* gettext-tools/src/xg-arglist-parser.c (arglist_parser_remember,
arglist_parser_remember_msgctxt): Likewise.

2 years agoSilence -Wformat warnings regarding 'int' vs. 'unsigned int' arguments.
Bruno Haible [Fri, 2 Jun 2023 23:30:59 +0000 (01:30 +0200)] 
Silence -Wformat warnings regarding 'int' vs. 'unsigned int' arguments.

* gettext-tools/src/read-catalog-abstract.c (catalog_reader_parse): Use %u
instead of %d in format string.
* gettext-tools/src/read-properties.c (UTF16_VALUE): Cast result to
'unsigned short'.
* gettext-tools/src/write-java.c (write_lookup_code,
write_java2_init_statements, write_java_code): Use %u instead of %d in format
strings.
* gettext-tools/src/x-perl.c (extract_balanced): Cast enum-typed fprintf
argument to 'int'.

2 years agoSilence "may write a terminating nul past the end of the destination" warnings.
Bruno Haible [Fri, 2 Jun 2023 23:30:00 +0000 (01:30 +0200)] 
Silence "may write a terminating nul past the end of the destination" warnings.

* gettext-tools/src/write-po.c (message_print_comment_filepos): Increase size of
buffer by 1.
* gettext-tools/src/xg-encoding.c (non_ascii_error_message,
non_utf8_error_message): Likewise.
* gettext-tools/src/xg-message.c (set_format_flags_from_context,
warn_format_string, remember_a_message): Likewise.

2 years agoSilence "this statement may fall through" warnings.
Bruno Haible [Fri, 2 Jun 2023 23:29:33 +0000 (01:29 +0200)] 
Silence "this statement may fall through" warnings.

* gettext-tools/src/x-lua.c: Include attribute.h.
(phase2_getc, phase3_get): Use FALLTHROUGH macro.

2 years agoSilence "missing initializer for field" warnings.
Bruno Haible [Fri, 2 Jun 2023 23:29:19 +0000 (01:29 +0200)] 
Silence "missing initializer for field" warnings.

* gettext-tools/src/xgettext.c (main, language_to_extractor): Initialize all
fields of extractor_ty.

2 years agoSilence "... shadows a previous local" warnings.
Bruno Haible [Fri, 2 Jun 2023 23:28:54 +0000 (01:28 +0200)] 
Silence "... shadows a previous local" warnings.

* gettext-tools/src/its.c (its_rule_apply): Reduce scope of local variable 'i'.
(_its_collect_text_content): Rename local variable 'buffer' to 'obuffer'.
(its_rule_list_extract_nodes): Reduce scope of local variable 'n'.
(_its_get_content): Reduce scope of local variable 'i'. Rename local variable
'i' to 'j'.
* gettext-tools/src/msgmerge.c (message_merge): Reduce scope of local variables
'i', 'len', 'cnt'.
(match_domain): Reduce scope of some local variables.
* gettext-tools/src/write-mo.c (write_table): Reduce scope of local variables
'j', 'm'.
* gettext-tools/src/xg-arglist-parser.c (arglist_parser_done): Rename local
variable 'i' to 'j'.
* gettext-tools/src/x-csharp.c (phase2_getc): Reduce scope of local variable
'c'.
* gettext-tools/src/x-javascript.c (phase2_getc): Likewise.
* gettext-tools/src/x-python.c (phase2_getc): Likewise.
* gettext-tools/src/x-lisp.c (read_object): Rename some uses of local variable
'c' to 'dmc'.
* gettext-tools/src/x-elisp.c (read_object): Rename some uses of local variable
'c' to 'ch' or 'dmc'.
* gettext-tools/src/x-librep.c (read_object): Likewise.
* gettext-tools/src/x-scheme.c (read_object): Likewise.
* gettext-tools/src/x-perl.c (extract_variable): Reduce scope of local variable
'c'.
* gettext-tools/src/x-vala.c (phase3_get): Reduce scope of local variable 'c2'.

2 years agoSilence "... shadows a parameter" warning.
Bruno Haible [Fri, 2 Jun 2023 23:28:42 +0000 (01:28 +0200)] 
Silence "... shadows a parameter" warning.

* gettext-tools/src/msgl-fsearch.c (message_fuzzy_index_alloc): Rename local
variable mlp.

2 years agoCode perfectionism.
Bruno Haible [Fri, 2 Jun 2023 23:28:17 +0000 (01:28 +0200)] 
Code perfectionism.

* gettext-tools/src/x-javascript.c (max): Remove unused macro.
(phase2_ungetc): Fix comment.

2 years agoCode perfectionism.
Bruno Haible [Fri, 2 Jun 2023 23:27:57 +0000 (01:27 +0200)] 
Code perfectionism.

* gettext-tools/src/write-po.c (putc): Remove unused macro.

2 years agoCode perfectionism.
Bruno Haible [Fri, 2 Jun 2023 23:27:46 +0000 (01:27 +0200)] 
Code perfectionism.

* gettext-tools/src/msgfmt.c (SIZEOF): Remove unused macro.
* gettext-tools/src/read-desktop.c (SIZEOF): Likewise.
* gettext-tools/src/x-desktop.c (SIZEOF): Likewise.

2 years agoCode perfectionism.
Bruno Haible [Fri, 2 Jun 2023 23:27:16 +0000 (01:27 +0200)] 
Code perfectionism.

* gettext-tools/src/format-lisp.c (VERIFY_LIST): Remove first, unused definition
of this macro.
* gettext-tools/src/format-scheme.c (VERIFY_LIST): Likewise.

2 years agoCode perfectionism.
Bruno Haible [Fri, 2 Jun 2023 23:26:49 +0000 (01:26 +0200)] 
Code perfectionism.

* gettext-tools/src/write-po.c (is_stylable): Define in both cases.

2 years agointl: Silence warnings "no previous prototype" and "nested extern declaration".
Bruno Haible [Fri, 2 Jun 2023 23:26:37 +0000 (01:26 +0200)] 
intl: Silence warnings "no previous prototype" and "nested extern declaration".

* gettext-runtime/intl/gettextP.h (_nl_log_untranslated): New declaration.
* gettext-runtime/intl/dcigettext.c: Remove nested declaration of _nl_log_untranslated.
* gettext-runtime/intl/log.c: Include gettextP.h.

2 years agointl: Silence a "no previous prototype" warning.
Bruno Haible [Fri, 2 Jun 2023 23:26:11 +0000 (01:26 +0200)] 
intl: Silence a "no previous prototype" warning.

* gettext-runtime/intl/langprefs.c: Include gettextP.h.

2 years agointl: Improve declaration of 'struct binding'.
Bruno Haible [Fri, 2 Jun 2023 23:25:53 +0000 (01:25 +0200)] 
intl: Improve declaration of 'struct binding'.

* autogen.sh (GNULIB_MODULES_LIBINTL): Add flexmember.
* gettext-runtime/intl/gettextP.h (struct binding): Use FLEXIBLE_ARRAY_MEMBER
instead of ZERO.
* gettext-runtime/intl/bindtextdom.c: Include flexmember.h.
(offsetof): Remove fallback definition.
(set_binding_values): Use FLEXNSIZEOF.

2 years agolibtextstyle: Silence a "missing initializer for field" warning.
Bruno Haible [Fri, 2 Jun 2023 23:25:21 +0000 (01:25 +0200)] 
libtextstyle: Silence a "missing initializer for field" warning.

* libtextstyle/lib/color.c (print_color_test): Fill the r, g, b values of all
colors[] elements.

2 years agolibtextstyle: Silence a "no previous prototype" warning.
Bruno Haible [Fri, 2 Jun 2023 23:25:06 +0000 (01:25 +0200)] 
libtextstyle: Silence a "no previous prototype" warning.

* libtextstyle/gnulib-local/lib/memory-ostream.oo.c (memory_ostream::contents):
Mark as static.

2 years agoFix support for Qt4 plural forms format strings.
Bruno Haible [Fri, 2 Jun 2023 23:24:34 +0000 (01:24 +0200)] 
Fix support for Qt4 plural forms format strings.

Pinpointed by gcc 13 warning:
warning: missing initializer for field ‘is_format3’ of ‘flag_context_ty’ [-Wmissing-field-initializers]

* gettext-tools/src/xg-arglist-context.c (null_context, passthrough_context,
passthrough_context_circular_list): Initialize also the fields is_format3,
pass_format3.

2 years agoxgettext: Fix a portability problem: Don't assume anything about the value of EOF.
Bruno Haible [Fri, 2 Jun 2023 23:23:14 +0000 (01:23 +0200)] 
xgettext: Fix a portability problem: Don't assume anything about the value of EOF.

Pinpointed by gcc 13 warning:
warning: macro "P7_EOF" is not used [-Wunused-macros]

* gettext-tools/src/x-c.c (P7_STRING_END): Remove macro.
(phase7_getc): Transform EOF to P7_EOF.
(phase5_get): Test for P7_EOF, not EOF.
* gettext-tools/src/x-vala.c (P7_STRING_END): Remove macro.
(phase7_getc): Transform EOF to P7_EOF.
(phase3_get): Test for P7_EOF, not EOF.

2 years agolibgrep: Don't crash upon out-of-memory.
Bruno Haible [Fri, 2 Jun 2023 23:22:53 +0000 (01:22 +0200)] 
libgrep: Don't crash upon out-of-memory.

Pinpointed by gcc 13 warning:
warning: use of possibly-NULL ‘mb_properties’ where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument]

* gettext-tools/libgrep/m-fgrep.c (check_multibyte_string): Check the malloc()
return value.

2 years agolibtextstyle: Don't crash if xgethostname() returns NULL.
Bruno Haible [Fri, 2 Jun 2023 23:22:24 +0000 (01:22 +0200)] 
libtextstyle: Don't crash if xgethostname() returns NULL.

Pinpointed by gcc 13 warning:
warning: dereference of possibly-NULL ‘p’ [CWE-690] [-Wanalyzer-possible-null-dereference]

* libtextstyle/gnulib-local/lib/term-ostream.oo.c (term_ostream_create): If
xgethostname() returns NULL, use a dummy hash code.

2 years agolibxml: Fix possible null pointer access (regression 2023-05-26).
Bruno Haible [Fri, 2 Jun 2023 23:21:57 +0000 (01:21 +0200)] 
libxml: Fix possible null pointer access (regression 2023-05-26).

Pinpointed by gcc 13 warning:
warning: dereference of NULL ‘clone’ [CWE-476] [-Wanalyzer-null-dereference]

* gnulib-local/lib/libxml/tree.c (xmlDOMWrapCloneNode): Assign clone from
cloneAttr.

2 years agolibxml: Fix compilation error with gcc < 10 (regression 2023-05-26).
Bruno Haible [Mon, 29 May 2023 09:41:07 +0000 (11:41 +0200)] 
libxml: Fix compilation error with gcc < 10 (regression 2023-05-26).

* gnulib-local/lib/libxml/tree.c (xmlDOMWrapCloneNode): Add braces.

2 years agoformat-c: Recognize size specifiers w8, w16, w32, w64, wf8, wf16, wf32, wf64.
Bruno Haible [Sun, 28 May 2023 15:45:08 +0000 (17:45 +0200)] 
format-c: Recognize size specifiers w8, w16, w32, w64, wf8, wf16, wf32, wf64.

* gettext-tools/src/format-c.c (INVALID_SIZE_SPECIFIER): New macro.
* gettext-tools/src/format-c-parse.h (format_parse_entrails): Accept only one
size specifier, not a sequence of size specifiers. Accept "wN" and "wfN",
where N = 8, 16, 32, 64. Reject integer size specifiers for floating-point
directives. Reject integer size specifiers other than "l" for %c and %s.
* gettext-tools/tests/format-c-1: Add more test cases.
* gettext-tools/tests/format-c-2: Likewise.
* NEWS: Mention it.

2 years agoc-format: Recognize the %b format directive.
Bruno Haible [Sun, 28 May 2023 10:56:43 +0000 (12:56 +0200)] 
c-format: Recognize the %b format directive.

* gettext-tools/src/format-c-parse.h (format_parse_entrails): Recognize %b as
a directive that takes an unsigned integer argument.
* gettext-tools/tests/format-c-1: Add test of %b.
* gettext-tools/tests/format-c-2: Add type compatibility test for %b.
* NEWS: Mention it.

2 years agoxgettext: Support digit separators as in ISO C 23.
Bruno Haible [Sun, 28 May 2023 10:14:07 +0000 (12:14 +0200)] 
xgettext: Support digit separators as in ISO C 23.

* gettext-tools/src/x-c.c (phase5_get): Recognize digit separators.
* gettext-tools/tests/xgettext-c-2: Add more test cases of integer and
floating-point literals.
* NEWS: Mention it.

2 years agointl: Support bison ≥ 3.7 better.
Bruno Haible [Fri, 26 May 2023 23:46:59 +0000 (01:46 +0200)] 
intl: Support bison ≥ 3.7 better.

* gettext-runtime/intl/Makefile.am (generate-plural): Renamed from
$(srcdir)/plural.c.
(plural.c, plural.h): New parallel-safe rules.
(BUILT_SOURCES): Add plural.c, plural.h.

2 years agobuild: Make bison rules more reliable.
Bruno Haible [Fri, 26 May 2023 23:46:03 +0000 (01:46 +0200)] 
build: Make bison rules more reliable.

* gettext-runtime/intl/Makefile.am ($(srcdir)/plural.c): Fix sed expressions.
* gettext-tools/src/Makefile.am (po-gram-gen.c, cldr-plural.c): Likewise.

2 years agoSilence a gcc warning "array subscript ... is partly outside array bounds".
Bruno Haible [Fri, 26 May 2023 22:25:12 +0000 (00:25 +0200)] 
Silence a gcc warning "array subscript ... is partly outside array bounds".

* autogen.sh (GNULIB_MODULES_TOOLS_FOR_SRC): Add flexmember.
* gettext-tools/src/xg-arglist-parser.h (struct arglist_parser): Use
FLEXIBLE_ARRAY_MEMBER.
* gettext-tools/src/xg-arglist-parser.c: Include flexmember.h.
(arglist_parser_alloc, arglist_parser_clone): Use FLEXNSIZEOF instead of
hand-made size computations.

2 years agoUpdate to the newest gnulib.
Bruno Haible [Sun, 9 Apr 2023 09:52:18 +0000 (11:52 +0200)] 
Update to the newest gnulib.

2 years agolibgrep: Optimize and silence gcc warning.
Bruno Haible [Fri, 26 May 2023 21:02:24 +0000 (23:02 +0200)] 
libgrep: Optimize and silence gcc warning.

* gettext-tools/libgrep/m-fgrep.c (Fexecute): Set mb_properties to NULL in a
unibyte locale.

2 years agolibgrep: Modernize.
Bruno Haible [Fri, 26 May 2023 20:59:26 +0000 (22:59 +0200)] 
libgrep: Modernize.

* gettext-tools/libgrep/m-fgrep.c: Include <wchar.h> unconditionally. Assume
mbrlen function, by virtue of the gnulib module 'mbrlen'. Don't include
<wctype.h>. Assume ANSI C.

2 years agoSilence a gcc warning.
Bruno Haible [Fri, 26 May 2023 16:59:49 +0000 (18:59 +0200)] 
Silence a gcc warning.

* gettext-tools/src/write-po.c (memset_small): Use
'#pragma GCC diagnostic ignored' to silence a bogus gcc warning.

2 years agoSilence a gcc warning.
Bruno Haible [Fri, 26 May 2023 15:21:25 +0000 (17:21 +0200)] 
Silence a gcc warning.

* gettext-tools/src/format-scheme.c (II): Mark as possibly unused.

2 years agolibxml: Silence several gcc warnings.
Bruno Haible [Fri, 26 May 2023 15:07:04 +0000 (17:07 +0200)] 
libxml: Silence several gcc warnings.

* gnulib-local/lib/libxml/SAX2.c (xmlNsErrMsg): Mark as possibly unused.
(xmlSAX2AttributeDecl, xmlSAX2ElementDecl, xmlSAX2NotationDecl): Mark a local
variable as possibly unused.
* gnulib-local/lib/libxml/encoding.c (xmlCharEncCloseFunc): Likewise.
* gnulib-local/lib/libxml/trionan.c (compute_minus_zerod, minus_zerod): Mark as
possibly unused.
* gnulib-local/lib/libxml/tree.c (xmlDOMWrapCloneNode): Use a differently typed
variable cloneAttr.

2 years agointl: Silence a gcc warning.
Bruno Haible [Fri, 26 May 2023 14:11:55 +0000 (16:11 +0200)] 
intl: Silence a gcc warning.

* gettext-runtime/intl/localealias.c (read_alias_file): Silence a bogus
-Wuse-after-free warning.

2 years agobuild: Improve autoconf quoting.
Bruno Haible [Fri, 26 May 2023 14:03:57 +0000 (16:03 +0200)] 
build: Improve autoconf quoting.

* gettext-runtime/intl/configure.ac: Fix quoting of AS_HELP_STRING argument.
* gettext-tools/configure.ac: Likewise.

2 years agoSupport creating shared libraries on Hurd/x86_64.
Bruno Haible [Sun, 21 May 2023 20:22:38 +0000 (22:22 +0200)] 
Support creating shared libraries on Hurd/x86_64.

Patch from
<https://lists.gnu.org/archive/html/bug-hurd/2023-05/msg00086.html>.

* m4/libtool.m4 (_LT_ENABLE_LOCK): Treat Hurd/x86_64 like
Linux/x86_64.

2 years agodoc: Clarify when extracted comments get extracted.
Bruno Haible [Wed, 3 May 2023 16:32:57 +0000 (18:32 +0200)] 
doc: Clarify when extracted comments get extracted.

Fixes the fix from <https://savannah.gnu.org/bugs/index.php?42376>.
Prompted by <https://savannah.gnu.org/bugs/index.php?64136>.

* gettext-tools/doc/xgettext.texi: Clarify that it's not blank lines, but lines
with tokens, that prevent the extraction of a preceding comment block.

2 years agohostname: Use more modern network APIs.
Bruno Haible [Sat, 1 Apr 2023 15:14:43 +0000 (17:14 +0200)] 
hostname: Use more modern network APIs.

Reported by Jens Petersen <petersen@redhat.com>
at <https://savannah.gnu.org/bugs/?63983>.

* autogen.sh (GNULIB_MODULES_TOOLS_FOR_SRC): Add getaddrinfo.
* gettext-tools/src/hostname.c (HAVE_GETADDRINFO): Define to 1.
Do the #includes for gethostname() after those for getaddrinfo().
(ipv4_is_linklocal, ipv6_is_linklocal): New functions.
(print_hostname): For long_format and ip_format, prefer getaddrinfo over
gethostbyname.
* gettext-tools/src/Makefile.am (hostname_LDADD): New variable.

2 years agoUpdate to the newest gnulib.
Bruno Haible [Sat, 1 Apr 2023 15:05:27 +0000 (17:05 +0200)] 
Update to the newest gnulib.

2 years agoxgettext: In language Tcl, fix the \u, \U handling.
Bruno Haible [Sat, 1 Apr 2023 13:36:04 +0000 (15:36 +0200)] 
xgettext: In language Tcl, fix the \u, \U handling.

* gettext-tools/src/x-tcl.c (do_getc_escaped_low_surrogate): Actually store the
read characters in buf.

2 years agoUse string-desc module from gnulib.
Bruno Haible [Thu, 30 Mar 2023 13:18:27 +0000 (15:18 +0200)] 
Use string-desc module from gnulib.

* autogen.sh (GNULIB_MODULES_TOOLS_FOR_SRC): Add string-desc. Remove memmem,
memrchr.
(GNULIB_MODULES_LIBGETTEXTPO): Likewise.
* gettext-tools/src/str-desc.h: Remove file.
* gettext-tools/src/str-desc.c: Remove file.
* gettext-tools/src/FILES: Update.
* gettext-tools/src/msgl-ascii.h: Include string-desc.h instead of str-desc.h.
Use string_desc_t instead of string_desc_ty.
* gettext-tools/src/msgl-ascii.c: Use string_desc_t instead of string_desc_ty.
* gettext-tools/src/msgl-iconv.h: Include string-desc.h instead of str-desc.h.
Use string_desc_t instead of string_desc_ty.
* gettext-tools/src/msgl-iconv.c: Include string-desc.h instead of str-desc.h.
Use string_desc_t instead of string_desc_ty.
* gettext-tools/src/xg-encoding.h: Include string-desc.h instead of str-desc.h.
Use string_desc_t instead of string_desc_ty.
* gettext-tools/src/xg-encoding.c (string_desc_from_current_source_encoding):
Use string_desc_t instead of string_desc_ty.
* gettext-tools/src/x-perl.c: Include string-desc.h instead of str-desc.h.
(extract_quotelike_pass1, extract_quotelike_pass1_utf8, extract_quotelike,
extract_triple_quotelike, interpolate_keywords): Use string_desc_t instead of
string_desc_ty.
* gettext-tools/src/Makefile.am (noinst_HEADERS): Remove str-desc.h.
(libgettextsrc_la_SOURCES): Remove str-desc.c.
* gettext-tools/libgettextpo/Makefile.am (libgettextpo_la_AUXSOURCES): Remove
str-desc.c.

2 years agoUpdate to the newest gnulib.
Bruno Haible [Thu, 30 Mar 2023 10:26:00 +0000 (12:26 +0200)] 
Update to the newest gnulib.

2 years agointl: Simplify use of vasnprintf from Gnulib.
Bruno Haible [Fri, 17 Mar 2023 16:14:27 +0000 (17:14 +0100)] 
intl: Simplify use of vasnprintf from Gnulib.

* autogen.sh (GNULIB_MODULES_LIBINTL): Use vasnprintf-posix instead of vasnprintf.
* gettext-runtime/intl/vasnprintf.h: Remove file, moved to gnulib.
* gettext-runtime/intl/Makefile.am (EXTRA_DIST): Remove vasnprintf.h.
(printf.lo): Simplify dependencies accordingly.

2 years agointl: Fix bug in the exported *wprintf functions.
Bruno Haible [Fri, 17 Mar 2023 16:08:12 +0000 (17:08 +0100)] 
intl: Fix bug in the exported *wprintf functions.

* autogen.sh (GNULIB_MODULES_LIBINTL): Add vasnwprintf-posix.
* gettext-runtime/intl/configure.ac: Hide the symbols from the gnulib modules
isnand-nolibm, isnanl-nolibm, printf-frexp, printf-frexpl, signbit, vasnwprintf,
frexp-nolibm, frexpl-nolibm.
* gettext-runtime/intl/printf.c: Don't instantiate the vasnwprintf code here.
* gettext-runtime/intl/wprintf-parse.h: Remove file, moved to gnulib.
* gettext-runtime/intl/vasnwprintf.h: Remove file, moved to gnulib.
* gettext-runtime/intl/Makefile.am (EXTRA_DIST): Remove wprintf-parse.h,
vasnwprintf.h.
(printf.lo): Simplify dependencies accordingly.

2 years agoUpdate to the newest gnulib.
Bruno Haible [Fri, 17 Mar 2023 12:20:28 +0000 (13:20 +0100)] 
Update to the newest gnulib.

2 years agobuild: Fix link error on native Windows (regression 2023-03-15).
Bruno Haible [Fri, 17 Mar 2023 01:44:56 +0000 (02:44 +0100)] 
build: Fix link error on native Windows (regression 2023-03-15).

* autogen.sh (GNULIB_MODULES_TOOLS_FOR_SRC, GNULIB_MODULES_LIBGETTEXTPO): Add
memmem and memrchr, needed by str-desc.c.

2 years agodoc: Add a clarification.
Bruno Haible [Wed, 15 Mar 2023 23:11:20 +0000 (00:11 +0100)] 
doc: Add a clarification.

Reported by Christian Ohm <chr.ohm@gmx.net>
in <https://savannah.gnu.org/bugs/?36084>.

* gettext-tools/doc/gettext.texi (c-format Flag): Clarify that an xgettext:...
comment applies only to the next string.

2 years agoxgettext: In language Perl, avoid a crash.
Bruno Haible [Wed, 15 Mar 2023 21:47:47 +0000 (22:47 +0100)] 
xgettext: In language Perl, avoid a crash.

* gettext-tools/src/xg-arglist-parser.c (arglist_parser_clone): Clone the
msgid_pos correctly.
* gettext-tools/tests/xgettext-perl-10: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

2 years agoxgettext: In language Perl, avoid a crash when NUL is used as delimiter.
Bruno Haible [Wed, 15 Mar 2023 20:57:56 +0000 (21:57 +0100)] 
xgettext: In language Perl, avoid a crash when NUL is used as delimiter.

* gettext-tools/src/str-desc.h: New file.
* gettext-tools/src/str-desc.c: New file.
* gettext-tools/src/FILES: Describe them.
* gettext-tools/src/Makefile.am (noinst_HEADERS): Add str-desc.h.
(libgettextsrc_la_SOURCES): Add str-desc.c.
* gettext-tools/src/msgl-ascii.h: Include str-desc.h.
(is_ascii_string_desc): New declaration.
* gettext-tools/src/msgl-ascii.c (is_ascii_string_desc): New function.
* gettext-tools/src/msgl-iconv.h: Include str-desc.h.
(convert_string_desc_directly): New declaration.
* gettext-tools/src/msgl-iconv.c: Include str-desc.h.
(convert_string_desc_directly): New function.
* gettext-tools/src/xg-encoding.h: Include str-desc.h.
(string_desc_from_current_source_encoding): New declaration.
* gettext-tools/src/xg-encoding.c (string_desc_from_current_source_encoding):
New function.
* gettext-tools/src/x-perl.c: Include str-desc.h, c-ctype.h.
(extract_quotelike_pass1): Return a string_desc_ty instead of a 'char *'.
(extract_quotelike_pass1_utf8): Likewise.
(extract_quotelike, extract_triple_quotelike): Update.
(interpolate_keywords): Take a string_desc_ty instead of a 'const char *' as
argument.
(x_perl_prelex): Update.
* gettext-tools/libgettextpo/Makefile.am (libgettextpo_la_AUXSOURCES): Add
str-desc.c.
* gettext-tools/tests/xgettext-perl-9: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

2 years agopo: In the Makefiles, enable --quiet by default when possible.
Bruno Haible [Tue, 14 Mar 2023 21:14:17 +0000 (22:14 +0100)] 
po: In the Makefiles, enable --quiet by default when possible.

This is possible because msgmerge became faster
- through an index-based fuzzy search (msgl-fsearch.c) in 2006,
- through OpenMP parallelization in 2006,
- through processor speedups over the years.
The only case where msgmerge is still slow is when a compendium is in use.

Suggested by Marcus Müller <marcus_savannah@hostalia.de> in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-03/msg00034.html>.

* gettext-runtime/po/Makefile.in.in ($(POFILES), update-po): If msgmerge has
version ≥ 0.11, pass option --quiet.
* gettext-runtime/po/Makevars (MSGMERGE_OPTIONS): Don't suggest --quiet any
more.
* gettext-tools/po/Makevars (MSGMERGE_OPTIONS): Likewise.
* gettext-tools/examples/hello-*/po/Makevars (MSGMERGE_OPTIONS): Likewise.
* gettext-tools/examples/hello-*/po/Makefile.am ($(POFILES), update-po): If
msgmerge has version ≥ 0.11, pass option --quiet.
(MSGMERGE_OPTIONS): Don't suggest --quiet any more.
* gettext-tools/examples/hello-objc-gnustep/po/GNUmakefile: Likewise.
* gettext-tools/examples/po/Makefile.am ($(POFILES), update-po): Pass option
--quiet to msgmerge.
(MSGMERGE_OPTIONS): Don't suggest --quiet any more.

2 years agoxgettext: In language Tcl, support \x, \u, \U escapes as specified in Tcl 8.6.
Bruno Haible [Tue, 14 Mar 2023 11:59:22 +0000 (12:59 +0100)] 
xgettext: In language Tcl, support \x, \u, \U escapes as specified in Tcl 8.6.

* gettext-tools/src/x-tcl.c: Update comments.
(phase1_pushback): Increase size to 5.
(do_getc_escaped): For \x, parse only up to 2 hexadecimal characters.
Handle '\U'.
(do_getc_escaped_low_surrogate): New function.
(accumulate_word): After reading a high surrogate, see if it is followed by a
low surrogate.
* gettext-tools/tests/xgettext-tcl-4: Change expected outcome for \x. Add test
cases for \u with surrogates and for \U.
* gettext-tools/tests/xgettext-tcl-5: Add more test cases.
* NEWS: Mention the change.

2 years agoxgettext: In language Tcl, avoid a crash at surrogate character escapes.
Bruno Haible [Tue, 14 Mar 2023 08:37:51 +0000 (09:37 +0100)] 
xgettext: In language Tcl, avoid a crash at surrogate character escapes.

* gettext-tools/src/x-tcl.c (accumulate_word): Warn when seeing a surrogate
character, instead of aborting.
* gettext-tools/tests/xgettext-tcl-5: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

2 years agoxgettext: In language Shell, avoid a crash.
Bruno Haible [Tue, 14 Mar 2023 02:19:59 +0000 (03:19 +0100)] 
xgettext: In language Shell, avoid a crash.

* gettext-tools/src/x-sh.c (phase1_pushback): Increase size by 1.
* gettext-tools/tests/xgettext-sh-8: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

2 years agolisp-format, scheme-format: Fix a loop transformation.
Bruno Haible [Tue, 14 Mar 2023 01:41:27 +0000 (02:41 +0100)] 
lisp-format, scheme-format: Fix a loop transformation.

* gettext-tools/src/format-lisp.c (rotate_loop): Assign the new
list->repeated.count.
* gettext-tools/src/format-scheme.c (rotate_loop): Likewise.
* gettext-tools/tests/xgettext-lisp-6: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

2 years agolisp-format: Fix a crash in format string that contains "~@?" before "~V".
Bruno Haible [Tue, 14 Mar 2023 00:38:13 +0000 (01:38 +0100)] 
lisp-format: Fix a crash in format string that contains "~@?" before "~V".

* gettext-tools/src/format-lisp.c (nocheck_params): Don't call
add_req_type_constraint if position < 0.
* gettext-tools/tests/xgettext-lisp-5: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

2 years agolisp-format, scheme-format: Fix a memory overrun.
Bruno Haible [Tue, 14 Mar 2023 00:04:45 +0000 (01:04 +0100)] 
lisp-format, scheme-format: Fix a memory overrun.

* gettext-tools/src/format-lisp.c (make_repeated_list): Fix upper bound of a
loop.
* gettext-tools/src/format-scheme.c (make_repeated_list): Likewise.
* gettext-tools/tests/xgettext-lisp-4: New file.
* gettext-tools/tests/xgettext-scheme-6: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.

2 years agolisp-format, scheme-format: Improve run-time checks.
Bruno Haible [Mon, 13 Mar 2023 22:11:46 +0000 (23:11 +0100)] 
lisp-format, scheme-format: Improve run-time checks.

* gettext-tools/src/format-lisp.c (add_type_constraint,
add_listtype_constraint): Always check the result.
* gettext-tools/src/format-scheme.c (add_type_constraint,
add_listtype_constraint): Likewise.

2 years agoFix lisp-format, scheme-format: Add a loop normalization.
Bruno Haible [Mon, 13 Mar 2023 19:52:33 +0000 (20:52 +0100)] 
Fix lisp-format, scheme-format: Add a loop normalization.

* gettext-tools/src/format-lisp.c (normalize_outmost_list): Algorithmic fixes.
* gettext-tools/src/format-scheme.c (normalize_outmost_list): Likewise.
* gettext-tools/tests/format-lisp-2: Add another test.
* gettext-tools/tests/format-scheme-2: Likewise.

2 years agoFix lisp-format, scheme-format: Fix a memory corruption bug.
Bruno Haible [Sun, 12 Mar 2023 23:51:07 +0000 (00:51 +0100)] 
Fix lisp-format, scheme-format: Fix a memory corruption bug.

* gettext-tools/src/format-lisp.c (make_repeated_list): Access the correct
array.
* gettext-tools/src/format-scheme.c (make_repeated_list): Likewise.
* gettext-tools/tests/xgettext-lisp-3: New file.
* gettext-tools/tests/xgettext-scheme-5: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.

2 years agoxgettext: In language JavaScript, avoid a crash.
Bruno Haible [Sun, 12 Mar 2023 23:21:50 +0000 (00:21 +0100)] 
xgettext: In language JavaScript, avoid a crash.

This avoids a crash
"Assertion `phase2_pushback_length + j < SIZEOF (phase2_pushback)' failed.".

* gettext-tools/src/x-javascript.c (phase2_pushback): Increase size by 1.
* gettext-tools/tests/xgettext-javascript-12: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

2 years agoxgettext: In language JavaScript, avoid a crash at an XML comment, CDATA, or PI.
Bruno Haible [Sun, 12 Mar 2023 23:10:47 +0000 (00:10 +0100)] 
xgettext: In language JavaScript, avoid a crash at an XML comment, CDATA, or PI.

* gettext-tools/src/x-javascript.c (phase5_scan_xml_markup): Return int instead
of bool.
(phase5_get): Ignore XML markup parsed by phase5_scan_xml_markup.
* gettext-tools/tests/xgettext-javascript-9: New file.
* gettext-tools/tests/xgettext-javascript-10: New file.
* gettext-tools/tests/xgettext-javascript-11: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.

2 years agoxgettext: In language JavaScript, avoid a crash for some non-ASCII input.
Bruno Haible [Sun, 12 Mar 2023 14:25:33 +0000 (15:25 +0100)] 
xgettext: In language JavaScript, avoid a crash for some non-ASCII input.

* gettext-tools/src/xg-encoding.c (non_ascii_error_message,
non_utf8_error_message): Handle all possible lexical_context_ty values.
* gettext-tools/tests/xgettext-javascript-8: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

2 years agoxgettext: In language C#, avoid a crash due to a too small buffer.
Bruno Haible [Sun, 12 Mar 2023 12:33:30 +0000 (13:33 +0100)] 
xgettext: In language C#, avoid a crash due to a too small buffer.

* gettext-tools/src/x-csharp.c (phase3_pushback): Increase size to 10.
* gettext-tools/tests/xgettext-csharp-9: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

2 years agoFix python-brace-format: Fix placement of FMTDIR_ERROR marker.
Bruno Haible [Sun, 12 Mar 2023 12:11:58 +0000 (13:11 +0100)] 
Fix python-brace-format: Fix placement of FMTDIR_ERROR marker.

* gettext-tools/src/format-python-brace.c (parse_directive): Simplify. Fix
placement of FMTDIR_ERROR marker and improve error message in one case.
* gettext-tools/tests/format-python-brace-1: Add more test cases.

2 years agoFix python-brace-format: Disallow empty precision.
Bruno Haible [Sun, 12 Mar 2023 11:28:00 +0000 (12:28 +0100)] 
Fix python-brace-format: Disallow empty precision.

* gettext-tools/src/format-python-brace.c (parse_directive): After '.', expect
at least one digit.
* gettext-tools/tests/format-python-brace-1: Add a test case.

2 years agoxgettext: Avoid a crash due to a python-brace-format string with a NUL byte.
Bruno Haible [Sun, 12 Mar 2023 10:45:11 +0000 (11:45 +0100)] 
xgettext: Avoid a crash due to a python-brace-format string with a NUL byte.

* gettext-tools/src/format-python-brace.c: Improve comments.
(parse_directive): Don't read past the string end if c1 is NUL.
* gettext-tools/tests/xgettext-python-6: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

2 years agoxgettext: Fix abort when outputting a msgid that has an invalid UTF-8 character.
Bruno Haible [Sun, 12 Mar 2023 00:39:57 +0000 (01:39 +0100)] 
xgettext: Fix abort when outputting a msgid that has an invalid UTF-8 character.

* gettext-tools/src/xg-encoding.c: Include unistr.h.
(non_utf8_error_message): New function.
(from_current_source_encoding): When xgettext_current_source_encoding is
"UTF-8", check that the string is well-formed UTF-8.
* gettext-tools/tests/xgettext-c-8: New file.
* gettext-tools/tests/xgettext-python-5: New file.
* gettext-tools/tests/xgettext-elisp-3: New file.
* gettext-tools/tests/xgettext-librep-3: New file.
* gettext-tools/tests/xgettext-awk-3: New file.
* gettext-tools/tests/xgettext-lua-3: New file.
* gettext-tools/tests/xgettext-vala-4: New file.
* gettext-tools/tests/xgettext-php-5: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.

2 years agoSimplify code.
Bruno Haible [Sat, 11 Mar 2023 02:31:25 +0000 (03:31 +0100)] 
Simplify code.

* gettext-tools/src/format-python-brace.c (parse_upto): Remove redundant
declaration.

2 years agoxgettext: In language Vala, report out-of-range hexadecimal escapes.
Bruno Haible [Sat, 11 Mar 2023 00:21:40 +0000 (01:21 +0100)] 
xgettext: In language Vala, report out-of-range hexadecimal escapes.

This avoids a later crash
"Assertion `UNICODE_VALUE (c) >= 0 && UNICODE_VALUE (c) < 0x110000' failed."

* gettext-tools/src/x-vala.c (phase7_getc): When the value of a hexadecimal
escape sequence overflows, warn and use the last value before it overflowed.
* gettext-tools/tests/xgettext-vala-7: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

2 years agoxgettext: In language C, report out-of-range hexadecimal escapes.
Bruno Haible [Sat, 11 Mar 2023 00:02:47 +0000 (01:02 +0100)] 
xgettext: In language C, report out-of-range hexadecimal escapes.

This avoids a later crash
"Assertion `UNICODE_VALUE (c) >= 0 && UNICODE_VALUE (c) < 0x110000' failed."

* gettext-tools/src/x-c.c (phase7_getc): When the value of a hexadecimal escape
sequence overflows, warn and use the last value before it overflowed.
* gettext-tools/tests/xgettext-c-7: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

2 years agoxgettext: In language PO, handle non-ASCII non-UTF-8 input files correctly.
Bruno Haible [Fri, 10 Mar 2023 22:32:24 +0000 (23:32 +0100)] 
xgettext: In language PO, handle non-ASCII non-UTF-8 input files correctly.

* gettext-tools/src/x-po.c: Include msgl-iconv.h, msgl-ascii.h, po-charset.h.
(extract): If a header charset is present, convert the messages to UTF-8;
otherwise verify that they are all ASCII.
* gettext-tools/tests/xgettext-po-3: New file.
* gettext-tools/tests/xgettext-po-4: New file.
* gettext-tools/tests/testdata/xg-po-3.po: New file.
* gettext-tools/tests/testdata/xg-po-4.po: New file.
* gettext-tools/tests/Makefile.am (TESTS, EXTRA_DIST): Add them.
* NEWS: Mention the change.

2 years agopo-mode: Fix incompatibility with the forthcoming Emacs 29.
Bruno Haible [Thu, 9 Mar 2023 23:07:52 +0000 (00:07 +0100)] 
po-mode: Fix incompatibility with the forthcoming Emacs 29.

Patch by Takesi Ayanokoji <ayanokoji.takesi@gmail.com>.

* gettext-tools/emacs/po-mode.el (po-font-lock-keywords): Use
font-lock-constant-face, introduced in Emacs 20.3, instead of the
long-deprecated font-lock-reference-face.
* NEWS: Mention it.

2 years agoxgettext: In language YCP, avoid stack overflow.
Bruno Haible [Thu, 9 Mar 2023 21:30:17 +0000 (22:30 +0100)] 
xgettext: In language YCP, avoid stack overflow.

* gettext-tools/src/x-ycp.c: Include error-progname.h.
(MAX_NESTING_DEPTH): New macro.
(nesting_depth): New variable.
(extract_parenthesized): Increase and check nesting_depth before calling
extract_parenthesized recursively.
(extract_ycp): Initialize nesting_depth.
* gettext-tools/tests/xgettext-ycp-stackovfl-1: New file.
* gettext-tools/tests/xgettext-ycp-stackovfl-2: New file.
* gettext-tools/tests/xgettext-ycp-stackovfl-3: New file.
* gettext-tools/tests/xgettext-ycp-stackovfl-4: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.

2 years agoxgettext: In language PHP, avoid stack overflow.
Bruno Haible [Thu, 9 Mar 2023 20:23:47 +0000 (21:23 +0100)] 
xgettext: In language PHP, avoid stack overflow.

* gettext-tools/src/x-php.c: Include error-progname.h.
(MAX_NESTING_DEPTH): New macro.
(paren_nesting_depth, bracket_nesting_depth): New variables.
(extract_balanced): Increase and check paren_nesting_depth or
bracket_nesting_depth before calling extract_balanced recursively.
(extract_python): Initialize paren_nesting_depth and bracket_nesting_depth.
* gettext-tools/tests/xgettext-php-stackovfl-1: New file.
* gettext-tools/tests/xgettext-php-stackovfl-2: New file.
* gettext-tools/tests/xgettext-php-stackovfl-3: New file.
* gettext-tools/tests/xgettext-php-stackovfl-4: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.

2 years agoxgettext: In language Perl, avoid stack overflow.
Bruno Haible [Thu, 9 Mar 2023 19:28:19 +0000 (20:28 +0100)] 
xgettext: In language Perl, avoid stack overflow.

* gettext-tools/src/x-perl.c (MAX_NESTING_DEPTH): New macro.
(nesting_depth): New variable.
(interpolate_keywords): Increase and check nesting_depth. Revert it before
returning.
(x_perl_lex): Likewise.
(extract_balanced): Increase and check nesting_depth before calling
extract_balanced recursively.
(extract_perl): Initialize nesting_depth.
* gettext-tools/tests/xgettext-perl-stackovfl-1: New file.
* gettext-tools/tests/xgettext-perl-stackovfl-2: New file.
* gettext-tools/tests/xgettext-perl-stackovfl-3: New file.
* gettext-tools/tests/xgettext-perl-stackovfl-4: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.

2 years agoxgettext: In language Tcl, avoid stack overflow.
Bruno Haible [Thu, 9 Mar 2023 10:34:41 +0000 (11:34 +0100)] 
xgettext: In language Tcl, avoid stack overflow.

* gettext-tools/src/x-tcl.c: Include error-progname.h.
(MAX_NESTING_DEPTH): New macro.
(bracket_nesting_depth, brace_nesting_depth): New variables.
(accumulate_word, read_word): Increase and check bracket_nesting_depth or
brace_nesting_depth before calling read_command_list recursively.
(extract_tcl): Initialize bracket_nesting_depth and brace_nesting_depth.
* gettext-tools/tests/xgettext-tcl-stackovfl-1: New file.
* gettext-tools/tests/xgettext-tcl-stackovfl-2: New file.
* gettext-tools/tests/xgettext-tcl-stackovfl-3: New file.
* gettext-tools/tests/xgettext-tcl-stackovfl-4: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.

2 years agoxgettext: In language Vala, avoid stack overflow.
Bruno Haible [Wed, 8 Mar 2023 20:53:49 +0000 (21:53 +0100)] 
xgettext: In language Vala, avoid stack overflow.

* gettext-tools/src/x-vala.c (MAX_NESTING_DEPTH): New macro.
(nesting_depth): New variable.
(extract_balanced): Increase and check nesting_depth before calling
extract_balanced recursively.
(extract_vala): Initialize nesting_depth.
* gettext-tools/tests/xgettext-vala-stackovfl-1: New file.
* gettext-tools/tests/xgettext-vala-stackovfl-2: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.

2 years agoxgettext: In language Lua, avoid stack overflow.
Bruno Haible [Wed, 8 Mar 2023 20:37:57 +0000 (21:37 +0100)] 
xgettext: In language Lua, avoid stack overflow.

* gettext-tools/src/x-lua.c: Include error-progname.h.
(MAX_NESTING_DEPTH): New macro.
(paren_nesting_depth, bracket_nesting_depth): New variables.
(extract_balanced): Increase and check paren_nesting_depth or
bracket_nesting_depth before calling extract_balanced recursively.
(extract_lua): Initialize paren_nesting_depth and bracket_nesting_depth.
* gettext-tools/tests/xgettext-lua-stackovfl-1: New file.
* gettext-tools/tests/xgettext-lua-stackovfl-2: New file.
* gettext-tools/tests/xgettext-lua-stackovfl-3: New file.
* gettext-tools/tests/xgettext-lua-stackovfl-4: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.

2 years agoxgettext: In language awk, avoid stack overflow.
Bruno Haible [Wed, 8 Mar 2023 19:40:35 +0000 (20:40 +0100)] 
xgettext: In language awk, avoid stack overflow.

* gettext-tools/src/x-awk.c (MAX_NESTING_DEPTH): New macro.
(nesting_depth): New variable.
(extract_parenthesized): Increase and check nesting_depth before calling
extract_parenthesized recursively.
(extract_awk): Initialize nesting_depth.
* gettext-tools/tests/xgettext-awk-stackovfl-1: New file.
* gettext-tools/tests/xgettext-awk-stackovfl-2: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.

2 years agoxgettext: In language Shell, avoid stack overflow.
Bruno Haible [Wed, 8 Mar 2023 18:36:35 +0000 (19:36 +0100)] 
xgettext: In language Shell, avoid stack overflow.

* gettext-tools/src/x-sh.c (MAX_NESTING_DEPTH): New macro.
(nesting_depth): New variable.
(read_word): Increase nesting_depth before calling read_command_list
recursively.
(read_command_list): Check nesting_depth.
(extract_sh): Initialize nesting_depth.
* gettext-tools/tests/xgettext-shell-stackovfl-1: New file.
* gettext-tools/tests/xgettext-shell-stackovfl-2: New file.
* gettext-tools/tests/xgettext-shell-stackovfl-3: New file.
* gettext-tools/tests/xgettext-shell-stackovfl-4: New file.
* gettext-tools/tests/xgettext-shell-stackovfl-5: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.

2 years agoxgettext: In language librep, avoid stack overflow.
Bruno Haible [Tue, 7 Mar 2023 23:02:07 +0000 (00:02 +0100)] 
xgettext: In language librep, avoid stack overflow.

* gettext-tools/src/x-librep.c: Include error-progname.h.
(MAX_NESTING_DEPTH): New macro.
(nesting_depth): New variable.
(read_object): Increase nesting_depth before calling read_object recursively.
Check nesting_depth.
(extract_librep): Initialize nesting_depth.
* gettext-tools/tests/xgettext-librep-stackovfl-1: New file.
* gettext-tools/tests/xgettext-librep-stackovfl-2: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.

2 years agoxgettext: In language EmacsLisp, avoid stack overflow, part 2.
Bruno Haible [Tue, 7 Mar 2023 22:45:32 +0000 (23:45 +0100)] 
xgettext: In language EmacsLisp, avoid stack overflow, part 2.

* gettext-tools/src/x-elisp.c (escape_nesting_depth): New variable.
(do_getc_escaped): Increase escape_nesting_depth before calling do_getc_escaped
recursively. Check escape_nesting_depth.
(extract_elisp): Initialize escape_nesting_depth.
* gettext-tools/tests/xgettext-elisp-stackovfl-3: New file.
* gettext-tools/tests/xgettext-elisp-stackovfl-4: New file.
* gettext-tools/tests/testdata/xg-el-so-3.el: New file.
* gettext-tools/tests/testdata/xg-el-so-4.el: New file.
* gettext-tools/tests/Makefile.am (TESTS, EXTRA_DIST): Add them.

2 years agoxgettext: In language EmacsLisp, avoid stack overflow, part 1.
Bruno Haible [Tue, 7 Mar 2023 20:46:17 +0000 (21:46 +0100)] 
xgettext: In language EmacsLisp, avoid stack overflow, part 1.

* gettext-tools/src/x-elisp.c: Include error-progname.h.
(MAX_NESTING_DEPTH): New macro.
(nesting_depth): New variable.
(read_object): Increase nesting_depth before calling read_object recursively.
Check nesting_depth.
(extract_elisp): Initialize nesting_depth.
* gettext-tools/tests/xgettext-elisp-stackovfl-1: New file.
* gettext-tools/tests/xgettext-elisp-stackovfl-2: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.