]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
libgettextpo: Remove static variable gram_pos.
authorBruno Haible <bruno@clisp.org>
Thu, 1 Aug 2024 21:34:37 +0000 (23:34 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 1 Aug 2024 21:34:37 +0000 (23:34 +0200)
* gettext-tools/src/po-gram.h (struct po_parser_state): Add field gram_pos.
* gettext-tools/src/po-lex.h (gram_pos): Remove declaration.
* gettext-tools/src/po-lex.c (gram_pos): Remove variable.
(po_gram_error, lex_start, lex_end, lex_getc, lex_ungetc, keyword_p,
po_gram_lex): Access ps->gram_pos instead of gram_pos.
* gettext-tools/src/po-gram-gen.y: Access ps->gram_pos instead of gram_pos.
* gettext-tools/woe32dll/gettextsrc-exports.c (gram_pos): Remove export.

gettext-tools/src/po-gram-gen.y
gettext-tools/src/po-gram.h
gettext-tools/src/po-lex.c
gettext-tools/src/po-lex.h
gettext-tools/woe32dll/gettextsrc-exports.c

index a70fcc1bf944bf1ab8b9dd779fb01124189fa6b4..baafc16505964549e2101d379fb795a562caaba6 100644 (file)
@@ -54,7 +54,7 @@ do_callback_message (struct po_parser_state *ps,
 {
   /* Test for header entry.  Ignore fuzziness of the header entry.  */
   if (msgctxt == NULL && msgid[0] == '\0' && !obsolete)
-    po_lex_charset_set (ps, msgstr, gram_pos.file_name, ps->gram_pot_role);
+    po_lex_charset_set (ps, msgstr, ps->gram_pos.file_name, ps->gram_pot_role);
 
   catalog_reader_seen_message (ps->catr,
                                msgctxt,
@@ -148,7 +148,8 @@ comment
 domain
         : DOMAIN STRING
                 {
-                   catalog_reader_seen_domain (ps->catr, $2.string, &gram_pos);
+                   catalog_reader_seen_domain (ps->catr, $2.string,
+                                               &ps->gram_pos);
                 }
         ;
 
index d265aade1e075a78b740b339ac8633da6d225134..4a2932819a1c388c0b6e158702e61941ff4dfd9a 100644 (file)
@@ -102,6 +102,7 @@ struct po_parser_state
   bool po_lex_weird_cjk;
 
   /* Current position within the PO file.  */
+  lex_pos_ty gram_pos;
   int gram_pos_column;
 
   /* Whether invalid multibyte sequences in the input shall be signalled
index 6dbd939ce07e3064ef98127a63de992856ac33b3..f46f3ac699cd0942a5fa7231317f4f33b28f9a72 100644 (file)
 #endif
 
 
-/* Current position within the PO file.  */
-lex_pos_ty gram_pos;
-
-
 /* Error handling during the parsing of a PO file.
-   These functions can access gram_pos and ps->gram_pos_column.  */
+   These functions can access ps->gram_pos and ps->gram_pos_column.  */
 
 /* VARARGS1 */
 void
@@ -85,7 +81,8 @@ po_gram_error (struct po_parser_state *ps, const char *fmt, ...)
   if (vasprintf (&buffer, fmt, ap) < 0)
     error (EXIT_FAILURE, 0, _("memory exhausted"));
   va_end (ap);
-  po_xerror (PO_SEVERITY_ERROR, NULL, gram_pos.file_name, gram_pos.line_number,
+  po_xerror (PO_SEVERITY_ERROR, NULL,
+             ps->gram_pos.file_name, ps->gram_pos.line_number,
              ps->gram_pos_column + 1, false, buffer);
   free (buffer);
 
@@ -829,11 +826,11 @@ lex_start (struct po_parser_state *ps,
 {
   /* Ignore the logical_filename, because PO file entries already have
      their file names attached.  But use real_filename for error messages.  */
-  gram_pos.file_name = xstrdup (real_filename);
+  ps->gram_pos.file_name = xstrdup (real_filename);
 
   mbfile_init (ps->mbf, fp);
 
-  gram_pos.line_number = 1;
+  ps->gram_pos.line_number = 1;
   ps->gram_pos_column = 0;
   ps->signal_eilseq = true;
   ps->po_lex_obsolete = false;
@@ -847,8 +844,8 @@ lex_start (struct po_parser_state *ps,
 void
 lex_end (struct po_parser_state *ps)
 {
-  gram_pos.file_name = NULL;
-  gram_pos.line_number = 0;
+  ps->gram_pos.file_name = NULL;
+  ps->gram_pos.line_number = 0;
   po_lex_charset_close (ps);
   free (ps->buf);
 }
@@ -872,7 +869,7 @@ lex_getc (struct po_parser_state *ps, mbchar_t mbc)
               po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
                          xasprintf ("%s: %s",
                                     xasprintf (_("error while reading \"%s\""),
-                                               gram_pos.file_name),
+                                               ps->gram_pos.file_name),
                                     errno_description));
             }
           break;
@@ -880,7 +877,7 @@ lex_getc (struct po_parser_state *ps, mbchar_t mbc)
 
       if (mb_iseq (mbc, '\n'))
         {
-          gram_pos.line_number++;
+          ps->gram_pos.line_number++;
           ps->gram_pos_column = 0;
           break;
         }
@@ -906,7 +903,7 @@ lex_getc (struct po_parser_state *ps, mbchar_t mbc)
               break;
             }
 
-          gram_pos.line_number++;
+          ps->gram_pos.line_number++;
           ps->gram_pos_column = 0;
         }
       else
@@ -922,7 +919,7 @@ lex_ungetc (struct po_parser_state *ps, const mbchar_t mbc)
     {
       if (mb_iseq (mbc, '\n'))
         /* Decrement the line number, but don't care about the column.  */
-        gram_pos.line_number--;
+        ps->gram_pos.line_number--;
       else
         /* Decrement the column number.  Also works well enough for tabs.  */
         ps->gram_pos_column -= mb_width (ps, mbc);
@@ -958,7 +955,7 @@ keyword_p (struct po_parser_state *ps, const char *s)
       if (!strcmp (s, "msgctxt"))
         return PREV_MSGCTXT;
     }
-  po_gram_error_at_line (&gram_pos, _("keyword \"%s\" unknown"), s);
+  po_gram_error_at_line (&ps->gram_pos, _("keyword \"%s\" unknown"), s);
   return NAME;
 }
 
@@ -1167,7 +1164,7 @@ po_gram_lex (union PO_GRAM_STYPE *lval, struct po_parser_state *ps)
                 buf[bufpos] = '\0';
 
                 lval->string.string = buf;
-                lval->string.pos = gram_pos;
+                lval->string.pos = ps->gram_pos;
                 lval->string.obsolete = ps->po_lex_obsolete;
                 ps->po_lex_obsolete = false;
                 ps->signal_eilseq = true;
@@ -1200,13 +1197,13 @@ po_gram_lex (union PO_GRAM_STYPE *lval, struct po_parser_state *ps)
                   }
                 if (mb_iseof (mbc))
                   {
-                    po_gram_error_at_line (&gram_pos,
+                    po_gram_error_at_line (&ps->gram_pos,
                                            _("end-of-file within string"));
                     break;
                   }
                 if (mb_iseq (mbc, '\n'))
                   {
-                    po_gram_error_at_line (&gram_pos,
+                    po_gram_error_at_line (&ps->gram_pos,
                                            _("end-of-line within string"));
                     break;
                   }
@@ -1227,12 +1224,12 @@ po_gram_lex (union PO_GRAM_STYPE *lval, struct po_parser_state *ps)
             /* Strings cannot contain the msgctxt separator, because it cannot
                be faithfully represented in the msgid of a .mo file.  */
             if (strchr (buf, MSGCTXT_SEPARATOR) != NULL)
-              po_gram_error_at_line (&gram_pos,
+              po_gram_error_at_line (&ps->gram_pos,
                                      _("context separator <EOT> within string"));
 
             /* FIXME: Treatment of embedded \000 chars is incorrect.  */
             lval->string.string = xstrdup (buf);
-            lval->string.pos = gram_pos;
+            lval->string.pos = ps->gram_pos;
             lval->string.obsolete = ps->po_lex_obsolete;
             return (ps->po_lex_previous ? PREV_STRING : STRING);
 
@@ -1293,12 +1290,12 @@ po_gram_lex (union PO_GRAM_STYPE *lval, struct po_parser_state *ps)
               if (k == NAME)
                 {
                   lval->string.string = xstrdup (buf);
-                  lval->string.pos = gram_pos;
+                  lval->string.pos = ps->gram_pos;
                   lval->string.obsolete = ps->po_lex_obsolete;
                 }
               else
                 {
-                  lval->pos.pos = gram_pos;
+                  lval->pos.pos = ps->gram_pos;
                   lval->pos.obsolete = ps->po_lex_obsolete;
                 }
               return k;
@@ -1336,17 +1333,17 @@ po_gram_lex (union PO_GRAM_STYPE *lval, struct po_parser_state *ps)
             buf[bufpos] = '\0';
 
             lval->number.number = atol (buf);
-            lval->number.pos = gram_pos;
+            lval->number.pos = ps->gram_pos;
             lval->number.obsolete = ps->po_lex_obsolete;
             return NUMBER;
 
           case '[':
-            lval->pos.pos = gram_pos;
+            lval->pos.pos = ps->gram_pos;
             lval->pos.obsolete = ps->po_lex_obsolete;
             return '[';
 
           case ']':
-            lval->pos.pos = gram_pos;
+            lval->pos.pos = ps->gram_pos;
             lval->pos.obsolete = ps->po_lex_obsolete;
             return ']';
 
index 854a3dcff2eaf45127f42e5e1687d875b6d83c5c..62f48171430c77bddcc3dd9e2067f96522696c25 100644 (file)
@@ -54,9 +54,6 @@ struct po_parser_state;
 
 /* Global variables from po-lex.c.  */
 
-/* Current position within the PO file.  */
-extern DLL_VARIABLE lex_pos_ty gram_pos;
-
 /* Number of parse errors within a PO file that cause the program to
    terminate.  Cf. error_message_count, declared in <error.h>.  */
 extern DLL_VARIABLE unsigned int gram_max_allowed_errors;
index 9dc223b0b84b202905921316f597682f2ec1df12..6b273d04726404a50b1a3b04e71c2676cb1f124b 100644 (file)
@@ -57,7 +57,6 @@ VARIABLE(formatstring_smalltalk)
 VARIABLE(formatstring_tcl)
 VARIABLE(formatstring_ycp)
 VARIABLE(gram_max_allowed_errors)
-VARIABLE(gram_pos)
 VARIABLE(input_format_po)
 VARIABLE(input_format_properties)
 VARIABLE(input_format_stringtable)