]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Refactor: Don't use po_gram_error_at_line outside the PO file reader.
authorBruno Haible <bruno@clisp.org>
Fri, 2 Aug 2024 20:33:13 +0000 (22:33 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 2 Aug 2024 20:33:13 +0000 (22:33 +0200)
* gettext-tools/src/msgcmp.c: Include po-xerror.h, xvasprintf.h.
(match_domain, compare): Use po_xerror, po_xerror2 instead of
po_gram_error_at_line.
* gettext-tools/src/msgfmt.c: Include po-xerror.h.
(msgfmt_set_domain): Use po_xerror instead of po_gram_error_at_line.
* gettext-tools/src/msgmerge.c: Include xvasprintf.h.
(match_domain): Use po_xerror, po_xerror2 instead of po_gram_error_at_line.
* gettext-tools/src/read-catalog.c (default_set_domain): Use po_xerror instead
of po_gram_error_at_line.
* gettext-tools/src/xgettext.c: Include po-xerror.h.
(exclude_directive_domain): Use po_xerror instead of po_gram_error_at_line.

gettext-tools/src/msgcmp.c
gettext-tools/src/msgfmt.c
gettext-tools/src/msgmerge.c
gettext-tools/src/read-catalog.c
gettext-tools/src/xgettext.c

index 731178fefb0e908b32a4ae1950d6cd2a809bee36..2d55ca33be67ba19d76fc58ef98c9f145c5cb1ff 100644 (file)
@@ -41,6 +41,8 @@
 #include "read-properties.h"
 #include "read-stringtable.h"
 #include "xmalloca.h"
+#include "po-xerror.h"
+#include "xvasprintf.h"
 #include "po-charset.h"
 #include "msgl-iconv.h"
 #include "msgl-fsearch.h"
@@ -323,14 +325,14 @@ match_domain (const char *fn1, const char *fn2,
           if (!include_untranslated && defmsg->msgstr[0] == '\0')
             {
               (*nerrors)++;
-              po_gram_error_at_line (&defmsg->pos,
-                                     _("this message is untranslated"));
+              po_xerror (PO_SEVERITY_ERROR, defmsg, NULL, 0, 0, false,
+                         _("this message is untranslated"));
             }
           else if (!include_fuzzies && defmsg->is_fuzzy && !is_header (defmsg))
             {
               (*nerrors)++;
-              po_gram_error_at_line (&defmsg->pos,
-                                     _("this message needs to be reviewed by the translator"));
+              po_xerror (PO_SEVERITY_ERROR, defmsg, NULL, 0, 0, false,
+                         _("this message needs to be reviewed by the translator"));
             }
           else
             defmsg->used = 1;
@@ -368,17 +370,18 @@ match_domain (const char *fn1, const char *fn2,
             defmsg = NULL;
           if (defmsg)
             {
-              po_gram_error_at_line (&refmsg->pos,
-                                     _("this message is used but not defined..."));
-              error_message_count--;
-              po_gram_error_at_line (&defmsg->pos,
-                                     _("...but this definition is similar"));
+              po_xerror2 (PO_SEVERITY_ERROR,
+                          refmsg, NULL, 0, 0, false,
+                          _("this message is used but not defined"),
+                          defmsg, NULL, 0, 0, false,
+                          _("but this definition is similar"));
               defmsg->used = 1;
             }
           else
-            po_gram_error_at_line (&refmsg->pos,
-                                   _("this message is used but not defined in %s"),
-                                   fn1);
+            po_xerror (PO_SEVERITY_ERROR, refmsg, NULL, 0, 0, false,
+                       xasprintf (
+                         _("this message is used but not defined in %s"),
+                         fn1));
         }
     }
 }
@@ -545,8 +548,8 @@ compare (const char *fn1, const char *fn2, catalog_input_format_ty input_syntax)
           message_ty *defmsg = defmlp->item[j];
 
           if (!defmsg->used)
-            po_gram_error_at_line (&defmsg->pos,
-                                   _("warning: this message is not used"));
+            po_xerror (PO_SEVERITY_ERROR, defmsg, NULL, 0, 0, false,
+                       _("warning: this message is not used"));
         }
     }
 
index 7e6cbb34500736c5f3843e2e3d989b441c3c9e23..cb088180f884632360122594ff3b8cf0ba452c6d 100644 (file)
@@ -60,6 +60,7 @@
 #include "read-properties.h"
 #include "read-stringtable.h"
 #include "read-desktop.h"
+#include "po-xerror.h"
 #include "po-charset.h"
 #include "msgl-check.h"
 #include "msgl-iconv.h"
