Subject: bug#13394: closed (Re: bug#13394: Misalignment for "seq -w")

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 09 Jan 2013 12:07:02 +0000

Your bug report

#13394: Misalignment for "seq -w"

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
13394: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13394
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#13394: Misalignment for "seq -w"
From: Pádraig Brady <[email-masked]>
To: Erik Auerswald <[email-masked]>
Cc: Bernhard Voelker <[email-masked]>, [email-masked],Marcel Böhme <[email-masked]>
Date: Wed, 09 Jan 2013 12:05:33 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

On 01/09/2013 11:01 AM, Erik Auerswald wrote:
> Hi,
>
> On 01/09/2013 11:34 AM, Bernhard Voelker wrote:
>> On 01/09/2013 11:14 AM, Marcel Böhme wrote:
>>>
>>> There are the following problems with the -w parameter of the seq tool:
>>> [...]
>>
>> Hmm, according to the TEXI manual, the FIRST number should also use
>> a fixed point decimal representation when the -w option is used:
>> [...]
>> But that leaves the question open if there's a reason for this.
>> I.e. if it's just documented behavior, a requirement of some
>> standard or due to compatibility reasons.
>
> That seems to be just documented behavior, since seq is not standardized by POSIX and other seq implementations ([1],[2],[3]) don't document this. On the contrary, a common example is 'seq -w 0 .05 .1'.
>
> This example works fine with GNU seq:
>
> $ seq -w 0 .05 .1
> 0.00
> 0.05
> 0.10
>
> Even when counting to negative numbers:
>
> $ seq -w 0 -.05 -.1
> 00.00
> -0.05
> -0.10
>
> Starting with a negative number with a fractional step size breaks equal width for non-negative numbers:
>
> $ seq -w -1 .5 1
> -1.0
> -0.5
> 0.0
> 0.5
> 1.0
>
> $ seq --version | head -n1
> seq (GNU coreutils) 8.13

Looks like a bug. I'll fix with:

diff --git a/src/seq.c b/src/seq.c
index e1b467c..3eb53f8 100644
--- a/src/seq.c
+++ b/src/seq.c
@@ -332,6 +332,8 @@ get_default_format (operand first, operand step, operand last)
              last_width--;  /* don't include space for '.' */
            if (last.precision == 0 && prec)
              last_width++;  /* include space for '.' */
+          if (first.precision == 0 && prec)
+            first_width++;  /* include space for '.' */
            size_t width = MAX (first_width, last_width);
            if (width <= INT_MAX)
              {

Subject: Misalignment for "seq -w"
From: "Marcel Böhme" <[email-masked]>
To: [email-masked]
Date: Wed, 9 Jan 2013 11:14:53 +0100 (CET)
List-Id: <debbugs-submit.debbugs.gnu.org>

Dear all,

There are the following problems with the -w parameter of the seq tool:

$seq -w -1 1.0 0
-1.0
0.0
1.0

But it should print:
-1.0
00.0
01.0

A similar problem is observable for: 
$seq -w 10 -.1 1 | head

Best regards,
 Marcel