]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Update support of object-pascal-format strings.
authorBruno Haible <bruno@clisp.org>
Sun, 25 Apr 2010 09:54:55 +0000 (11:54 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 25 Apr 2010 14:05:51 +0000 (16:05 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/format-pascal.c
gettext-tools/tests/ChangeLog
gettext-tools/tests/format-pascal-1
gettext-tools/tests/format-pascal-2

index b70f433237082580441de11369cf6a048501d8ba..54ab7797fe7fd546f35962ea8ba98d249d8848e2 100644 (file)
@@ -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.
index c8fea176e011a8e24aa865fa275eef3dd91c283f..7e0c5055cce2ed654e823d2258a0acc30540efdc 100644 (file)
@@ -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,
        - 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.
 
 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;
index deb0123f466c729c7e8dd959cb2360c70bf615b2..149df4ea52e12aae422af55f087581ecdc33ffa6 100644 (file)
@@ -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.
index 33ab9c90b5c19959c673fcada02a03cadd7e75a8..1439c283d6defe57892adc704f79fde68d900414 100755 (executable)
@@ -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
index d6a53d8cb03401d192c66ea70cfedace226b5221..8f6cefe47fd470dfd0d08c0b14085a485a0c1814 100755 (executable)
@@ -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"