From a860ca32b0cadfff722f7639b2158a59be7bd346 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 3 Nov 2007 01:10:59 -0700 Subject: Fix bug with "seq 10.8 0.1 10.95", plus another bug with %% in format. * NEWS: Mention the %%-in-format bug fix. * src/seq.c (struct layout): New type. (long_double_format): New arg LAYOUT. Fill it in. Fix mishandling of %% in formats. (print_numbers): New arg LAYOUT. Don't convert LAST to output format when deciding whether to go slightly past LAST. Instead, convert X to output format and back. This fixes a bug reported by Andreas Schwab in where "seq 10.8 0.1 10.95" would output 11.0 on platforms where 10.95 rounds to a value that prints as 11.0 when only one digit past the decimal point is asked for. (main): Compute layout, for benefit of print_numbers. * tests/misc/seq (float-3): Undo previous change, since the bug should be fixed now. (fmt-b): New test, for the %% bug. --- tests/misc/seq | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/misc/seq b/tests/misc/seq index 1f3ec06c1..73f41336d 100755 --- a/tests/misc/seq +++ b/tests/misc/seq @@ -47,7 +47,7 @@ my @Tests = ['float-1', qw(0.8 0.1 0.9), {OUT => [qw(0.8 0.9)]}], ['float-2', qw(0.1 0.99 1.99), {OUT => [qw(0.10 1.09)]}], - ['float-3', qw(10.8 0.1 10.94), {OUT => [qw(10.8 10.9)]}], + ['float-3', qw(10.8 0.1 10.95), {OUT => [qw(10.8 10.9)]}], ['float-4', qw(0.1 -0.1 -0.2), {OUT => [qw(0.1 0.0 -0.1 -0.2)]}, {OUT_SUBST => 's,^-0\.0$,0.0,'}, ], @@ -79,6 +79,7 @@ my @Tests = ['fmt-8', qw(-f %0+.0f 1 2), {OUT => [qw(+1 +2)]}], ['fmt-9', '-f "% -3.0f"', qw(-1 0), {OUT => ['-1 ', ' 0 ']}], ['fmt-a', '-f "% -.0f"',qw(-1 0), {OUT => ['-1', ' 0']}], + ['fmt-b', qw(-f %%%g%% 1), {OUT => ['%1%']}], ); # Append a newline to each entry in the OUT array. -- cgit v1.2.3-54-g00ecf