GNU bug report logs - #13394
Misalignment for "seq -w"

Previous Next

Package: coreutils;

Reported by: "Marcel Böhme" <hawkie <at> web.de>

Date: Wed, 9 Jan 2013 10:16:02 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13394 in the body.
You can then email your comments to 13394 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#13394; Package coreutils. (Wed, 09 Jan 2013 10:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Marcel Böhme" <hawkie <at> web.de>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Wed, 09 Jan 2013 10:16:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Marcel Böhme" <hawkie <at> web.de>
To: bug-coreutils <at> gnu.org
Subject: Misalignment for "seq -w"
Date: Wed, 9 Jan 2013 11:14:53 +0100 (CET)
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




Information forwarded to bug-coreutils <at> gnu.org:
bug#13394; Package coreutils. (Wed, 09 Jan 2013 10:36:02 GMT) Full text and rfc822 format available.

Message #8 received at 13394 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Marcel Böhme <hawkie <at> web.de>, Pádraig Brady <P <at> draigbrady.com>
Cc: 13394 <at> debbugs.gnu.org
Subject: Re: bug#13394: Misalignment for "seq -w"
Date: Wed, 09 Jan 2013 11:34:53 +0100
On 01/09/2013 11:14 AM, Marcel Böhme wrote:
> 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

Hmm, according to the TEXI manual, the FIRST number should also use
a fixed point decimal representation when the -w option is used:

`-w'
`--equal-width'
     Print all numbers with the same width, by padding with leading
     zeros.  FIRST, STEP, and LAST should all use a fixed point decimal
     representation.  (To have other kinds of padding, use `--format').

Thus, seq is just doing what the manual says:

  $ seq -w -1.0 1.0 0.0
  -1.0
  00.0

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.

But as Padraig worked in this area recently ([1]), I think there
is further room for improvement ... and then the documentation
should be fixed.

@Padraig: WDYT?

Have a nice day,
Berny

[1] http://git.sv.gnu.org/cgit/coreutils.git/commit/?id=64d4a280




Information forwarded to bug-coreutils <at> gnu.org:
bug#13394; Package coreutils. (Wed, 09 Jan 2013 11:03:02 GMT) Full text and rfc822 format available.

Message #11 received at 13394 <at> debbugs.gnu.org (full text, mbox):

From: Erik Auerswald <auerswal <at> unix-ag.uni-kl.de>
To: Bernhard Voelker <mail <at> bernhard-voelker.de>
Cc: 13394 <at> debbugs.gnu.org,
	Pádraig Brady <P <at> draigbrady.com>,
	Marcel Böhme <hawkie <at> web.de>
Subject: Re: bug#13394: Misalignment for "seq -w"
Date: Wed, 09 Jan 2013 12:01:51 +0100
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

HTH,
Erik

[1] http://man.cat-v.org/unix_8th/1/seq
[2] http://man.cat-v.org/plan_9/1/seq
[3] http://www.freebsd.org/cgi/man.cgi?query=seq&manpath=FreeBSD+9.0-RELEASE




Reply sent to Pádraig Brady <P <at> draigBrady.com>:
You have taken responsibility. (Wed, 09 Jan 2013 12:07:01 GMT) Full text and rfc822 format available.

Notification sent to "Marcel Böhme" <hawkie <at> web.de>:
bug acknowledged by developer. (Wed, 09 Jan 2013 12:07:02 GMT) Full text and rfc822 format available.

Message #16 received at 13394-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Erik Auerswald <auerswal <at> unix-ag.uni-kl.de>
Cc: Bernhard Voelker <mail <at> bernhard-voelker.de>, 13394-done <at> debbugs.gnu.org,
	Marcel Böhme <hawkie <at> web.de>
Subject: Re: bug#13394: Misalignment for "seq -w"
Date: Wed, 09 Jan 2013 12:05:33 +0000
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)
             {






Information forwarded to bug-coreutils <at> gnu.org:
bug#13394; Package coreutils. (Wed, 09 Jan 2013 12:15:02 GMT) Full text and rfc822 format available.

Message #19 received at 13394 <at> debbugs.gnu.org (full text, mbox):

From: Erik Auerswald <auerswal <at> unix-ag.uni-kl.de>
To: 13394 <at> debbugs.gnu.org, P <at> draigBrady.com, hawkie <at> web.de
Subject: Re: bug#13394: Misalignment for "seq -w"
Date: Wed, 09 Jan 2013 13:14:37 +0100
On 01/09/2013 01:05 PM, Pádraig Brady wrote:
> 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)
> {

The patch looks plausible. ;-)

Thanks,
Erik




Information forwarded to bug-coreutils <at> gnu.org:
bug#13394; Package coreutils. (Wed, 09 Jan 2013 12:43:02 GMT) Full text and rfc822 format available.

Message #22 received at 13394 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: 13394 <at> debbugs.gnu.org, P <at> draigBrady.com, hawkie <at> web.de
Subject: Re: bug#13394: Misalignment for "seq -w"
Date: Wed, 09 Jan 2013 13:42:26 +0100
On 01/09/2013 01:05 PM, Pádraig Brady wrote:
> 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)
>               {

+1

Have a nice day,
Berny




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 07 Feb 2013 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 138 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.