]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
libgettextpo: Remove static variable pass_comments.
authorBruno Haible <bruno@clisp.org>
Mon, 29 Jul 2024 00:44:40 +0000 (02:44 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 29 Jul 2024 00:44:40 +0000 (02:44 +0200)
* 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.

gettext-tools/src/po-lex.c
gettext-tools/src/po-lex.h
gettext-tools/src/read-catalog-abstract.c
gettext-tools/src/read-catalog-abstract.h
gettext-tools/src/read-catalog.c

index e79e33982f1927c705ef81bfb914566412f927f7..fb3019dd3372160cdffd395dbbbc8a0a542db2d9 100644 (file)
@@ -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;
-}
index 0956613cc7ecf38fe230ae6dad3510f470d25b9d..854a3dcff2eaf45127f42e5e1687d875b6d83c5c 100644 (file)
@@ -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, ...)
index cdb15e4df05a75e0fe83c8455c4a000edf6c0d36..71a9b644e33423e73d8c4f0daf11bbf0fc52db42 100644 (file)
@@ -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;
index f50408534bf7f3bec348567f222a22eec1ebde67..a9de36878a368e1c68cc69660c384e2731ea8967 100644 (file)
@@ -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;                                           \
                                                                         \
index af409155346b98a5e63fce800b78d3d41eb88b67..2e85fd96743af3dd927164a168b88962c9abf4e1 100644 (file)
@@ -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;
 }