]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
msgfmt: Accumulate errors when parsing the PO header
authorDaiki Ueno <ueno@gnu.org>
Tue, 13 May 2014 06:16:39 +0000 (15:16 +0900)
committerDaiki Ueno <ueno@gnu.org>
Tue, 13 May 2014 06:19:24 +0000 (15:19 +0900)
Problem reported by Peter Eisentraut at
<https://savannah.gnu.org/bugs/?40262>.
* msgl-check.c (check_header_entry): Return the number of errors.
(check_message): Check the return value of check_header_entry.

gettext-tools/src/ChangeLog
gettext-tools/src/msgl-check.c

index a6a238777c7e5a60646bd829a5cb93af5f83f79b..0a3a8a5f6b178f14a52393847f4fe75ae7b9a74d 100644 (file)
@@ -1,3 +1,11 @@
+2014-05-13  Daiki Ueno  <ueno@gnu.org>
+
+       msgfmt: Accumulate errors when parsing the PO header
+       Problem reported by Peter Eisentraut at
+       <https://savannah.gnu.org/bugs/?40262>.
+       * msgl-check.c (check_header_entry): Return the number of errors.
+       (check_message): Check the return value of check_header_entry.
+
 2014-05-13  Felipe Sateler <fsateler@debian.org>  (tiny change)
 
        project-id: Add missing quotes around `pwd` for basename
index f8d2d68f3b5dfa47079f856165e7a83e55730cda..8f1ddd0dca0cc123aa9ad8e5fe84430401324d2d 100644 (file)
@@ -751,7 +751,7 @@ plural handling is a GNU gettext extension"));
 
 
 /* Perform miscellaneous checks on a header entry.  */
-static void
+static int
 check_header_entry (const message_ty *mp, const char *msgstr_string)
 {
   static const char *required_fields[] =
@@ -770,6 +770,7 @@ check_header_entry (const message_ty *mp, const char *msgstr_string)
   };
   const size_t nfields = SIZEOF (required_fields);
   const size_t nrequiredfields = nfields - 1;
+  int seen_errors = 0;
   int cnt;
 
   for (cnt = 0; cnt < nfields; ++cnt)
@@ -797,11 +798,12 @@ check_header_entry (const message_ty *mp, const char *msgstr_string)
                   p += strlen (default_values[cnt]);
                   if (*p == '\0' || *p == '\n')
                     {
-                     char *msg =
-                       xasprintf (_("header field '%s' still has the initial default value\n"),
-                                  field);
-                     po_xerror (severity, mp, NULL, 0, 0, true, msg);
-                     free (msg);
+                      char *msg =
+                        xasprintf (_("header field '%s' still has the initial default value\n"),
+                                   field);
+                      po_xerror (severity, mp, NULL, 0, 0, true, msg);
+                      free (msg);
+                      seen_errors++;
                     }
                 }
               break;
@@ -817,8 +819,10 @@ check_header_entry (const message_ty *mp, const char *msgstr_string)
                        field);
           po_xerror (severity, mp, NULL, 0, 0, true, msg);
           free (msg);
+          seen_errors++;
         }
     }
+  return seen_errors;
 }
 
 
@@ -834,18 +838,21 @@ check_message (const message_ty *mp,
                int check_compatibility,
                int check_accelerators, char accelerator_char)
 {
+  int seen_errors = 0;
+
   if (check_header && is_header (mp))
-    check_header_entry (mp, mp->msgstr);
-
-  return check_pair (mp,
-                     mp->msgid, msgid_pos, mp->msgid_plural,
-                     mp->msgstr, mp->msgstr_len,
-                     mp->is_format,
-                     check_newlines,
-                     check_format_strings,
-                     distribution,
-                     check_compatibility,
-                     check_accelerators, accelerator_char);
+    seen_errors += check_header_entry (mp, mp->msgstr);
+
+  seen_errors += check_pair (mp,
+                             mp->msgid, msgid_pos, mp->msgid_plural,
+                             mp->msgstr, mp->msgstr_len,
+                             mp->is_format,
+                             check_newlines,
+                             check_format_strings,
+                             distribution,
+                             check_compatibility,
+                             check_accelerators, accelerator_char);
+  return seen_errors;
 }