From 5b2a00875c85f939e15c7d39fdd227bee1d4edad Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 22 Jun 2025 03:09:48 +0200 Subject: [PATCH] ruby-format: Accept null precision. Proof that it's valid: $ ruby puts "%.f" % 3.1415926535 * gettext-tools/src/format-ruby.c: Clarify comment regarding the precision. * gettext-tools/tests/format-ruby-1: Add test cases with null precision. --- gettext-tools/src/format-ruby.c | 2 +- gettext-tools/tests/format-ruby-1 | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gettext-tools/src/format-ruby.c b/gettext-tools/src/format-ruby.c index e58e62773..7e371fef9 100644 --- a/gettext-tools/src/format-ruby.c +++ b/gettext-tools/src/format-ruby.c @@ -50,7 +50,7 @@ - '*', indicating a width, taken from the argument list, - '*' and a digit sequence, followed by '$', indicating a width, taken from a positional argument, - - '.' and a digit sequence, indicating a precision, + - '.' and an optional nonempty digit sequence, indicating a precision, - '.' '*', indicating a precision, taken from the argument list, - '.' '*' and a digit sequence, followed by '$', indicating a precision, taken from a positional argument. diff --git a/gettext-tools/tests/format-ruby-1 b/gettext-tools/tests/format-ruby-1 index 2294b3365..b473bb2ca 100755 --- a/gettext-tools/tests/format-ruby-1 +++ b/gettext-tools/tests/format-ruby-1 @@ -241,6 +241,10 @@ cat <<\EOF > f-r-1.data "abc%2$2*1$g" # Invalid: twice width (numbered) "abc%2$*1$2g" +# Valid: null precision (unnumbered) +"abc%.f" +# Valid: null precision (numbered) +"abc%1$.f" # Invalid: twice precision (unnumbered) "abc%.4.2g" # Invalid: twice precision (numbered)