summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gettext-tools/libgettextpo/ChangeLog5
-rw-r--r--gettext-tools/libgettextpo/gettext-po.c4
-rw-r--r--gettext-tools/src/ChangeLog10
-rw-r--r--gettext-tools/src/format.c6
-rw-r--r--gettext-tools/src/format.h2
-rw-r--r--gettext-tools/src/msgl-check.c46
-rw-r--r--gettext-tools/src/msgl-check.h7
7 files changed, 64 insertions, 16 deletions
diff --git a/gettext-tools/libgettextpo/ChangeLog b/gettext-tools/libgettextpo/ChangeLog
index 52cfde2..381b99b 100644
--- a/gettext-tools/libgettextpo/ChangeLog
+++ b/gettext-tools/libgettextpo/ChangeLog
@@ -1,3 +1,8 @@
+2007-10-20 Bruno Haible <bruno@clisp.org>
+
+ * gettext-po.c (po_message_check_format): Update call to check_message,
+ check_msgid_msgstr_format.
+
2007-10-07 Bruno Haible <bruno@clisp.org>
* libgettextpo.rc (Comments): Update.
diff --git a/gettext-tools/libgettextpo/gettext-po.c b/gettext-tools/libgettextpo/gettext-po.c
index 0125d5a..a4ca300 100644
--- a/gettext-tools/libgettextpo/gettext-po.c
+++ b/gettext-tools/libgettextpo/gettext-po.c
@@ -1219,7 +1219,7 @@ po_message_check_format (po_message_t message, po_xerror_handler_t handler)
handler->xerror2;
if (!mp->obsolete)
- check_message (mp, &mp->pos, 0, 1, NULL, 0, 0, 0, 0);
+ check_message (mp, &mp->pos, 0, 1, NULL, 0, 0, 0, 0, 0);
/* Restore error handler. */
po_xerror = textmode_xerror;
@@ -1263,7 +1263,7 @@ po_message_check_format (po_message_t message, po_error_handler_t handler)
check_msgid_msgstr_format (mp->msgid, mp->msgid_plural,
mp->msgstr, mp->msgstr_len,
- mp->is_format, NULL, po_error_logger);
+ mp->is_format, NULL, 0, po_error_logger);
/* Restore error handler. */
po_error = error;
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index e94ba3e..538d5dd 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,3 +1,13 @@
+2007-10-20 Bruno Haible <bruno@clisp.org>
+
+ * format.h (check_msgid_msgstr_format): Add plural_distribution_length
+ argument.
+ * format.c (check_msgid_msgstr_format): Likewise.
+ * msgl-check.h (check_message): Likewise.
+ * msgl-check.c (check_plural_eval, check_plural, check_pair,
+ check_message): Likewise.
+ (check_message_list): Update.
+
2007-10-18 Bruno Haible <bruno@clisp.org>
* plural-count.c (get_plural_count): Adapt to changed prototype of
diff --git a/gettext-tools/src/format.c b/gettext-tools/src/format.c
index 0ac6654..f85fa14 100644
--- a/gettext-tools/src/format.c
+++ b/gettext-tools/src/format.c
@@ -63,12 +63,14 @@ struct formatstring_parser *formatstring_parsers[NFORMATS] =
PLURAL_DISTRIBUTION is either NULL or an array of nplurals elements,
PLURAL_DISTRIBUTION[j] being true if the value j appears to be assumed
infinitely often by the plural formula.
+ PLURAL_DISTRIBUTION_LENGTH is the length of the PLURAL_DISTRIBUTION array.
Return the number of errors that were seen. */
int
check_msgid_msgstr_format (const char *msgid, const char *msgid_plural,
const char *msgstr, size_t msgstr_len,
const enum is_format is_format[NFORMATS],
const unsigned char *plural_distribution,
+ unsigned long plural_distribution_length,
formatstring_error_logger_t error_logger)
{
int seen_errors = 0;
@@ -135,7 +137,9 @@ check_msgid_msgstr_format (const char *msgid, const char *msgid_plural,
bool strict_checking =
(msgid_plural == NULL
|| !has_plural_translations
- || (plural_distribution != NULL && plural_distribution[j]));
+ || (plural_distribution != NULL
+ && j < plural_distribution_length
+ && plural_distribution[j]));
if (parser->check (msgid_descr, msgstr_descr,
strict_checking,
diff --git a/gettext-tools/src/format.h b/gettext-tools/src/format.h
index 718482a..df5d37e 100644
--- a/gettext-tools/src/format.h
+++ b/gettext-tools/src/format.h
@@ -143,12 +143,14 @@ extern unsigned int get_python_format_unnamed_arg_count (const char *string);
PLURAL_DISTRIBUTION is either NULL or an array of nplurals elements,
PLURAL_DISTRIBUTION[j] being true if the value j appears to be assumed
infinitely often by the plural formula.
+ PLURAL_DISTRIBUTION_LENGTH is the length of the PLURAL_DISTRIBUTION array.
Return the number of errors that were seen. */
extern int
check_msgid_msgstr_format (const char *msgid, const char *msgid_plural,
const char *msgstr, size_t msgstr_len,
const enum is_format is_format[NFORMATS],
const unsigned char *plural_distribution,
+ unsigned long plural_distribution_length,
formatstring_error_logger_t error_logger);
diff --git a/gettext-tools/src/msgl-check.c b/gettext-tools/src/msgl-check.c
index ca1c277..0baee30 100644
--- a/gettext-tools/src/msgl-check.c
+++ b/gettext-tools/src/msgl-check.c
@@ -51,12 +51,14 @@
Return the number of errors that were seen.
If no errors, returns in *PLURAL_DISTRIBUTION either NULL or an array
of length NPLURALS_VALUE describing which plural formula values appear
- infinitely often. */
+ infinitely often and in *PLURAL_DISTRIBUTION_LENGTH the length of this
+ array. */
static int
check_plural_eval (struct expression *plural_expr,
unsigned long nplurals_value,
const message_ty *header,
- unsigned char **plural_distribution)
+ unsigned char **plural_distribution,
+ unsigned long *plural_distribution_length)
{
/* Do as if the plural formula assumes a value N infinitely often if it
assumes it at least 5 times. */
@@ -118,7 +120,10 @@ check_plural_eval (struct expression *plural_expr,
for (val = 0; val < nplurals_value; val++)
distribution[val] = (distribution[val] == OFTEN ? 1 : 0);
+ *plural_distribution_length = nplurals_value;
}
+ else
+ *plural_distribution_length = 0;
*plural_distribution = distribution;
return 0;
@@ -196,9 +201,12 @@ plural_help (const char *nullentry)
/* Perform plural expression checking.
Return the number of errors that were seen.
If no errors, returns in *PLURAL_DISTRIBUTION either NULL or an array
- describing which plural formula values appear infinitely often. */
+ describing which plural formula values appear infinitely often and in
+ *PLURAL_DISTRIBUTION_LENGTH the length of this array. */
static int
-check_plural (message_list_ty *mlp, unsigned char **plural_distribution)
+check_plural (message_list_ty *mlp,
+ unsigned char **plural_distribution,
+ unsigned long *plural_distribution_length)
{
int seen_errors = 0;
const message_ty *has_plural;
@@ -209,6 +217,7 @@ check_plural (message_list_ty *mlp, unsigned char **plural_distribution)
size_t j;
message_ty *header;
unsigned char *distribution = NULL;
+ unsigned long distribution_length = 0;
/* Determine whether mlp has plural entries. */
has_plural = NULL;
@@ -369,7 +378,7 @@ check_plural (message_list_ty *mlp, unsigned char **plural_distribution)
if (!seen_errors)
seen_errors =
check_plural_eval (plural_expr, nplurals_value, header,
- &distribution);
+ &distribution, &distribution_length);
/* Check the number of plurals of the translations. */
if (!seen_errors)
@@ -427,8 +436,10 @@ check_plural (message_list_ty *mlp, unsigned char **plural_distribution)
{
free (distribution);
distribution = NULL;
+ distribution_length = 0;
}
*plural_distribution = distribution;
+ *plural_distribution_length = distribution_length;
return seen_errors;
}
@@ -460,7 +471,9 @@ formatstring_error_logger (const char *format, ...)
/* Perform miscellaneous checks on a message.
PLURAL_DISTRIBUTION is either NULL or an array of nplurals elements,
PLURAL_DISTRIBUTION[j] being true if the value j appears to be assumed
- infinitely often by the plural formula. */
+ infinitely often by the plural formula.
+ PLURAL_DISTRIBUTION_LENGTH is the length of the PLURAL_DISTRIBUTION
+ array. */
static int
check_pair (const message_ty *mp,
const char *msgid,
@@ -469,7 +482,9 @@ check_pair (const message_ty *mp,
const char *msgstr, size_t msgstr_len,
const enum is_format is_format[NFORMATS],
int check_newlines,
- int check_format_strings, const unsigned char *plural_distribution,
+ int check_format_strings,
+ const unsigned char *plural_distribution,
+ unsigned long plural_distribution_length,
int check_compatibility,
int check_accelerators, char accelerator_char)
{
@@ -587,6 +602,7 @@ plural handling is a GNU gettext extension"));
seen_errors +=
check_msgid_msgstr_format (msgid, msgid_plural, msgstr, msgstr_len,
is_format, plural_distribution,
+ plural_distribution_length,
formatstring_error_logger);
}
@@ -712,12 +728,15 @@ some header fields still have the initial default value\n"));
PLURAL_DISTRIBUTION is either NULL or an array of nplurals elements,
PLURAL_DISTRIBUTION[j] being true if the value j appears to be assumed
infinitely often by the plural formula.
+ PLURAL_DISTRIBUTION_LENGTH is the length of the PLURAL_DISTRIBUTION array.
Return the number of errors that were seen. */
int
check_message (const message_ty *mp,
const lex_pos_ty *msgid_pos,
int check_newlines,
- int check_format_strings, const unsigned char *plural_distribution,
+ int check_format_strings,
+ const unsigned char *plural_distribution,
+ unsigned long plural_distribution_length,
int check_header,
int check_compatibility,
int check_accelerators, char accelerator_char)
@@ -730,7 +749,8 @@ check_message (const message_ty *mp,
mp->msgstr, mp->msgstr_len,
mp->is_format,
check_newlines,
- check_format_strings, plural_distribution,
+ check_format_strings,
+ plural_distribution, plural_distribution_length,
check_compatibility,
check_accelerators, accelerator_char);
}
@@ -748,10 +768,12 @@ check_message_list (message_list_ty *mlp,
{
int seen_errors = 0;
unsigned char *plural_distribution = NULL;
+ unsigned long plural_distribution_length = 0;
size_t j;
if (check_header)
- seen_errors += check_plural (mlp, &plural_distribution);
+ seen_errors +=
+ check_plural (mlp, &plural_distribution, &plural_distribution_length);
for (j = 0; j < mlp->nitems; j++)
{
@@ -760,7 +782,9 @@ check_message_list (message_list_ty *mlp,
if (!mp->obsolete)
seen_errors += check_message (mp, &mp->pos,
check_newlines,
- check_format_strings, plural_distribution,
+ check_format_strings,
+ plural_distribution,
+ plural_distribution_length,
check_header, check_compatibility,
check_accelerators, accelerator_char);
}
diff --git a/gettext-tools/src/msgl-check.h b/gettext-tools/src/msgl-check.h
index 5945d33..2c5e4ab 100644
--- a/gettext-tools/src/msgl-check.h
+++ b/gettext-tools/src/msgl-check.h
@@ -1,5 +1,5 @@
/* Checking of messages in PO files.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2007 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2005.
This program is free software: you can redistribute it and/or modify
@@ -31,11 +31,14 @@ extern "C" {
PLURAL_DISTRIBUTION is either NULL or an array of nplurals elements,
PLURAL_DISTRIBUTION[j] being true if the value j appears to be assumed
infinitely often by the plural formula.
+ PLURAL_DISTRIBUTION_LENGTH is the length of the PLURAL_DISTRIBUTION array.
Return the number of errors that were seen. */
extern int check_message (const message_ty *mp,
const lex_pos_ty *msgid_pos,
int check_newlines,
- int check_format_strings, const unsigned char *plural_distribution,
+ int check_format_strings,
+ const unsigned char *plural_distribution,
+ unsigned long plural_distribution_length,
int check_header,
int check_compatibility,
int check_accelerators, char accelerator_char);