]> git.ipfire.org Git - thirdparty/gettext.git/commit
xgettext: Refactor the formatstring code.
authorBruno Haible <bruno@clisp.org>
Thu, 30 Nov 2023 07:43:16 +0000 (08:43 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 30 Nov 2023 10:40:20 +0000 (11:40 +0100)
commit75f39124f97404354fd7378c32b4e907055fcbce
treefe641ea066e6c3879ecb238fa44f654e49b5479c
parente13883ab5734a1af1c356ec6302de9ef7475c01b
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.
gettext-tools/src/xg-arglist-context.c
gettext-tools/src/xg-arglist-context.h
gettext-tools/src/xg-arglist-parser.c
gettext-tools/src/xg-formatstring.c
gettext-tools/src/xg-formatstring.h
gettext-tools/src/xg-message.c
gettext-tools/src/xgettext.c