python-format: Accept null precision.

Proof that it's valid:
$ python
print("%(value).f" % { 'value': 3.1415926535 })

* gettext-tools/src/format-python.c: Fix comment regarding the precision.
* gettext-tools/tests/format-python-1: Add a test case with null precision.
This commit is contained in:
Bruno Haible 2025-06-22 02:48:26 +02:00
parent c0a5ed0180
commit b6ea1c2cbe
2 changed files with 3 additions and 1 deletions

View File

@ -50,7 +50,7 @@
- is optionally followed by a width specification: '*' (reads an argument)
or a nonempty digit sequence,
- is optionally followed by '.' and a precision specification: '*' (reads
an argument) or a nonempty digit sequence,
an argument) or an optional nonempty digit sequence,
- is optionally followed by a size specifier, one of 'h' 'l' 'L'.
- is finished by a specifier
- '%', that needs no argument,

View File

@ -64,6 +64,8 @@ cat <<\EOF > f-p-1.data
"abc%y"
# Invalid: flags after width
"abc%*0g"
# Valid: null precision
"abc%.f"
# Invalid: twice precision
"abc%.4.2g"
# Invalid: two size specifiers