]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
pascal-format: Accept null precision.
authorBruno Haible <bruno@clisp.org>
Sun, 22 Jun 2025 00:11:33 +0000 (02:11 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 22 Jun 2025 00:11:33 +0000 (02:11 +0200)
Proof that it's valid:
------------------------- foo.pp -------------------------
program foo;
uses sysutils;
begin
  writeln(format('%.f', [3.1415926535]));
end.
----------------------------------------------------------

* gettext-tools/src/format-pascal.c: Fix comment regarding the precision.
(format_parse): Accept a null precision after '.'.
* gettext-tools/tests/format-pascal-1: Add a test case with null precision.

gettext-tools/src/format-pascal.c
gettext-tools/tests/format-pascal-1

index 855acc614d691c84b17940b6f8e3d8b555dcf897..648597501473182c0b3e4246dd32de7a6e7c45c4 100644 (file)
@@ -49,8 +49,8 @@
        - is optionally followed by a width specification: '*' (reads an
          argument, must be of type integer) or a nonempty digit sequence,
        - is optionally followed by '.' and a precision specification: '*'
-         (reads an argument, must be of type integer) or a nonempty digit
-         sequence,
+         (reads an argument, must be of type integer) or an optional 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.
@@ -216,8 +216,6 @@ format_parse (const char *format, bool translated, char *fdi,
 
                     format++;
                   }
-                else
-                  --format;     /* will jump to bad_format */
               }
 
             switch (c_tolower (*format))
index c0694c087d869bf6b0802dcc49dabea6372d2ff1..98d2e55807c50dccb310bfc810e50ac10ffabbc7 100755 (executable)
@@ -48,6 +48,8 @@ cat <<\EOF > f-op-1.data
 "abc%y"
 # Invalid: flags after width
 "abc%*-g"
+# Valid: null precision
+"abc%.f"
 # Invalid: twice precision
 "abc%.4.2g"
 # Valid: three arguments