elisp-format: Accept null precision.

Proof that is is valid:
(format "%.f" 3.1415926)

* gettext-tools/src/format-elisp.c: Fix comment regarding the precision.
* gettext-tools/tests/format-elisp-1: Add a test case with null precision.
This commit is contained in:
Bruno Haible 2025-06-22 00:54:23 +02:00
parent 36f19a58d5
commit d29d2aa61a
2 changed files with 5 additions and 3 deletions

View File

@ -31,8 +31,8 @@
#define _(str) gettext (str)
/* Emacs Lisp format strings are implemented in emacs-21.1/src/editfns.c,
xemacs-21.1.14/src/editfns.c and xemacs-21.1.14/src/doprnt.c.
/* Emacs Lisp format strings are implemented in emacs-21.4/src/editfns.c and
emacs-21.4/src/doprnt.c.
A directive
- starts with '%' or '%m$' where m is a positive integer,
- is optionally followed by any of the characters '#', '0', '-', ' ', '+',
@ -40,7 +40,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 finished by a specifier
- '%', that needs no argument,
- 'c', that need a character argument,

View File

@ -54,6 +54,8 @@ cat <<\EOF > f-el-1.data
"abc%y"
# Invalid: flags after width
"abc%2^d"
# Valid: null precision
"abc%.f"
# Invalid: twice precision
"abc%.4.2d"
# Valid: three arguments