From: Bruno Haible Date: Mon, 29 Jul 2024 00:11:43 +0000 (+0200) Subject: libgettextpo: Remove static variable pass_obsolete_entries. X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=388b4024d93525de7dd2627a804b212a082a3b7d;p=thirdparty%2Fgettext.git libgettextpo: Remove static variable pass_obsolete_entries. * gettext-tools/src/read-catalog-abstract.h (ABSTRACT_CATALOG_READER_TY): Add pass_obsolete_entries field. * gettext-tools/src/read-catalog-abstract.c (catalog_reader_alloc): Initialize the pass_obsolete_entries field. * gettext-tools/src/read-catalog.c (read_catalog_stream): Assign the pass_obsolete_entries field, instead of calling po_lex_pass_obsolete_entries. * gettext-tools/src/msgfmt.c (read_catalog_file_msgfmt): Likewise. * gettext-tools/src/po-lex.h (pass_obsolete_entries): Remove declaration. (po_lex_pass_obsolete_entries): Remove declaration. * gettext-tools/src/po-lex.c (pass_obsolete_entries): Remove variable. (po_lex_pass_obsolete_entries): Remove function. * gettext-tools/src/po-gram-gen.y: Update. * gettext-tools/woe32dll/gettextsrc-exports.c (pass_obsolete_entries): Remove export. --- diff --git a/gettext-tools/src/msgfmt.c b/gettext-tools/src/msgfmt.c index 5aebec28a..16f5ed669 100644 --- a/gettext-tools/src/msgfmt.c +++ b/gettext-tools/src/msgfmt.c @@ -1387,6 +1387,7 @@ read_catalog_file_msgfmt (char *filename, catalog_input_format_ty input_syntax) default_catalog_reader_ty *dcatr; dcatr = default_catalog_reader_alloc (&msgfmt_methods); + dcatr->pass_obsolete_entries = true; dcatr->handle_comments = false; dcatr->allow_domain_directives = true; dcatr->allow_duplicates = false; @@ -1400,7 +1401,6 @@ read_catalog_file_msgfmt (char *filename, catalog_input_format_ty input_syntax) dcatr->domain = current_domain->domain_name; dcatr->mlp = current_domain->mlp; } - po_lex_pass_obsolete_entries (true); catalog_reader_parse ((abstract_catalog_reader_ty *) dcatr, fp, real_filename, filename, false, input_syntax); catalog_reader_free ((abstract_catalog_reader_ty *) dcatr); diff --git a/gettext-tools/src/po-gram-gen.y b/gettext-tools/src/po-gram-gen.y index 2c9e9368e..05ff9b6c3 100644 --- a/gettext-tools/src/po-gram-gen.y +++ b/gettext-tools/src/po-gram-gen.y @@ -162,7 +162,7 @@ message check_obsolete ($1, $2); check_obsolete ($1, $3); check_obsolete ($1, $4); - if (!$1.obsolete || pass_obsolete_entries) + if (!$1.obsolete || ps->catr->pass_obsolete_entries) do_callback_message (ps, $1.ctxt, string2, &$1.pos, NULL, string4, strlen (string4) + 1, &$3.pos, $1.prev_ctxt, @@ -182,7 +182,7 @@ message check_obsolete ($1, $2); check_obsolete ($1, $3); check_obsolete ($1, $4); - if (!$1.obsolete || pass_obsolete_entries) + if (!$1.obsolete || ps->catr->pass_obsolete_entries) do_callback_message (ps, $1.ctxt, string2, &$1.pos, $3.string, $4.rhs.msgstr, $4.rhs.msgstr_len, &$4.pos, $1.prev_ctxt, diff --git a/gettext-tools/src/po-lex.c b/gettext-tools/src/po-lex.c index cd5921080..e79e33982 100644 --- a/gettext-tools/src/po-lex.c +++ b/gettext-tools/src/po-lex.c @@ -821,7 +821,6 @@ mbfile_ungetc (const mbchar_t mbc, mbfile_t mbf) unsigned int gram_max_allowed_errors = 20; static bool pass_comments = false; -bool pass_obsolete_entries = false; /* Prepare lexical analysis. */ @@ -1356,12 +1355,3 @@ po_lex_pass_comments (bool flag) { pass_comments = flag; } - - -/* po_gram_lex() can return obsolete entries as if they were normal entries. - Switch this on or off. */ -void -po_lex_pass_obsolete_entries (bool flag) -{ - pass_obsolete_entries = flag; -} diff --git a/gettext-tools/src/po-lex.h b/gettext-tools/src/po-lex.h index 6027d1732..0956613cc 100644 --- a/gettext-tools/src/po-lex.h +++ b/gettext-tools/src/po-lex.h @@ -61,9 +61,6 @@ extern DLL_VARIABLE lex_pos_ty gram_pos; terminate. Cf. error_message_count, declared in . */ extern DLL_VARIABLE unsigned int gram_max_allowed_errors; -/* True if obsolete entries shall be considered as valid. */ -extern DLL_VARIABLE bool pass_obsolete_entries; - /* Prepare lexical analysis. */ extern void lex_start (struct po_parser_state *ps, @@ -81,10 +78,6 @@ extern int po_gram_lex (union PO_GRAM_STYPE *lval, struct po_parser_state *ps); /* po_gram_lex() can return comments as COMMENT. Switch this on or off. */ extern void po_lex_pass_comments (bool flag); -/* po_gram_lex() can return obsolete entries as if they were normal entries. - Switch this on or off. */ -extern void po_lex_pass_obsolete_entries (bool flag); - extern void po_gram_error (struct po_parser_state *ps, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); extern void po_gram_error_at_line (const lex_pos_ty *pos, const char *fmt, ...) diff --git a/gettext-tools/src/read-catalog-abstract.c b/gettext-tools/src/read-catalog-abstract.c index 9edf07893..cdb15e4df 100644 --- a/gettext-tools/src/read-catalog-abstract.c +++ b/gettext-tools/src/read-catalog-abstract.c @@ -47,6 +47,7 @@ catalog_reader_alloc (abstract_catalog_reader_class_ty *method_table) catr = (abstract_catalog_reader_ty *) xmalloc (method_table->size); catr->methods = method_table; + catr->pass_obsolete_entries = false; catr->po_lex_isolate_start = NULL; catr->po_lex_isolate_end = NULL; if (method_table->constructor) diff --git a/gettext-tools/src/read-catalog-abstract.h b/gettext-tools/src/read-catalog-abstract.h index 7b1173e33..f50408534 100644 --- a/gettext-tools/src/read-catalog-abstract.h +++ b/gettext-tools/src/read-catalog-abstract.h @@ -126,6 +126,9 @@ struct abstract_catalog_reader_class_ty #define ABSTRACT_CATALOG_READER_TY \ abstract_catalog_reader_class_ty *methods; \ \ + /* True if obsolete entries shall be considered as valid. */ \ + bool pass_obsolete_entries; \ + \ /* Representation of U+2068 FIRST STRONG ISOLATE (FSI) in the \ PO file's encoding, or NULL if not available. */ \ const char *po_lex_isolate_start; \ diff --git a/gettext-tools/src/read-catalog.c b/gettext-tools/src/read-catalog.c index fd221b1f0..af4091553 100644 --- a/gettext-tools/src/read-catalog.c +++ b/gettext-tools/src/read-catalog.c @@ -467,6 +467,7 @@ read_catalog_stream (FILE *fp, const char *real_filename, msgdomain_list_ty *mdlp; dcatr = default_catalog_reader_alloc (&default_methods); + dcatr->pass_obsolete_entries = true; dcatr->handle_comments = true; dcatr->allow_domain_directives = true; dcatr->allow_duplicates = allow_duplicates; @@ -477,7 +478,6 @@ read_catalog_stream (FILE *fp, const char *real_filename, if (input_syntax->produces_utf8) /* We know a priori that input_syntax->parse convert strings to UTF-8. */ dcatr->mdlp->encoding = po_charset_utf8; - po_lex_pass_obsolete_entries (true); catalog_reader_parse ((abstract_catalog_reader_ty *) dcatr, fp, real_filename, logical_filename, false, input_syntax); mdlp = dcatr->mdlp; diff --git a/gettext-tools/woe32dll/gettextsrc-exports.c b/gettext-tools/woe32dll/gettextsrc-exports.c index 4bf249a31..9dc223b0b 100644 --- a/gettext-tools/woe32dll/gettextsrc-exports.c +++ b/gettext-tools/woe32dll/gettextsrc-exports.c @@ -68,7 +68,6 @@ VARIABLE(omit_header) VARIABLE(output_format_po) VARIABLE(output_format_properties) VARIABLE(output_format_stringtable) -VARIABLE(pass_obsolete_entries) VARIABLE(plural_table) VARIABLE(plural_table_size) VARIABLE(po_charset_ascii)