]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Change the calling convention of the formatstring_parser's 'check' method.
authorBruno Haible <bruno@clisp.org>
Tue, 7 Sep 2004 11:49:00 +0000 (11:49 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:11:54 +0000 (12:11 +0200)
Add format string checking facility to the gettextpo library.

28 files changed:
gettext-tools/ChangeLog
gettext-tools/po/ChangeLog
gettext-tools/po/Makevars
gettext-tools/src/ChangeLog
gettext-tools/src/format-awk.c
gettext-tools/src/format-c.c
gettext-tools/src/format-csharp.c
gettext-tools/src/format-elisp.c
gettext-tools/src/format-gcc-internal.c
gettext-tools/src/format-java.c
gettext-tools/src/format-librep.c
gettext-tools/src/format-lisp.c
gettext-tools/src/format-pascal.c
gettext-tools/src/format-perl-brace.c
gettext-tools/src/format-perl.c
gettext-tools/src/format-php.c
gettext-tools/src/format-python.c
gettext-tools/src/format-qt.c
gettext-tools/src/format-sh.c
gettext-tools/src/format-tcl.c
gettext-tools/src/format-ycp.c
gettext-tools/src/format.c
gettext-tools/src/format.h
gettext-tools/src/gettext-po.c
gettext-tools/src/gettext-po.h
gettext-tools/src/msgfmt.c
gettext-tools/src/msgmerge.c
gettext-tools/windows/gettextpo.def

index ef3a0f8fe996f52ef51a762b2633bb8e34ef7775..1ba2767a469d30830456a459fa35bb57d218f5d6 100644 (file)
@@ -1,3 +1,7 @@
+2004-09-06  Bruno Haible  <bruno@clisp.org>
+
+       * windows/gettextpo.def: Add po_message_check_format.
+
 2004-09-05  Bruno Haible  <bruno@clisp.org>
 
        * windows/gettextsrc.def: Add the variables names from po-error.h.
index 7a829ddb8f18d98f0dafdbb7eb0e67809017c6d1..80ae8e411f84be556d5f7054ada511570614263c 100644 (file)
@@ -1,3 +1,7 @@
+2004-09-06  Bruno Haible  <bruno@clisp.org>
+
+       * Makevars (XGETTEXT_OPTIONS): Recognize error_logger calls.
+
 2004-09-05  Bruno Haible  <bruno@clisp.org>
 
        * Makevars (XGETTEXT_OPTIONS): Recognize po_error and po_error_at_line.
index e1f13d6c7b2f3f981cbbdc29b9fbc96233a7f854..9ab201f9cfba0aa0059bf45e4a9b3c7f74dc9a60 100644 (file)
@@ -13,7 +13,7 @@ XGETTEXT_OPTIONS = \
   --keyword=N_ --flag=N_:1:pass-c-format \
   --flag=error:3:c-format --flag=error_at_line:5:c-format \
   --flag=asprintf:2:c-format --flag=vasprintf:2:c-format \
-  --flag=xasprintf:1:c-format \
+  --flag=xasprintf:1:c-format --flag=error_logger:1:c-format \
   --flag=po_error:3:c-format --flag=po_error_at_line:5:c-format \
   --flag=po_gram_error:1:c-format --flag=po_gram_error_at_line:2:c-format
 
index 781c550fdbd5b1878546c6fbc7297f22b2575328..780bf77c30407ad6f552437768a90cceb9c4d0c7 100644 (file)
@@ -1,3 +1,37 @@
+2004-09-06  Bruno Haible  <bruno@clisp.org>
+
+       * format.h (formatstring_error_logger_t): New type.
+       (struct formatstring_parser): Change calling convention of 'check'
+       method.
+       (check_msgid_msgstr_format): New declaration.
+       * format-awk.c (format_check): Use error_logger argument instead of
+       noisy and error_at_line.
+       * format-c.c (format_check): Likewise.
+       * format-csharp.c (format_check): Likewise.
+       * format-elisp.c (format_check): Likewise.
+       * format-gcc-internal.c (format_check): Likewise.
+       * format-java.c (format_check): Likewise.
+       * format-librep.c (format_check): Likewise.
+       * format-lisp.c (format_check): Likewise.
+       * format-pascal.c (format_check): Likewise.
+       * format-perl.c (format_check): Likewise.
+       * format-perl-brace.c (format_check): Likewise.
+       * format-php.c (format_check): Likewise.
+       * format-python.c (format_check): Likewise.
+       * format-qt.c (format_check): Likewise.
+       * format-sh.c (format_check): Likewise.
+       * format-tcl.c (format_check): Likewise.
+       * format-ycp.c (format_check): Likewise.
+       * format.c (check_msgid_msgstr_format): New function, extracted from
+       msgfmt.c.
+       * msgfmt.c (curr_msgid_pos): New variable.
+       (formatstring_error_logger): New function.
+       (check_pair): Use check_msgid_msgstr_format, formatstring_error_logger.
+       * msgmerge.c (msgfmt_check_pair_fails): Update.
+       * gettext-po.h (po_message_check_format): New declaration.
+       * gettext-po.c (po_error_logger, po_message_check_format): New
+       functions.
+
 2004-09-05  Bruno Haible  <bruno@clisp.org>
 
        * po-error.h: New file.
index 27b6654283167efa96a2da983d6da3c269866e1d..d2a9423a4b0453bafc20e4b93551fb8ebc4beecd 100644 (file)
@@ -28,8 +28,6 @@
 #include "xalloc.h"
 #include "xerror.h"
 #include "format-invalid.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -461,8 +459,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -486,14 +485,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
 
          if (cmp > 0)
            {
-             if (noisy)
-               {
-                 error_with_progname = false;
-                 error_at_line (0, 0, pos->file_name, pos->line_number,
-                                _("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
-                                spec2->numbered[j].number, pretty_msgstr);
-                 error_with_progname = true;
-               }
+             if (error_logger)
+               error_logger (_("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
+                             spec2->numbered[j].number, pretty_msgstr);
              err = true;
              break;
            }
@@ -501,14 +495,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
            {
              if (equality)
                {
-                 if (noisy)
-                   {
-                     error_with_progname = false;
-                     error_at_line (0, 0, pos->file_name, pos->line_number,
-                                    _("a format specification for argument %u doesn't exist in '%s'"),
-                                    spec1->numbered[i].number, pretty_msgstr);
-                     error_with_progname = true;
-                   }
+                 if (error_logger)
+                   error_logger (_("a format specification for argument %u doesn't exist in '%s'"),
+                                 spec1->numbered[i].number, pretty_msgstr);
                  err = true;
                  break;
                }
@@ -526,15 +515,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
              {
                if (spec1->numbered[i].type != spec2->numbered[j].type)
                  {
-                   if (noisy)
-                     {
-                       error_with_progname = false;
-                       error_at_line (0, 0, pos->file_name, pos->line_number,
-                                      _("format specifications in 'msgid' and '%s' for argument %u are not the same"),
-                                      pretty_msgstr,
-                                      spec2->numbered[j].number);
-                       error_with_progname = true;
-                     }
+                   if (error_logger)
+                     error_logger (_("format specifications in 'msgid' and '%s' for argument %u are not the same"),
+                                   pretty_msgstr, spec2->numbered[j].number);
                    err = true;
                    break;
                  }
index 8b9b1fce3815603f21d619468ed8dec772b6f09a..cead658fdf49fe1c847dc24eace6dc985cf0e518 100644 (file)
@@ -28,8 +28,6 @@
 #include "xalloc.h"
 #include "xerror.h"
 #include "format-invalid.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -831,8 +829,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -844,28 +843,18 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
       ? spec1->unnumbered_arg_count != spec2->unnumbered_arg_count
       : spec1->unnumbered_arg_count < spec2->unnumbered_arg_count)
     {
-      if (noisy)
-       {
-         error_with_progname = false;
-         error_at_line (0, 0, pos->file_name, pos->line_number,
-                        _("number of format specifications in 'msgid' and '%s' does not match"),
-                        pretty_msgstr);
-         error_with_progname = true;
-       }
+      if (error_logger)
+       error_logger (_("number of format specifications in 'msgid' and '%s' does not match"),
+                     pretty_msgstr);
       err = true;
     }
   else
     for (i = 0; i < spec2->unnumbered_arg_count; i++)
       if (spec1->unnumbered[i].type != spec2->unnumbered[i].type)
        {
-         if (noisy)
-           {
-             error_with_progname = false;
-             error_at_line (0, 0, pos->file_name, pos->line_number,
-                            _("format specifications in 'msgid' and '%s' for argument %u are not the same"),
-                            pretty_msgstr, i + 1);
-             error_with_progname = true;
-           }
+         if (error_logger)
+           error_logger (_("format specifications in 'msgid' and '%s' for argument %u are not the same"),
+                         pretty_msgstr, i + 1);
          err = true;
        }
 
index f13acc20de735ded055d0dffd12480da20b92266..6a847236676208233cad24916f38720d6911f9d4 100644 (file)
@@ -27,8 +27,6 @@
 #include "c-ctype.h"
 #include "xalloc.h"
 #include "xerror.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -180,8 +178,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -192,14 +191,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
       ? spec1->numbered_arg_count != spec2->numbered_arg_count
       : spec1->numbered_arg_count < spec2->numbered_arg_count)
     {
-      if (noisy)
-       {
-         error_with_progname = false;
-         error_at_line (0, 0, pos->file_name, pos->line_number,
-                        _("number of format specifications in 'msgid' and '%s' does not match"),
-                        pretty_msgstr);
-         error_with_progname = true;
-       }
+      if (error_logger)
+       error_logger (_("number of format specifications in 'msgid' and '%s' does not match"),
+                     pretty_msgstr);
       err = true;
     }
 
index 37ae646cc09bbe66c97f0ceed438477d43976503..41d30276056856324d11106a7e3b99bfe669e064 100644 (file)
@@ -28,8 +28,6 @@
 #include "xalloc.h"
 #include "xerror.h"
 #include "format-invalid.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -309,8 +307,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -334,14 +333,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
 
          if (cmp > 0)
            {
-             if (noisy)
-               {
-                 error_with_progname = false;
-                 error_at_line (0, 0, pos->file_name, pos->line_number,
-                                _("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
-                                spec2->numbered[j].number, pretty_msgstr);
-                 error_with_progname = true;
-               }
+             if (error_logger)
+               error_logger (_("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
+                             spec2->numbered[j].number, pretty_msgstr);
              err = true;
              break;
            }
@@ -349,14 +343,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
            {
              if (equality)
                {
-                 if (noisy)
-                   {
-                     error_with_progname = false;
-                     error_at_line (0, 0, pos->file_name, pos->line_number,
-                                    _("a format specification for argument %u doesn't exist in '%s'"),
-                                    spec1->numbered[i].number, pretty_msgstr);
-                     error_with_progname = true;
-                   }
+                 if (error_logger)
+                   error_logger (_("a format specification for argument %u doesn't exist in '%s'"),
+                                 spec1->numbered[i].number, pretty_msgstr);
                  err = true;
                  break;
                }
@@ -374,15 +363,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
              {
                if (spec1->numbered[i].type != spec2->numbered[j].type)
                  {
-                   if (noisy)
-                     {
-                       error_with_progname = false;
-                       error_at_line (0, 0, pos->file_name, pos->line_number,
-                                      _("format specifications in 'msgid' and '%s' for argument %u are not the same"),
-                                      pretty_msgstr,
-                                      spec2->numbered[j].number);
-                       error_with_progname = true;
-                     }
+                   if (error_logger)
+                     error_logger (_("format specifications in 'msgid' and '%s' for argument %u are not the same"),
+                                   pretty_msgstr, spec2->numbered[j].number);
                    err = true;
                    break;
                  }
index 29689916fde496940eade36e8c484a3b19ba9d55..207adb9b8f95da949f1ddf799b08fbf2aaa665d5 100644 (file)
@@ -28,8 +28,6 @@
 #include "xalloc.h"
 #include "xerror.h"
 #include "format-invalid.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -249,8 +247,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -262,28 +261,18 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
       ? spec1->unnumbered_arg_count != spec2->unnumbered_arg_count
       : spec1->unnumbered_arg_count < spec2->unnumbered_arg_count)
     {
-      if (noisy)
-       {
-         error_with_progname = false;
-         error_at_line (0, 0, pos->file_name, pos->line_number,
-                        _("number of format specifications in 'msgid' and '%s' does not match"),
-                        pretty_msgstr);
-         error_with_progname = true;
-       }
+      if (error_logger)
+       error_logger (_("number of format specifications in 'msgid' and '%s' does not match"),
+                     pretty_msgstr);
       err = true;
     }
   else
     for (i = 0; i < spec2->unnumbered_arg_count; i++)
       if (spec1->unnumbered[i].type != spec2->unnumbered[i].type)
        {
-         if (noisy)
-           {
-             error_with_progname = false;
-             error_at_line (0, 0, pos->file_name, pos->line_number,
-                            _("format specifications in 'msgid' and '%s' for argument %u are not the same"),
-                            pretty_msgstr, i + 1);
-             error_with_progname = true;
-           }
+         if (error_logger)
+           error_logger (_("format specifications in 'msgid' and '%s' for argument %u are not the same"),
+                         pretty_msgstr, i + 1);
          err = true;
        }
 
index bb133399f39ea4d54c7f7fbb06ddbfbcc3dd2bd7..c43404b944ab03c7d518fdd0510d849463c6442c 100644 (file)
@@ -31,8 +31,6 @@
 #include "xallocsa.h"
 #include "xerror.h"
 #include "format-invalid.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -701,8 +699,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -726,14 +725,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
 
          if (cmp > 0)
            {
-             if (noisy)
-               {
-                 error_with_progname = false;
-                 error_at_line (0, 0, pos->file_name, pos->line_number,
-                                _("a format specification for argument {%u}, as in '%s', doesn't exist in 'msgid'"),
-                                spec2->numbered[j].number, pretty_msgstr);
-                 error_with_progname = true;
-               }
+             if (error_logger)
+               error_logger (_("a format specification for argument {%u}, as in '%s', doesn't exist in 'msgid'"),
+                             spec2->numbered[j].number, pretty_msgstr);
              err = true;
              break;
            }
@@ -741,14 +735,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
            {
              if (equality)
                {
-                 if (noisy)
-                   {
-                     error_with_progname = false;
-                     error_at_line (0, 0, pos->file_name, pos->line_number,
-                                    _("a format specification for argument {%u} doesn't exist in '%s'"),
-                                    spec1->numbered[i].number, pretty_msgstr);
-                     error_with_progname = true;
-                   }
+                 if (error_logger)
+                   error_logger (_("a format specification for argument {%u} doesn't exist in '%s'"),
+                                 spec1->numbered[i].number, pretty_msgstr);
                  err = true;
                  break;
                }
@@ -766,15 +755,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
              {
                if (spec1->numbered[i].type != spec2->numbered[j].type)
                  {
-                   if (noisy)
-                     {
-                       error_with_progname = false;
-                       error_at_line (0, 0, pos->file_name, pos->line_number,
-                                      _("format specifications in 'msgid' and '%s' for argument {%u} are not the same"),
-                                      pretty_msgstr,
-                                      spec2->numbered[j].number);
-                       error_with_progname = true;
-                     }
+                   if (error_logger)
+                     error_logger (_("format specifications in 'msgid' and '%s' for argument {%u} are not the same"),
+                                   pretty_msgstr, spec2->numbered[j].number);
                    err = true;
                    break;
                  }
index ff7c1caaebb9d567722ffed63e47ec1e4b51f8a6..3e27db61017625763c8ee79387768bd0c5235a15 100644 (file)
@@ -28,8 +28,6 @@
 #include "xalloc.h"
 #include "xerror.h"
 #include "format-invalid.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -273,8 +271,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -298,14 +297,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
 
          if (cmp > 0)
            {
-             if (noisy)
-               {
-                 error_with_progname = false;
-                 error_at_line (0, 0, pos->file_name, pos->line_number,
-                                _("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
-                                spec2->numbered[j].number, pretty_msgstr);
-                 error_with_progname = true;
-               }
+             if (error_logger)
+               error_logger (_("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
+                             spec2->numbered[j].number, pretty_msgstr);
              err = true;
              break;
            }
@@ -313,14 +307,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
            {
              if (equality)
                {
-                 if (noisy)
-                   {
-                     error_with_progname = false;
-                     error_at_line (0, 0, pos->file_name, pos->line_number,
-                                    _("a format specification for argument %u doesn't exist in '%s'"),
-                                    spec1->numbered[i].number, pretty_msgstr);
-                     error_with_progname = true;
-                   }
+                 if (error_logger)
+                   error_logger (_("a format specification for argument %u doesn't exist in '%s'"),
+                                 spec1->numbered[i].number, pretty_msgstr);
                  err = true;
                  break;
                }
@@ -338,15 +327,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
              {
                if (spec1->numbered[i].type != spec2->numbered[j].type)
                  {
-                   if (noisy)
-                     {
-                       error_with_progname = false;
-                       error_at_line (0, 0, pos->file_name, pos->line_number,
-                                      _("format specifications in 'msgid' and '%s' for argument %u are not the same"),
-                                      pretty_msgstr,
-                                      spec2->numbered[j].number);
-                       error_with_progname = true;
-                     }
+                   if (error_logger)
+                     error_logger (_("format specifications in 'msgid' and '%s' for argument %u are not the same"),
+                                   pretty_msgstr, spec2->numbered[j].number);
                    err = true;
                    break;
                  }
index 9ce33c74c0c1142b5429e5601fd7f2504453da24..22caeb75a41c433ace870dedd43fce7f06d5382b 100644 (file)
@@ -30,8 +30,6 @@
 #include "xerror.h"
 #include "format-invalid.h"
 #include "minmax.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -3328,8 +3326,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -3339,14 +3338,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
     {
       if (!equal_list (spec1->list, spec2->list))
        {
-         if (noisy)
-           {
-             error_with_progname = false;
-             error_at_line (0, 0, pos->file_name, pos->line_number,
-                            _("format specifications in 'msgid' and '%s' are not equivalent"),
-                            pretty_msgstr);
-             error_with_progname = true;
-           }
+         if (error_logger)
+           error_logger (_("format specifications in 'msgid' and '%s' are not equivalent"),
+                         pretty_msgstr);
          err = true;
        }
     }
@@ -3360,14 +3354,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
            && (normalize_list (intersection),
                equal_list (intersection, spec2->list))))
        {
-         if (noisy)
-           {
-             error_with_progname = false;
-             error_at_line (0, 0, pos->file_name, pos->line_number,
-                            _("format specifications in '%s' are not a subset of those in 'msgid'"),
-                            pretty_msgstr);
-             error_with_progname = true;
-           }
+         if (error_logger)
+           error_logger (_("format specifications in '%s' are not a subset of those in 'msgid'"),
+                         pretty_msgstr);
          err = true;
        }
     }
index e287ed9cbee315df169cfc7f349ea6b6c5e3a27b..d2afd017361ad4a4e035f23385695be96f3eed3b 100644 (file)
@@ -28,8 +28,6 @@
 #include "xalloc.h"
 #include "xerror.h"
 #include "format-invalid.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -362,8 +360,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -387,14 +386,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
 
          if (cmp > 0)
            {
-             if (noisy)
-               {
-                 error_with_progname = false;
-                 error_at_line (0, 0, pos->file_name, pos->line_number,
-                                _("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
-                                spec2->numbered[j].number, pretty_msgstr);
-                 error_with_progname = true;
-               }
+             if (error_logger)
+               error_logger (_("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
+                             spec2->numbered[j].number, pretty_msgstr);
              err = true;
              break;
            }
@@ -402,14 +396,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
            {
              if (equality)
                {
-                 if (noisy)
-                   {
-                     error_with_progname = false;
-                     error_at_line (0, 0, pos->file_name, pos->line_number,
-                                    _("a format specification for argument %u doesn't exist in '%s'"),
-                                    spec1->numbered[i].number, pretty_msgstr);
-                     error_with_progname = true;
-                   }
+                 if (error_logger)
+                   error_logger (_("a format specification for argument %u doesn't exist in '%s'"),
+                                 spec1->numbered[i].number, pretty_msgstr);
                  err = true;
                  break;
                }
@@ -427,15 +416,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
              {
                if (spec1->numbered[i].type != spec2->numbered[j].type)
                  {
-                   if (noisy)
-                     {
-                       error_with_progname = false;
-                       error_at_line (0, 0, pos->file_name, pos->line_number,
-                                      _("format specifications in 'msgid' and '%s' for argument %u are not the same"),
-                                      pretty_msgstr,
-                                      spec2->numbered[j].number);
-                       error_with_progname = true;
-                     }
+                   if (error_logger)
+                     error_logger (_("format specifications in 'msgid' and '%s' for argument %u are not the same"),
+                                   pretty_msgstr, spec2->numbered[j].number);
                    err = true;
                    break;
                  }
index 5da2c14dbbf96e6cdce778d8a69b97f8d207f042..5604c4831a7fe9e7fcb9115907fb5acd15c91a65 100644 (file)
@@ -26,8 +26,6 @@
 
 #include "format.h"
 #include "xalloc.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -162,8 +160,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -191,14 +190,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
            {
              if (equality)
                {
-                 if (noisy)
-                   {
-                     error_with_progname = false;
-                     error_at_line (0, 0, pos->file_name, pos->line_number,
-                                    _("a format specification for argument '%s' doesn't exist in '%s'"),
-                                    spec1->named[i].name, pretty_msgstr);
-                     error_with_progname = true;
-                   }
+                 if (error_logger)
+                   error_logger (_("a format specification for argument '%s' doesn't exist in '%s'"),
+                                 spec1->named[i].name, pretty_msgstr);
                  err = true;
                  break;
                }
index 9131adfe9039a4f3e40b7e6ac35034f7db11bf89..976741e72e49ba79c565d7883c723e06ddd37dad 100644 (file)
@@ -28,8 +28,6 @@
 #include "xalloc.h"
 #include "xerror.h"
 #include "format-invalid.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -539,8 +537,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -564,14 +563,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
 
          if (cmp > 0)
            {
-             if (noisy)
-               {
-                 error_with_progname = false;
-                 error_at_line (0, 0, pos->file_name, pos->line_number,
-                                _("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
-                                spec2->numbered[j].number, pretty_msgstr);
-                 error_with_progname = true;
-               }
+             if (error_logger)
+               error_logger (_("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
+                             spec2->numbered[j].number, pretty_msgstr);
              err = true;
              break;
            }
@@ -579,14 +573,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
            {
              if (equality)
                {
-                 if (noisy)
-                   {
-                     error_with_progname = false;
-                     error_at_line (0, 0, pos->file_name, pos->line_number,
-                                    _("a format specification for argument %u doesn't exist in '%s'"),
-                                    spec1->numbered[i].number, pretty_msgstr);
-                     error_with_progname = true;
-                   }
+                 if (error_logger)
+                   error_logger (_("a format specification for argument %u doesn't exist in '%s'"),
+                                 spec1->numbered[i].number, pretty_msgstr);
                  err = true;
                  break;
                }
@@ -604,15 +593,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
              {
                if (spec1->numbered[i].type != spec2->numbered[j].type)
                  {
-                   if (noisy)
-                     {
-                       error_with_progname = false;
-                       error_at_line (0, 0, pos->file_name, pos->line_number,
-                                      _("format specifications in 'msgid' and '%s' for argument %u are not the same"),
-                                      pretty_msgstr,
-                                      spec2->numbered[j].number);
-                       error_with_progname = true;
-                     }
+                   if (error_logger)
+                     error_logger (_("format specifications in 'msgid' and '%s' for argument %u are not the same"),
+                                   pretty_msgstr, spec2->numbered[j].number);
                    err = true;
                    break;
                  }
index 87d6d34d0d901c6bfa56016ccfca687fe97d8d61..72a707e2acef6487ce7a15e63f514206a310bbe5 100644 (file)
@@ -28,8 +28,6 @@
 #include "xalloc.h"
 #include "xerror.h"
 #include "format-invalid.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -309,8 +307,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -334,14 +333,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
 
          if (cmp > 0)
            {
-             if (noisy)
-               {
-                 error_with_progname = false;
-                 error_at_line (0, 0, pos->file_name, pos->line_number,
-                                _("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
-                                spec2->numbered[j].number, pretty_msgstr);
-                 error_with_progname = true;
-               }
+             if (error_logger)
+               error_logger (_("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
+                             spec2->numbered[j].number, pretty_msgstr);
              err = true;
              break;
            }
@@ -349,14 +343,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
            {
              if (equality)
                {
-                 if (noisy)
-                   {
-                     error_with_progname = false;
-                     error_at_line (0, 0, pos->file_name, pos->line_number,
-                                    _("a format specification for argument %u doesn't exist in '%s'"),
-                                    spec1->numbered[i].number, pretty_msgstr);
-                     error_with_progname = true;
-                   }
+                 if (error_logger)
+                   error_logger (_("a format specification for argument %u doesn't exist in '%s'"),
+                                 spec1->numbered[i].number, pretty_msgstr);
                  err = true;
                  break;
                }
@@ -374,15 +363,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
              {
                if (spec1->numbered[i].type != spec2->numbered[j].type)
                  {
-                   if (noisy)
-                     {
-                       error_with_progname = false;
-                       error_at_line (0, 0, pos->file_name, pos->line_number,
-                                      _("format specifications in 'msgid' and '%s' for argument %u are not the same"),
-                                      pretty_msgstr,
-                                      spec2->numbered[j].number);
-                       error_with_progname = true;
-                     }
+                   if (error_logger)
+                     error_logger (_("format specifications in 'msgid' and '%s' for argument %u are not the same"),
+                                   pretty_msgstr, spec2->numbered[j].number);
                    err = true;
                    break;
                  }
index 418b9d404cbcc2fdc47ea0cdec9476571f98d379..a92054c942042e8b24dcbd5ddc165a04cebef6b4 100644 (file)
@@ -29,8 +29,6 @@
 #include "xalloc.h"
 #include "xerror.h"
 #include "format-invalid.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -391,8 +389,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -400,26 +399,16 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
 
   if (spec1->named_arg_count > 0 && spec2->unnamed_arg_count > 0)
     {
-      if (noisy)
-       {
-         error_with_progname = false;
-         error_at_line (0, 0, pos->file_name, pos->line_number,
-                        _("format specifications in 'msgid' expect a mapping, those in '%s' expect a tuple"),
-                        pretty_msgstr);
-         error_with_progname = true;
-       }
+      if (error_logger)
+       error_logger (_("format specifications in 'msgid' expect a mapping, those in '%s' expect a tuple"),
+                     pretty_msgstr);
       err = true;
     }
   else if (spec1->unnamed_arg_count > 0 && spec2->named_arg_count > 0)
     {
-      if (noisy)
-       {
-         error_with_progname = false;
-         error_at_line (0, 0, pos->file_name, pos->line_number,
-                        _("format specifications in 'msgid' expect a tuple, those in '%s' expect a mapping"),
-                        pretty_msgstr);
-         error_with_progname = true;
-       }
+      if (error_logger)
+       error_logger (_("format specifications in 'msgid' expect a tuple, those in '%s' expect a mapping"),
+                     pretty_msgstr);
       err = true;
     }
   else
@@ -440,14 +429,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
 
              if (cmp > 0)
                {
-                 if (noisy)
-                   {
-                     error_with_progname = false;
-                     error_at_line (0, 0, pos->file_name, pos->line_number,
-                                    _("a format specification for argument '%s', as in '%s', doesn't exist in 'msgid'"),
-                                    spec2->named[j].name, pretty_msgstr);
-                     error_with_progname = true;
-                   }
+                 if (error_logger)
+                   error_logger (_("a format specification for argument '%s', as in '%s', doesn't exist in 'msgid'"),
+                                 spec2->named[j].name, pretty_msgstr);
                  err = true;
                  break;
                }
@@ -455,14 +439,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
                {
                  if (equality)
                    {
-                     if (noisy)
-                       {
-                         error_with_progname = false;
-                         error_at_line (0, 0, pos->file_name, pos->line_number,
-                                        _("a format specification for argument '%s' doesn't exist in '%s'"),
-                                        spec1->named[i].name, pretty_msgstr);
-                         error_with_progname = true;
-                       }
+                     if (error_logger)
+                       error_logger (_("a format specification for argument '%s' doesn't exist in '%s'"),
+                                     spec1->named[i].name, pretty_msgstr);
                      err = true;
                      break;
                    }
@@ -480,16 +459,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
                  {
                    if (spec1->named[i].type != spec2->named[j].type)
                      {
-                       if (noisy)
-                         {
-                           error_with_progname = false;
-                           error_at_line (0, 0, pos->file_name,
-                                          pos->line_number,
-                                          _("format specifications in 'msgid' and '%s' for argument '%s' are not the same"),
-                                          pretty_msgstr,
-                                          spec2->named[j].name);
-                           error_with_progname = true;
-                         }
+                       if (error_logger)
+                         error_logger (_("format specifications in 'msgid' and '%s' for argument '%s' are not the same"),
+                                       pretty_msgstr, spec2->named[j].name);
                        err = true;
                        break;
                      }
@@ -509,28 +481,18 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
              ? spec1->unnamed_arg_count != spec2->unnamed_arg_count
              : spec1->unnamed_arg_count < spec2->unnamed_arg_count)
            {
-             if (noisy)
-               {
-                 error_with_progname = false;
-                 error_at_line (0, 0, pos->file_name, pos->line_number,
-                                _("number of format specifications in 'msgid' and '%s' does not match"),
-                                pretty_msgstr);
-                 error_with_progname = true;
-               }
+             if (error_logger)
+               error_logger (_("number of format specifications in 'msgid' and '%s' does not match"),
+                             pretty_msgstr);
              err = true;
            }
          else
            for (i = 0; i < spec2->unnamed_arg_count; i++)
              if (spec1->unnamed[i].type != spec2->unnamed[i].type)
                {
-                 if (noisy)
-                   {
-                     error_with_progname = false;
-                     error_at_line (0, 0, pos->file_name, pos->line_number,
-                                    _("format specifications in 'msgid' and '%s' for argument %u are not the same"),
-                                    pretty_msgstr, i + 1);
-                     error_with_progname = true;
-                   }
+                 if (error_logger)
+                   error_logger (_("format specifications in 'msgid' and '%s' for argument %u are not the same"),
+                                 pretty_msgstr, i + 1);
                  err = true;
                }
        }
index 6cd174f8c5747ede13b4716d1d2524e0519c519f..d8116f530072e3b145e10ae49bdf7257e7871658 100644 (file)
@@ -26,8 +26,6 @@
 #include "format.h"
 #include "xalloc.h"
 #include "xerror.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -110,8 +108,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -127,16 +126,11 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
         yield a "Argument missing" warning at runtime.  */
       if (arg_used1 != arg_used2)
        {
-         if (noisy)
-           {
-             error_with_progname = false;
-             error_at_line (0, 0, pos->file_name, pos->line_number,
-                            arg_used1
-                            ? _("a format specification for argument %u doesn't exist in '%s'")
-                            : _("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
-                            i, pretty_msgstr);
-             error_with_progname = true;
-           }
+         if (error_logger)
+           error_logger (arg_used1
+                         ? _("a format specification for argument %u doesn't exist in '%s'")
+                         : _("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
+                         i, pretty_msgstr);
          err = true;
          break;
        }
index 38c25e28694697a3b69e8e9fdd11cb58f24166f5..d884091cb2ded3e0a7d632476fb53f638a850703 100644 (file)
@@ -28,8 +28,6 @@
 #include "c-ctype.h"
 #include "xalloc.h"
 #include "format-invalid.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -259,8 +257,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -282,14 +281,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
 
          if (cmp > 0)
            {
-             if (noisy)
-               {
-                 error_with_progname = false;
-                 error_at_line (0, 0, pos->file_name, pos->line_number,
-                                _("a format specification for argument '%s', as in '%s', doesn't exist in 'msgid'"),
-                                spec2->named[j].name, pretty_msgstr);
-                 error_with_progname = true;
-               }
+             if (error_logger)
+               error_logger (_("a format specification for argument '%s', as in '%s', doesn't exist in 'msgid'"),
+                             spec2->named[j].name, pretty_msgstr);
              err = true;
              break;
            }
@@ -297,14 +291,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
            {
              if (equality)
                {
-                 if (noisy)
-                   {
-                     error_with_progname = false;
-                     error_at_line (0, 0, pos->file_name, pos->line_number,
-                                    _("a format specification for argument '%s' doesn't exist in '%s'"),
-                                    spec1->named[i].name, pretty_msgstr);
-                     error_with_progname = true;
-                   }
+                 if (error_logger)
+                   error_logger (_("a format specification for argument '%s' doesn't exist in '%s'"),
+                                 spec1->named[i].name, pretty_msgstr);
                  err = true;
                  break;
                }
index 4f8d7c1fb2aa9b8ad85f30872abfa4632aa36f13..08b78a68671b14d83f74f1050dbf7385fb79cbb4 100644 (file)
@@ -28,8 +28,6 @@
 #include "xalloc.h"
 #include "xerror.h"
 #include "format-invalid.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -348,8 +346,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -373,14 +372,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
 
          if (cmp > 0)
            {
-             if (noisy)
-               {
-                 error_with_progname = false;
-                 error_at_line (0, 0, pos->file_name, pos->line_number,
-                                _("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
-                                spec2->numbered[j].number, pretty_msgstr);
-                 error_with_progname = true;
-               }
+             if (error_logger)
+               error_logger (_("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
+                             spec2->numbered[j].number, pretty_msgstr);
              err = true;
              break;
            }
@@ -388,14 +382,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
            {
              if (equality)
                {
-                 if (noisy)
-                   {
-                     error_with_progname = false;
-                     error_at_line (0, 0, pos->file_name, pos->line_number,
-                                    _("a format specification for argument %u doesn't exist in '%s'"),
-                                    spec1->numbered[i].number, pretty_msgstr);
-                     error_with_progname = true;
-                   }
+                 if (error_logger)
+                   error_logger (_("a format specification for argument %u doesn't exist in '%s'"),
+                                 spec1->numbered[i].number, pretty_msgstr);
                  err = true;
                  break;
                }
@@ -413,15 +402,9 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
              {
                if (spec1->numbered[i].type != spec2->numbered[j].type)
                  {
-                   if (noisy)
-                     {
-                       error_with_progname = false;
-                       error_at_line (0, 0, pos->file_name, pos->line_number,
-                                      _("format specifications in 'msgid' and '%s' for argument %u are not the same"),
-                                      pretty_msgstr,
-                                      spec2->numbered[j].number);
-                       error_with_progname = true;
-                     }
+                   if (error_logger)
+                     error_logger (_("format specifications in 'msgid' and '%s' for argument %u are not the same"),
+                                   pretty_msgstr, spec2->numbered[j].number);
                    err = true;
                    break;
                  }
index c3799eb05db7fba3cab7fe377af80a8ec61fc48e..803c973731cc498821fba753191b89b0ca8a7c28 100644 (file)
@@ -28,8 +28,6 @@
 #include "xalloc.h"
 #include "xerror.h"
 #include "format-invalid.h"
-#include "error.h"
-#include "error-progname.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -113,8 +111,9 @@ format_get_number_of_directives (void *descr)
 }
 
 static bool
-format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
-             bool equality, bool noisy, const char *pretty_msgstr)
+format_check (void *msgid_descr, void *msgstr_descr, bool equality,
+             formatstring_error_logger_t error_logger,
+             const char *pretty_msgstr)
 {
   struct spec *spec1 = (struct spec *) msgid_descr;
   struct spec *spec2 = (struct spec *) msgstr_descr;
@@ -128,16 +127,11 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr,
 
       if (equality ? (arg_used1 != arg_used2) : (!arg_used1 && arg_used2))
        {
-         if (noisy)
-           {
-             error_with_progname = false;
-             error_at_line (0, 0, pos->file_name, pos->line_number,
-                            arg_used1
-                            ? _("a format specification for argument %u doesn't exist in '%s'")
-                            : _("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
-                            i + 1, pretty_msgstr);
-             error_with_progname = true;
-           }
+         if (error_logger)
+           error_logger (arg_used1
+                         ? _("a format specification for argument %u doesn't exist in '%s'")
+                         : _("a format specification for argument %u, as in '%s', doesn't exist in 'msgid'"),
+                         i + 1, pretty_msgstr);
          err = true;
          break;
        }
index eef4dd8cb6e84db0f9e0ee1ca61c06356fbbdcf5..38d9be75f30f9a3bf3c995d060f01fadaa29865b 100644 (file)
@@ -1,5 +1,5 @@
 /* Format strings.
-   Copyright (C) 2001-2003 Free Software Foundation, Inc.
+   Copyright (C) 2001-2004 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
    This program is free software; you can redistribute it and/or modify
 /* Specification.  */
 #include "format.h"
 
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "message.h"
+#include "gettext.h"
+
+#define _(str) gettext (str)
+
 /* Table of all format string parsers.  */
 struct formatstring_parser *formatstring_parsers[NFORMATS] =
 {
@@ -46,3 +54,89 @@ struct formatstring_parser *formatstring_parsers[NFORMATS] =
   /* format_gcc_internal */    &formatstring_gcc_internal,
   /* format_qt */              &formatstring_qt
 };
+
+/* Check whether both formats strings contain compatible format
+   specifications.  Return true if there is an error.  */
+bool
+check_msgid_msgstr_format (const char *msgid, const char *msgid_plural,
+                          const char *msgstr, size_t msgstr_len,
+                          enum is_format is_format[NFORMATS],
+                          formatstring_error_logger_t error_logger)
+{
+  bool err = false;
+  size_t i;
+  unsigned int j;
+
+  /* We check only those messages for which the msgid's is_format flag
+     is one of 'yes' or 'possible'.  We don't check msgids with is_format
+     'no' or 'impossible', to obey the programmer's order.  We don't check
+     msgids with is_format 'undecided' because that would introduce too
+     many checks, thus forcing the programmer to add "xgettext: no-c-format"
+     anywhere where a translator wishes to use a percent sign.  */
+  for (i = 0; i < NFORMATS; i++)
+    if (possible_format_p (is_format[i]))
+      {
+       /* At runtime, we can assume the program passes arguments that
+          fit well for msgid.  We must signal an error if msgstr wants
+          more arguments that msgid accepts.
+          If msgstr wants fewer arguments than msgid, it wouldn't lead
+          to a crash at runtime, but we nevertheless give an error because
+          1) this situation occurs typically after the programmer has
+             added some arguments to msgid, so we must make the translator
+             specially aware of it (more than just "fuzzy"),
+          2) it is generally wrong if a translation wants to ignore
+             arguments that are used by other translations.  */
+
+       struct formatstring_parser *parser = formatstring_parsers[i];
+       char *invalid_reason = NULL;
+       void *msgid_descr =
+         parser->parse (msgid_plural != NULL ? msgid_plural : msgid,
+                        false, &invalid_reason);
+
+       if (msgid_descr != NULL)
+         {
+           char buf[18+1];
+           const char *pretty_msgstr = "msgstr";
+           const char *p_end = msgstr + msgstr_len;
+           const char *p;
+
+           for (p = msgstr, j = 0; p < p_end; p += strlen (p) + 1, j++)
+             {
+               void *msgstr_descr;
+
+               if (msgid_plural != NULL)
+                 {
+                   sprintf (buf, "msgstr[%u]", j);
+                   pretty_msgstr = buf;
+                 }
+
+               msgstr_descr = parser->parse (p, true, &invalid_reason);
+
+               if (msgstr_descr != NULL)
+                 {
+                   if (parser->check (msgid_descr, msgstr_descr,
+                                      msgid_plural == NULL,
+                                      error_logger, pretty_msgstr))
+                     err = true;
+
+                   parser->free (msgstr_descr);
+                 }
+               else
+                 {
+                   error_logger (_("\
+'%s' is not a valid %s format string, unlike 'msgid'. Reason: %s"),
+                                 pretty_msgstr, format_language_pretty[i],
+                                 invalid_reason);
+                   err = true;
+                   free (invalid_reason);
+                 }
+             }
+
+           parser->free (msgid_descr);
+         }
+       else
+         free (invalid_reason);
+      }
+
+  return err;
+}
index b28c0a5bf00f344314c279dab558784859f7c495..f4474e0bd6130ff4df6633a4ba62e235719870e7 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "pos.h"       /* Get lex_pos_ty.  */
 #include "message.h"   /* Get NFORMATS.  */
+#include "error.h"     /* Get fallback definition of __attribute__.  */
 
 
 #ifdef __cplusplus
@@ -30,6 +31,10 @@ extern "C" {
 #endif
 
 
+/* This type of callback is responsible for showing an error.  */
+typedef void (*formatstring_error_logger_t) (const char *format, ...)
+     __attribute__ ((__format__ (__printf__, 1, 2)));
+
 /* This structure describes a format string parser for a language.  */
 struct formatstring_parser
 {
@@ -54,12 +59,9 @@ struct formatstring_parser
      msgstr_descr are the same (if equality=true), or (if equality=false)
      that those of msgid_descr extend those of msgstr_descr (i.e.
      msgstr_descr may omit some of the arguments of msgid_descr).
-     If not, signal an error using
-       error_with_progname = false;
-       error_at_line (0, 0, pos->file_name, pos->line_number, ...);
-       error_with_progname = true;
-     (but only if noisy=true) and return true.  Otherwise return false.  */
-  bool (*check) (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr, bool equality, bool noisy, const char *pretty_msgstr);
+     If not, signal an error using error_logger (only if error_logger != NULL)
+     and return true.  Otherwise return false.  */
+  bool (*check) (void *msgid_descr, void *msgstr_descr, bool equality, formatstring_error_logger_t error_logger, const char *pretty_msgstr);
 };
 
 /* Format string parsers, each defined in its own file.  */
@@ -100,6 +102,14 @@ extern void
        get_sysdep_c_format_directives (const char *string, bool translated,
                                 struct interval **intervalsp, size_t *lengthp);
 
+/* Check whether both formats strings contain compatible format
+   specifications.  Return true if there is an error.  */
+extern bool
+       check_msgid_msgstr_format (const char *msgid, const char *msgid_plural,
+                                 const char *msgstr, size_t msgstr_len,
+                                 enum is_format is_format[NFORMATS],
+                                 formatstring_error_logger_t error_logger);
+
 
 #ifdef __cplusplus
 }
index 2a4e6252229c9c72a7a8d5e869304cd4f065dfe3..8092a56249767c83d91faf2bc90b10c530aa79d6 100644 (file)
@@ -26,6 +26,7 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdarg.h>
 
 #include "message.h"
 #include "xalloc.h"
@@ -34,6 +35,8 @@
 #include "error.h"
 #include "xerror.h"
 #include "po-error.h"
+#include "vasprintf.h"
+#include "format.h"
 #include "gettext.h"
 
 #define _(str) gettext(str)
@@ -706,17 +709,39 @@ po_message_set_format (po_message_t message, const char *format_type, /*bool*/in
 }
 
 
-#if 0
-/* Test whether the message translation is a valid format string if the message
-   is marked as being a format string.  Return NULL if valid or not marked as
-   such, or an explanation string if invalid.  */
+/* An error logger based on the po_error function pointer.  */
+static void
+po_error_logger (const char *format, ...)
+{
+  va_list args;
+  char *error_message;
 
-char *
-po_message_check_format (po_message_t message, const char *format_type)
+  va_start (args, format);
+  if (vasprintf (&error_message, format, args) < 0)
+    error (EXIT_FAILURE, 0, _("memory exhausted"));
+  va_end (args);
+  po_error (0, 0, "%s", error_message);
+  free (error_message);
+}
+
+/* Test whether the message translation is a valid format string if the message
+   is marked as being a format string.  If it is invalid, pass the reasons to
+   the handler.  */
+void
+po_message_check_format (po_message_t message, po_error_handler_t handler)
 {
-  ??
+  message_ty *mp = (message_ty *) message;
+
+  /* Establish error handler for po_error_logger().  */
+  po_error = handler->error;
+
+  check_msgid_msgstr_format (mp->msgid, mp->msgid_plural,
+                            mp->msgstr, mp->msgstr_len,
+                            mp->is_format, po_error_logger);
+
+  /* Restore error handler.  */
+  po_error = error;
 }
-#endif
 
 
 /* Return the file name.  */
index e735652aec3ee8c55157f1201de011f1efa494cc..a11c1f9128a9364223d24342c12ea1d011535c46 100644 (file)
@@ -203,12 +203,10 @@ extern int po_message_is_format (po_message_t message, const char *format_type);
 /* Change the format string mark for a given type of a message.  */
 extern void po_message_set_format (po_message_t message, const char *format_type, /*bool*/int value);
 
-#if 0
 /* Test whether the message translation is a valid format string if the message
-   is marked as being a format string.  Return NULL if valid or not marked as
-   such, or an explanation string if invalid.  */
-extern char * po_message_check_format (po_message_t message, const char *format_type);
-#endif
+   is marked as being a format string.  If it is invalid, pass the reasons to
+   the handler.  */
+extern void po_message_check_format (po_message_t message, po_error_handler_t handler);
 
 
 /* =========================== po_filepos_t API ============================ */
index 209953b0bf27a599ba92090688fd507d0ac85677..23cac957a73549a89e526f57177323111c918b28 100644 (file)
@@ -28,6 +28,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdarg.h>
 #include <locale.h>
 
 #include "closeout.h"
@@ -1142,6 +1143,24 @@ check_plural (message_list_ty *mlp)
 }
 
 
+/* Signal an error when checking format strings.  */
+static lex_pos_ty curr_msgid_pos;
+static void
+formatstring_error_logger (const char *format, ...)
+{
+  va_list args;
+
+  va_start (args, format);
+  fprintf (stderr, "%s:%d: ",
+          curr_msgid_pos.file_name, curr_msgid_pos.line_number);
+  vfprintf (stderr, format, args);
+  putc ('\n', stderr);
+  fflush (stderr);
+  va_end (args);
+  ++error_message_count;
+}
+
+
 /* Perform miscellaneous checks on a message.  */
 static void
 check_pair (const char *msgid,
@@ -1151,7 +1170,6 @@ check_pair (const char *msgid,
            const lex_pos_ty *msgstr_pos, enum is_format is_format[NFORMATS])
 {
   int has_newline;
-  size_t i;
   unsigned int j;
   const char *p;
 
@@ -1249,81 +1267,13 @@ check_pair (const char *msgid,
 
   if (check_format_strings)
     /* Test 3: Check whether both formats strings contain the same number
-       of format specifications.
-       We check only those messages for which the msgid's is_format flag
-       is one of 'yes' or 'possible'.  We don't check msgids with is_format
-       'no' or 'impossible', to obey the programmer's order.  We don't check
-       msgids with is_format 'undecided' because that would introduce too
-       many checks, thus forcing the programmer to add "xgettext: no-c-format"
-       anywhere where a translator wishes to use a percent sign.  */
-    for (i = 0; i < NFORMATS; i++)
-      if (possible_format_p (is_format[i]))
-       {
-         /* At runtime, we can assume the program passes arguments that
-            fit well for msgid.  We must signal an error if msgstr wants
-            more arguments that msgid accepts.
-            If msgstr wants fewer arguments than msgid, it wouldn't lead
-            to a crash at runtime, but we nevertheless give an error because
-            1) this situation occurs typically after the programmer has
-               added some arguments to msgid, so we must make the translator
-               specially aware of it (more than just "fuzzy"),
-            2) it is generally wrong if a translation wants to ignore
-               arguments that are used by other translations.  */
-
-         struct formatstring_parser *parser = formatstring_parsers[i];
-         char *invalid_reason = NULL;
-         void *msgid_descr =
-           parser->parse (msgid_plural != NULL ? msgid_plural : msgid,
-                          false, &invalid_reason);
-
-         if (msgid_descr != NULL)
-           {
-             char buf[18+1];
-             const char *pretty_msgstr = "msgstr";
-             const char *p_end = msgstr + msgstr_len;
-             const char *p;
-
-             for (p = msgstr, j = 0; p < p_end; p += strlen (p) + 1, j++)
-               {
-                 void *msgstr_descr;
-
-                 if (msgid_plural != NULL)
-                   {
-                     sprintf (buf, "msgstr[%u]", j);
-                     pretty_msgstr = buf;
-                   }
-
-                 msgstr_descr = parser->parse (p, true, &invalid_reason);
-
-                 if (msgstr_descr != NULL)
-                   {
-                     if (parser->check (msgid_pos, msgid_descr, msgstr_descr,
-                                        msgid_plural == NULL,
-                                        true, pretty_msgstr))
-                       exit_status = EXIT_FAILURE;
-
-                     parser->free (msgstr_descr);
-                   }
-                 else
-                   {
-                     error_with_progname = false;
-                     error_at_line (0, 0, msgid_pos->file_name,
-                                    msgid_pos->line_number,
-                                    _("\
-'%s' is not a valid %s format string, unlike 'msgid'. Reason: %s"),
-                                    pretty_msgstr, format_language_pretty[i],
-                                    invalid_reason);
-                     error_with_progname = true;
-                     exit_status = EXIT_FAILURE;
-                     free (invalid_reason);
-                   }
-               }
-
-             parser->free (msgid_descr);
-           }
-         else
-           free (invalid_reason);
-       }
+       of format specifications.  */
+    {
+      curr_msgid_pos = *msgid_pos;
+      if (check_msgid_msgstr_format (msgid, msgid_plural, msgstr, msgstr_len,
+                                    is_format, formatstring_error_logger))
+       exit_status = EXIT_FAILURE;
+    }
 
   if (check_accelerators && msgid_plural == NULL)
     /* Test 4: Check that if msgid is a menu item with a keyboard accelerator,
index 3a4478ef723b61dcad6a7c193877733cc7e12179..3e9f464c644b424fb4a7e19f81a6840a702e46aa 100644 (file)
@@ -591,8 +591,8 @@ msgfmt_check_pair_fails (const lex_pos_ty *pos,
 
          if (msgstr_descr != NULL)
            {
-             failure = parser->check (pos, msgid_descr, msgstr_descr,
-                                      msgid_plural == NULL, false, NULL);
+             failure = parser->check (msgid_descr, msgstr_descr,
+                                      msgid_plural == NULL, NULL, NULL);
              parser->free (msgstr_descr);
            }
          else
index a5440699ef0aeca3447d2fffd7b0526c9c20f798..c0f307f8772dc2f45fd6985750baff7d48d333e4 100644 (file)
@@ -10,6 +10,7 @@ po_file_write
 po_filepos_file
 po_filepos_start_line
 po_header_field
+po_message_check_format
 po_message_comments
 po_message_create
 po_message_extracted_comments