]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
php-format: Reject null precision.
authorBruno Haible <bruno@clisp.org>
Sun, 22 Jun 2025 00:38:50 +0000 (02:38 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 22 Jun 2025 00:38:50 +0000 (02:38 +0200)
Rationale: The handling of null precision in php is buggy,
cf. <https://github.com/php/php-src/issues/18897>.

* gettext-tools/src/format-php.c: Fix comment regarding the precision.
* gettext-tools/tests/format-php-1: Add a test case with null precision.

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

index 11b55a0d78c82b3b829ba8a1aaa773aa22561b76..c1ec3abbbd1b81413d2b43fa3bc927dbc0927ae6 100644 (file)
      "'<anychar>", each of which acts as a flag,
    - is optionally followed by a width specification: a nonempty digit
      sequence,
-   - is optionally followed by '.' and a precision specification: a nonempty
-     digit sequence,
+   - is optionally followed by '.' and a precision specification: an [optional?]
+     nonempty digit sequence,
+     (It's optional per <https://www.php.net/manual/en/function.sprintf.php>,
+     but this is actually buggy: <https://github.com/php/php-src/issues/18897>.)
    - is optionally followed by a size specifier 'l', which is ignored,
    - is finished by a specifier
        - 's', that needs a string argument,
index a7420375d2c375a336036f207519ce8acd3a07f1..844be7ce4941ab92534968a653c2eb9b2c0f9496 100755 (executable)
@@ -54,6 +54,8 @@ cat <<\EOF > f-ph-1.data
 "abc%y"
 # Invalid: flags after width
 "abc%5-f"
+# Invalid: null precision
+"abc%.f"
 # Invalid: twice precision
 "abc%.4.2f"
 # Valid: three arguments