]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Make checking stricter when nplurals=1.
authorBruno Haible <bruno@clisp.org>
Tue, 4 Oct 2005 13:21:14 +0000 (13:21 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:12:52 +0000 (12:12 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/format.c

index 0a806f0e1e36cc2dc17e44aab31c0253b635db14..95b2ef9365d6717eb1104977e5798f6ee2fb262b 100644 (file)
@@ -1,3 +1,10 @@
+2005-10-04  Bruno Haible  <bruno@clisp.org>
+
+       * format.c: Include stdbool.h.
+       (check_msgid_msgstr_format): Enable strict checking also when
+       msgid_plural is present but nplurals = 1.
+       Reported by Farzaneh Sarafraz <farzaneh@farsiweb.info>.
+
 2005-10-01  Bruno Haible  <bruno@clisp.org>
 
        Change msgattrib to no longer remove extracted comments and file
index 9c0b11e486f7f48e33e0c1838105f1ef2b020405..6ebd367a620fd77091e8ec117f26355868fddacc 100644 (file)
@@ -23,6 +23,7 @@
 /* Specification.  */
 #include "format.h"
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -98,6 +99,15 @@ check_msgid_msgstr_format (const char *msgid, const char *msgid_plural,
          {
            char buf[18+1];
            const char *pretty_msgstr = "msgstr";
+           /* Use strict checking (require same number of format directives
+              on both sides) if the message has no plurals, or if msgid_plural
+              exists but on the msgstr[] side there is only msgstr[0].
+              Use relaxed checking when there are at least two msgstr[] forms.
+              We are too lazy to check which of the plural forms applies to
+              infinitely many values of N.  */
+           bool has_plural_translations = (strlen (msgstr) + 1 < msgstr_len);
+           bool strict_checking =
+             (msgid_plural == NULL || !has_plural_translations);
            const char *p_end = msgstr + msgstr_len;
            const char *p;
 
@@ -116,7 +126,7 @@ check_msgid_msgstr_format (const char *msgid, const char *msgid_plural,
                if (msgstr_descr != NULL)
                  {
                    if (parser->check (msgid_descr, msgstr_descr,
-                                      msgid_plural == NULL,
+                                      strict_checking,
                                       error_logger, pretty_msgstr))
                      err = true;