From: Bruno Haible Date: Mon, 29 Jul 2024 00:44:40 +0000 (+0200) Subject: libgettextpo: Remove static variable pass_comments. X-Git-Tag: v0.23~204 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d45a289573face7f6a738fe645764d64398f07c;p=thirdparty%2Fgettext.git libgettextpo: Remove static variable pass_comments. * gettext-tools/src/read-catalog-abstract.h (ABSTRACT_CATALOG_READER_TY): Add pass_comments field. * gettext-tools/src/read-catalog-abstract.c (catalog_reader_alloc): Initialize pass_comments field. * gettext-tools/src/read-catalog.c (default_parse_brief): Assign the pass_comments field, instead of calling po_lex_pass_comments. * gettext-tools/src/po-lex.h (po_lex_pass_comments): Remove declaration. * gettext-tools/src/po-lex.c (pass_comments): Remove variable. (po_gram_lex): Update. (po_lex_pass_comments): Remove function. --- diff --git a/gettext-tools/src/po-lex.c b/gettext-tools/src/po-lex.c index e79e33982..fb3019dd3 100644 --- a/gettext-tools/src/po-lex.c +++ b/gettext-tools/src/po-lex.c @@ -820,7 +820,6 @@ mbfile_ungetc (const mbchar_t mbc, mbfile_t mbf) /* Lexer variables. */ unsigned int gram_max_allowed_errors = 20; -static bool pass_comments = false; /* Prepare lexical analysis. */ @@ -1140,7 +1139,7 @@ po_gram_lex (union PO_GRAM_STYPE *lval, struct po_parser_state *ps) to pass comments, generate a COMMENT token, otherwise discard it. */ ps->signal_eilseq = false; - if (pass_comments) + if (ps->catr->pass_comments) { bufpos = 0; for (;;) @@ -1347,11 +1346,3 @@ po_gram_lex (union PO_GRAM_STYPE *lval, struct po_parser_state *ps) return JUNK; } } - - -/* po_gram_lex() can return comments as COMMENT. Switch this on or off. */ -void -po_lex_pass_comments (bool flag) -{ - pass_comments = flag; -} diff --git a/gettext-tools/src/po-lex.h b/gettext-tools/src/po-lex.h index 0956613cc..854a3dcff 100644 --- a/gettext-tools/src/po-lex.h +++ b/gettext-tools/src/po-lex.h @@ -75,9 +75,6 @@ extern void lex_end (struct po_parser_state *ps); union PO_GRAM_STYPE; 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); - 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 cdb15e4df..71a9b644e 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_comments = false; catr->pass_obsolete_entries = false; catr->po_lex_isolate_start = NULL; catr->po_lex_isolate_end = NULL; diff --git a/gettext-tools/src/read-catalog-abstract.h b/gettext-tools/src/read-catalog-abstract.h index f50408534..a9de36878 100644 --- a/gettext-tools/src/read-catalog-abstract.h +++ b/gettext-tools/src/read-catalog-abstract.h @@ -126,6 +126,10 @@ struct abstract_catalog_reader_class_ty #define ABSTRACT_CATALOG_READER_TY \ abstract_catalog_reader_class_ty *methods; \ \ + /* True if comments shall be handled, false if they shall be \ + ignored. */ \ + bool pass_comments; \ + \ /* True if obsolete entries shall be considered as valid. */ \ bool pass_obsolete_entries; \ \ diff --git a/gettext-tools/src/read-catalog.c b/gettext-tools/src/read-catalog.c index af4091553..2e85fd967 100644 --- a/gettext-tools/src/read-catalog.c +++ b/gettext-tools/src/read-catalog.c @@ -137,7 +137,7 @@ default_parse_brief (abstract_catalog_reader_ty *catr) { /* We need to parse comments, because even if dcatr->handle_comments is false, we need to know which messages are fuzzy. */ - po_lex_pass_comments (true); + catr->pass_comments = true; }