From: Bruno Haible Date: Sat, 21 Jun 2025 23:30:12 +0000 (+0200) Subject: librep-format: Accept null precision. X-Git-Tag: v0.26~84 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6859ac3476cd44164faa82dfbe53d95ced6a5438;p=thirdparty%2Fgettext.git librep-format: Accept null precision. Proof that it's valid: $ rep (format t "%.d" 3.1415926535) * gettext-tools/src/format-librep.c: Fix comment regarding the precision. * gettext-tools/tests/format-librep-1: Add a test case with null precision. --- diff --git a/gettext-tools/src/format-librep.c b/gettext-tools/src/format-librep.c index 264e122b6..2e2025356 100644 --- a/gettext-tools/src/format-librep.c +++ b/gettext-tools/src/format-librep.c @@ -38,8 +38,8 @@ 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, - is finished by a specifier - '%', that needs no argument, - 'c', that need a character argument, diff --git a/gettext-tools/tests/format-librep-1 b/gettext-tools/tests/format-librep-1 index cffaa89b7..b54dafda0 100755 --- a/gettext-tools/tests/format-librep-1 +++ b/gettext-tools/tests/format-librep-1 @@ -34,6 +34,8 @@ cat <<\EOF > f-lr-1.data "abc%y" # Invalid: flags after width "abc%2^d" +# Valid: null precision +"abc%.d" # Invalid: twice precision "abc%.4.2d" # Valid: three arguments