summaryrefslogtreecommitdiffstats
path: root/gettext-tools/src
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2008-08-15 10:25:48 +0000
committerBruno Haible <bruno@clisp.org>2009-06-23 12:15:46 +0200
commitf57a99eeea0a49b3949ce5124cf85df0a2395f31 (patch)
treef82c8a1e4950b3902a04546017bdeb74af82992b /gettext-tools/src
parent41ac5251a20f23e4be590498874265892d4ccfab (diff)
downloadexternal_gettext-f57a99eeea0a49b3949ce5124cf85df0a2395f31.zip
external_gettext-f57a99eeea0a49b3949ce5124cf85df0a2395f31.tar.gz
external_gettext-f57a99eeea0a49b3949ce5124cf85df0a2395f31.tar.bz2
Treat %.0s and %.0r as type-agnostic argument consumer.
Diffstat (limited to 'gettext-tools/src')
-rw-r--r--gettext-tools/src/ChangeLog9
-rw-r--r--gettext-tools/src/format-python.c25
2 files changed, 29 insertions, 5 deletions
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 448033f..346e291 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,3 +1,12 @@
+2008-08-15 Bruno Haible <bruno@clisp.org>
+
+ * format-python.c (format_parse): For %.0s and %.0r, set the type to
+ FORMAT_ANY.
+ (format_check): When strict equality is not desired, compare FORMAT_ANY
+ as matching any type.
+ Reported by Alexander Dupuy <alex.dupuy@mac.com> in
+ <http://savannah.gnu.org/bugs/?24025>.
+
2008-08-14 Bruno Haible <bruno@clisp.org>
* format-python.c (format_parse): For '%', set the type to FAT_NONE.
diff --git a/gettext-tools/src/format-python.c b/gettext-tools/src/format-python.c
index 395b562..889f732 100644
--- a/gettext-tools/src/format-python.c
+++ b/gettext-tools/src/format-python.c
@@ -55,7 +55,8 @@
- is finished by a specifier
- '%', that needs no argument,
- 'c', that needs a character argument,
- - 's', 'r', that need a string argument,
+ - 's', 'r', that need a string argument (or, when a precision of 0 is
+ given, an argument of any type),
- 'i', 'd', 'u', 'o', 'x', 'X', that need an integer argument,
- 'e', 'E', 'f', 'g', 'G', that need a floating-point argument.
Use of '(ident)' and use of unnamed argument specifications are exclusive,
@@ -133,6 +134,7 @@ format_parse (const char *format, bool translated, char *fdi,
{
/* A directive. */
char *name = NULL;
+ bool zero_precision = false;
enum format_arg_type type;
FDI_SET (format - 1, FMTDIR_START);
@@ -228,7 +230,14 @@ format_parse (const char *format, bool translated, char *fdi,
}
else if (isdigit (*format))
{
- do format++; while (isdigit (*format));
+ zero_precision = true;
+ do
+ {
+ if (*format != '0')
+ zero_precision = false;
+ format++;
+ }
+ while (isdigit (*format));
}
}
@@ -244,7 +253,7 @@ format_parse (const char *format, bool translated, char *fdi,
type = FAT_CHARACTER;
break;
case 's': case 'r':
- type = FAT_STRING;
+ type = (zero_precision ? FAT_ANY : FAT_STRING);
break;
case 'i': case 'd': case 'u': case 'o': case 'x': case 'X':
type = FAT_INTEGER;
@@ -475,7 +484,10 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality,
{
if (strcmp (spec1->named[i].name, spec2->named[j].name) == 0)
{
- if (spec1->named[i].type != spec2->named[j].type)
+ if (!(spec1->named[i].type == spec2->named[j].type
+ || (!equality
+ && (spec1->named[i].type == FAT_ANY
+ || spec2->named[j].type == FAT_ANY))))
{
if (error_logger)
error_logger (_("format specifications in 'msgid' and '%s' for argument '%s' are not the same"),
@@ -504,7 +516,10 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality,
}
else
for (i = 0; i < spec2->unnamed_arg_count; i++)
- if (spec1->unnamed[i].type != spec2->unnamed[i].type)
+ if (!(spec1->unnamed[i].type == spec2->unnamed[i].type
+ || (!equality
+ && (spec1->unnamed[i].type == FAT_ANY
+ || spec2->unnamed[i].type == FAT_ANY))))
{
if (error_logger)
error_logger (_("format specifications in 'msgid' and '%s' for argument %u are not the same"),