bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: seq -w floating point incorrect formating


From: Jim Meyering
Subject: Re: seq -w floating point incorrect formating
Date: Sat, 14 Feb 2009 18:30:09 +0100

Pádraig Brady <address@hidden> wrote:
> Samuel Hapák wrote:
>> Hello,
>> I think that seq is not behaving correctly on this input:
>> seq -w 9 0.5 10
>>
>> I obtain the output:
>> 9.0
>> 9.5
>> 10.0
>>
>> While I think I should obtain:
>> 09.0
>> 09.5
>> 10.0
>
> Looks like a bug alright.
> I'm thinking of applying the attached to fix it.

Looks right to me.  Thanks!
Please describe the fix in NEWS, and mention the
reporter in the log and in THANKS.

>>From b350141cfefdd68f663c8ea3efa47ed81bcaba03 Mon Sep 17 00:00:00 2001
> +++ b/src/seq.c
> @@ -317,6 +317,8 @@ get_default_format (operand first, operand step, operand 
> last)
>         size_t last_width = last.width + (prec - last.precision);
>         if (last.precision && prec == 0)
>           last_width--;  /* don't include space for '.' */
> +       if (last.precision == 0 && prec != 0)
> +         last_width++;  /* include space for '.' */
>         size_t width = MAX (first_width, last_width);
>         if (width <= INT_MAX)
>           {
> diff --git a/tests/misc/seq b/tests/misc/seq
> index 7f808cf..cd78bd1 100755
> --- a/tests/misc/seq
> +++ b/tests/misc/seq
> @@ -64,6 +64,7 @@ my @Tests =
>     ['eq-wid-5',      qw(-w 1 .5 2),  {OUT => [qw(1.0 1.5 2.0)]}],
>     ['eq-wid-6',      qw(-w +1 2),  {OUT => [qw(1 2)]}],
>     ['eq-wid-7',      qw(-w "    .1"  "    .1"),  {OUT => [qw(0.1)]}],
> +   ['eq-wid-8',      qw(-w 9 0.5 10),  {OUT => [qw(09.0 09.5 10.0)]}],
>
>     # Prior to coreutils-4.5.11, some of these were not accepted.
>     ['fmt-1', qw(-f %2.1f 1.5 .5 2),{OUT => [qw(1.5 2.0)]}],




reply via email to

[Prev in Thread] Current Thread [Next in Thread]