From: Bruno Haible Date: Sun, 22 Jun 2025 01:09:48 +0000 (+0200) Subject: ruby-format: Accept null precision. X-Git-Tag: v0.26~77 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5b2a00875c85f939e15c7d39fdd227bee1d4edad;p=thirdparty%2Fgettext.git 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. --- 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)