From c0a5ed01807c21d3fcb01df7a565fa06ac88fb90 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 22 Jun 2025 02:38:50 +0200 Subject: [PATCH] php-format: Reject null precision. Rationale: The handling of null precision in php is buggy, cf. . * 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 | 6 ++++-- gettext-tools/tests/format-php-1 | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gettext-tools/src/format-php.c b/gettext-tools/src/format-php.c index 11b55a0d7..c1ec3abbb 100644 --- a/gettext-tools/src/format-php.c +++ b/gettext-tools/src/format-php.c @@ -40,8 +40,10 @@ "'", 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 , + but this is actually buggy: .) - is optionally followed by a size specifier 'l', which is ignored, - is finished by a specifier - 's', that needs a string argument, diff --git a/gettext-tools/tests/format-php-1 b/gettext-tools/tests/format-php-1 index a7420375d..844be7ce4 100755 --- a/gettext-tools/tests/format-php-1 +++ b/gettext-tools/tests/format-php-1 @@ -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 -- 2.47.3