summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2010-04-25 11:54:55 +0200
committerBruno Haible <bruno@clisp.org>2010-04-25 16:05:51 +0200
commit085305b67992b3816505ab6fe2e452472583fe5f (patch)
treeaa5811d7dd1c62a9ebf030a6855c34f1ee216a3a
parent40c502a5ac00f63edf6376c1f709633130f2aba2 (diff)
downloadexternal_gettext-085305b67992b3816505ab6fe2e452472583fe5f.zip
external_gettext-085305b67992b3816505ab6fe2e452472583fe5f.tar.gz
external_gettext-085305b67992b3816505ab6fe2e452472583fe5f.tar.bz2
Update support of object-pascal-format strings.
-rw-r--r--gettext-tools/src/ChangeLog9
-rw-r--r--gettext-tools/src/format-pascal.c47
-rw-r--r--gettext-tools/tests/ChangeLog7
-rwxr-xr-xgettext-tools/tests/format-pascal-12
-rwxr-xr-xgettext-tools/tests/format-pascal-227
5 files changed, 53 insertions, 39 deletions
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index b70f433..54ab779 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,3 +1,12 @@
+2010-04-25 Bruno Haible <bruno@clisp.org>
+
+ Update support of object-pascal-format strings.
+ * format-pascal.c: Update description of format strings.
+ (enum format_arg_type): Remove FAT_INTEGER64.
+ (format_parse): Accept an empty digit sequence before ':'. Treat 'd',
+ 'u', 'x' the same way.
+ (main): Update.
+
2010-04-05 Bruno Haible <bruno@clisp.org>
Interoperability with mono versions >= 2009-02-27.
diff --git a/gettext-tools/src/format-pascal.c b/gettext-tools/src/format-pascal.c
index c8fea17..7e0c505 100644
--- a/gettext-tools/src/format-pascal.c
+++ b/gettext-tools/src/format-pascal.c
@@ -1,5 +1,5 @@
/* Object Pascal format strings.
- Copyright (C) 2001-2004, 2006-2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
This program is free software: you can redistribute it and/or modify
@@ -32,7 +32,9 @@
#define _(str) gettext (str)
/* Object Pascal format strings are usable with the "format" function in the
- "sysutils" unit. They are implemented in fpc-1.0.4/rtl/objpas/sysstr.inc.
+ "sysutils" unit. They are described in
+ <http://www.freepascal.org/docs-html/rtl/sysutils/format.html>
+ and are implemented in fpc-2.4.0/rtl/objpas/sysutils/sysformt.inc.
Another implementation exists in Borland Delphi. The GNU Pascal's
"sysutils" doesn't (yet?) have the "format" function.
@@ -41,8 +43,8 @@
- either
- is finished with '%', or
- - is optionally followed by an index specification: '*' (reads an
- argument, must be of type integer) or a nonempty digit sequence,
- followed by ':',
+ argument, must be of type integer) or a nonempty digit sequence
+ or nothing (equivalent to 0), followed by ':',
- is optionally followed by '-', which acts as a flag,
- is optionally followed by a width specification: '*' (reads an
argument, must be of type integer) or a nonempty digit sequence,
@@ -52,11 +54,12 @@
- is finished by a case-insensitive specifier. If no index was
specified, it reads an argument; otherwise is uses the index-th
argument, 0-based.
- - 'd', needs an 'integer' or 'int64' argument,
- - 'e', 'f', 'g', 'n', 'm', need an 'extended' floating-point argument,
- - 's', needs a 'string', 'char', 'pchar' or 'ansistring' argument,
- - 'p', needs a 'pointer' argument,
- - 'x', needs an integer argument.
+ - 'd', 'u', 'x', needs an 'integer' or 'int64' or 'qword' argument,
+ - 'e', 'f', 'g', 'n', 'm', need an 'extended' or 'currency' floating-
+ point argument,
+ - 's', needs a 'string', 'char', 'pchar', 'widestring', 'widechar',
+ 'pwidechar' or 'ansistring' argument,
+ - 'p', needs a 'pointer' argument.
Numbered and unnumbered argument specifications can be used in the same
string. Numbered argument specifications have no influence on the
"current argument index", that is incremented each time an argument is read.
@@ -64,10 +67,10 @@
enum format_arg_type
{
- FAT_INTEGER, /* integer */
- FAT_INTEGER64, /* integer, int64 */
- FAT_FLOAT, /* extended */
- FAT_STRING, /* string, char, pchar, ansistring */
+ FAT_INTEGER, /* integer, int64, qword */
+ FAT_FLOAT, /* extended, currency */
+ FAT_STRING, /* string, char, pchar, widestring, widechar, pwidechar,
+ ansistring */
FAT_POINTER
};
@@ -140,17 +143,16 @@ format_parse (const char *format, bool translated, char *fdi,
unsigned int main_number = 0;
enum format_arg_type type;
- if (isdigit (*format))
+ if (isdigit (*format) || *format == ':')
{
const char *f = format;
unsigned int m = 0;
- do
+ while (isdigit (*f))
{
m = 10 * m + (*f - '0');
f++;
}
- while (isdigit (*f));
if (*f == ':')
{
@@ -227,8 +229,8 @@ format_parse (const char *format, bool translated, char *fdi,
switch (c_tolower (*format))
{
- case 'd':
- type = FAT_INTEGER64;
+ case 'd': case 'u': case 'x':
+ type = FAT_INTEGER;
break;
case 'e': case 'f': case 'g': case 'n': case 'm':
type = FAT_FLOAT;
@@ -239,9 +241,6 @@ format_parse (const char *format, bool translated, char *fdi,
case 'p':
type = FAT_POINTER;
break;
- case 'x':
- type = FAT_INTEGER;
- break;
default:
if (*format == '\0')
{
@@ -309,9 +308,6 @@ format_parse (const char *format, bool translated, char *fdi,
if (type1 == type2)
type_both = type1;
- else if ((type1 == FAT_INTEGER && type2 == FAT_INTEGER64)
- || (type1 == FAT_INTEGER64 && type2 == FAT_INTEGER))
- type_both = FAT_INTEGER;
else
{
/* Incompatible types. */
@@ -493,9 +489,6 @@ format_print (void *descr)
case FAT_INTEGER:
printf ("i");
break;
- case FAT_INTEGER64:
- printf ("I");
- break;
case FAT_FLOAT:
printf ("f");
break;
diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog
index deb0123..149df4e 100644
--- a/gettext-tools/tests/ChangeLog
+++ b/gettext-tools/tests/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-25 Bruno Haible <bruno@clisp.org>
+
+ Update support of object-pascal-format strings.
+ * format-pascal-1: Add test for "%:d".
+ * format-pascal-2: Add test for "%:s". Test type compatibility between
+ %d, %u, %x.
+
2010-03-31 Guido Flohr <guido@imperia.net>
Improve how xgettext handles Perl syntax ambiguities.
diff --git a/gettext-tools/tests/format-pascal-1 b/gettext-tools/tests/format-pascal-1
index 33ab9c9..1439c28 100755
--- a/gettext-tools/tests/format-pascal-1
+++ b/gettext-tools/tests/format-pascal-1
@@ -57,6 +57,8 @@ cat <<\EOF > f-op-1.data
"abc%d%x%x"
# Valid: a numbered argument
"abc%0:d"
+# Valid: a numbered argument with omitted number
+"abc%:d"
# Valid: two-digit numbered arguments
"abc%10:def%9:dgh%8:dij%7:dkl%6:dmn%5:dop%4:dqr%3:dst%2:duv%1:dwx%0:dyz"
# Invalid: unterminated number
diff --git a/gettext-tools/tests/format-pascal-2 b/gettext-tools/tests/format-pascal-2
index d6a53d8..8f6cefe 100755
--- a/gettext-tools/tests/format-pascal-2
+++ b/gettext-tools/tests/format-pascal-2
@@ -37,6 +37,12 @@ msgstr "xyz%xvw%p"
# Valid: same numbered arguments, with different widths
msgid "abc%1:5s%0:4s"
msgstr "xyz%1:4s%0:5s"
+# Valid: same numbered arguments
+msgid "abc%:s"
+msgstr "xyz%0:s"
+# Valid: same numbered arguments
+msgid "abc%0:s"
+msgstr "xyz%:s"
# Invalid: missing argument
msgid "abc%1:sdef%0:x"
msgstr "xyz%0:x"
@@ -47,6 +53,15 @@ msgstr "xyz%1:x"
msgid "abc%0:xdef"
msgstr "xyz%0:xvw%1:p"
# Valid: type compatibility
+msgid "abc%d"
+msgstr "xyz%u"
+# Valid: type compatibility
+msgid "abc%d"
+msgstr "xyz%x"
+# Valid: type compatibility
+msgid "abc%u"
+msgstr "xyz%x"
+# Valid: type compatibility
msgid "abc%e"
msgstr "xyz%f"
# Valid: type compatibility
@@ -68,26 +83,14 @@ msgstr "xyz%s"
msgid "abc%d"
msgstr "xyz%p"
# Invalid: type incompatibility
-msgid "abc%d"
-msgstr "xyz%x"
-# Invalid: type incompatibility
msgid "abc%e"
msgstr "xyz%s"
# Invalid: type incompatibility
msgid "abc%e"
msgstr "xyz%p"
# Invalid: type incompatibility
-msgid "abc%e"
-msgstr "xyz%x"
-# Invalid: type incompatibility
msgid "abc%s"
msgstr "xyz%p"
-# Invalid: type incompatibility
-msgid "abc%s"
-msgstr "xyz%x"
-# Invalid: type incompatibility
-msgid "abc%p"
-msgstr "xyz%x"
# Invalid: type incompatibility for width
msgid "abc%g%*g"
msgstr "xyz%*g%g"