php-format: Reject null precision.

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.
This commit is contained in:
Bruno Haible 2025-06-22 02:38:50 +02:00
parent 3c4aff9b3b
commit c0a5ed0180
2 changed files with 6 additions and 2 deletions

View File

@ -40,8 +40,10 @@
"'<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,

View File

@ -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