From: Bruno Haible Date: Tue, 4 Oct 2005 13:21:14 +0000 (+0000) Subject: Make checking stricter when nplurals=1. X-Git-Tag: v0.15~384 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed57877a4b9bdafa4dbec9d9987cc6e63d22e06f;p=thirdparty%2Fgettext.git Make checking stricter when nplurals=1. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 0a806f0e1..95b2ef936 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,10 @@ +2005-10-04 Bruno Haible + + * 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 . + 2005-10-01 Bruno Haible Change msgattrib to no longer remove extracted comments and file diff --git a/gettext-tools/src/format.c b/gettext-tools/src/format.c index 9c0b11e48..6ebd367a6 100644 --- a/gettext-tools/src/format.c +++ b/gettext-tools/src/format.c @@ -23,6 +23,7 @@ /* Specification. */ #include "format.h" +#include #include #include @@ -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;