@@ -1236,8 +1237,10 @@ msgfmt_set_domain (default_catalog_reader_ty *dcatr,
   else
     {
       if (check_domain)
-        po_gram_error_at_line (name_pos,
-                               _("'domain %s' directive ignored"), name);
+        po_xerror (PO_SEVERITY_ERROR, NULL,
+                   name_pos->file_name, name_pos->line_number, (size_t)(-1),
+                   false,
+                   xasprintf (_("'domain %s' directive ignored"), name));
 
       /* NAME was allocated in read-po-gram.y but is not used anywhere.  */
       free (name);
index fb09b265f6660b92cba431a69ce2cc5a66278785..1782bef8bc385bea45fb4e73a9d4171a020c2eb0 100644 (file)
@@ -67,6 +67,7 @@
 #include "plural-count.h"
 #include "msgl-check.h"
 #include "po-xerror.h"
+#include "xvasprintf.h"
 #include "backupfile.h"
 #include "copy-file.h"
 #include "propername.h"
@@ -1596,13 +1597,11 @@ match_domain (const char *fn1, const char *fn2,
                 message_ty *mp;
 
                 if (verbosity_level > 1)
-                  {
-                    po_gram_error_at_line (&refmsg->pos,
-                                           _("this message is used but not defined..."));
-                    error_message_count--;
-                    po_gram_error_at_line (&defmsg->pos,
-                                           _("...but this definition is similar"));
-                  }
+                  po_xerror2 (PO_SEVERITY_ERROR,
+                              refmsg, NULL, 0, 0, false,
+                              _("this message is used but not defined"),
+                              defmsg, NULL, 0, 0, false,
+                              _("but this definition is similar"));
 
                 /* Merge the reference with the definition: take the #. and
                    #: comments from the reference, take the # comments from
@@ -1629,9 +1628,10 @@ match_domain (const char *fn1, const char *fn2,
                 const char *pend;
 
                 if (verbosity_level > 1)
-                  po_gram_error_at_line (&refmsg->pos,
-                                         _("this message is used but not defined in %s"),
-                                         fn1);
+                  po_xerror (PO_SEVERITY_ERROR, refmsg, NULL, 0, 0, false,
+                             xasprintf (
+                               _("this message is used but not defined in %s"),
+                               fn1));
 
                 mp = message_copy (refmsg);
 
@@ -1708,8 +1708,8 @@ match_domain (const char *fn1, const char *fn2,
                 unsigned long i;
 
                 if (verbosity_level > 1)
-                  po_gram_error_at_line (&mp->pos,
-                                         _("this message should define plural forms"));
+                  po_xerror (PO_SEVERITY_ERROR, mp, NULL, 0, 0, false,
+                             _("this message should define plural forms"));
 
                 new_msgstr_len = nplurals * mp->msgstr_len;
                 new_msgstr = XNMALLOC (new_msgstr_len, char);
@@ -1729,8 +1729,8 @@ match_domain (const char *fn1, const char *fn2,
                    Use only the first among the plural forms.  */
 
                 if (verbosity_level > 1)
-                  po_gram_error_at_line (&mp->pos,
-                                         _("this message should not define plural forms"));
+                  po_xerror (PO_SEVERITY_ERROR, mp, NULL, 0, 0, false,
+                             _("this message should not define plural forms"));
 
                 mp->msgstr_len = strlen (mp->msgstr) + 1;
                 mp->is_fuzzy = true;
index 7b373aae7584d9031962cfad1b125f2693a513ca..51f237ef22f79fd53d7b8a4c369058e472869c5c 100644 (file)
@@ -324,8 +324,9 @@ default_set_domain (default_catalog_reader_ty *dcatr,
     dcatr->domain = name;
   else
     {
-      po_gram_error_at_line (name_pos,
-                             _("this file may not contain domain directives"));
+      po_xerror (PO_SEVERITY_ERROR, NULL,
+                 name_pos->file_name, name_pos->line_number, (size_t)(-1),
+                 false, _("this file may not contain domain directives"));
 
       /* NAME was allocated in read-po-gram.y but is not used anywhere.  */
       free (name);
index fdcb85cc4fba539430bc7285d011abee9efeaa48..d3ebfa3d6fec205ed2096d74c338b38ecd794952 100644 (file)
@@ -72,6 +72,7 @@
 #include "read-po-lex.h"
 #include "message.h"
 #include "pos.h"
+#include "po-xerror.h"
 #include "po-charset.h"
 #include "msgl-iconv.h"
 #include "msgl-ascii.h"
@@ -1272,8 +1273,9 @@ static void
 exclude_directive_domain (abstract_catalog_reader_ty *catr,
                           char *name, lex_pos_ty *name_pos)
 {
-  po_gram_error_at_line (name_pos,
-                         _("this file may not contain domain directives"));
+  po_xerror (PO_SEVERITY_ERROR, NULL,
+             name_pos->file_name, name_pos->line_number, (size_t)(-1), false,
+             _("this file may not contain domain directives"));
 }