Debian Bug report logs - #339799
mawk: printf %02s does not result in a leadng zero being printed.

version graph

Package: mawk; Maintainer for mawk is Steve Langasek <vorlon@debian.org>; Source for mawk is src:mawk.

Reported by: "Erik C.J. Laan" <deb@elaan.dds.nl>

Date: Fri, 18 Nov 2005 21:33:13 UTC

Severity: normal

Tags: fixed-upstream

Found in version mawk/1.3.3-11

Done: Jonathan Nieder <jrnieder@gmail.com>

Bug is archived. No further changes may be made.

Toggle useless messages

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


Report forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#339799; Package mawk. Full text and rfc822 format available.

Acknowledgement sent to "Erik C.J. Laan" <deb@elaan.dds.nl>:
New Bug report received and forwarded. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: "Erik C.J. Laan" <deb@elaan.dds.nl>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: mawk: printf %02s does not result in a leadng zero being printed.
Date: Fri, 18 Nov 2005 22:22:31 +0100
Package: mawk
Version: 1.3.3-11
Severity: normal


for example:
echo "" | mawk ' { x = 4 ; printf("%02s\n",x ) } '
prints:
 4
instead of:
04

>From the behaviour of "nawk" on Solaris 8, AIX 4.3, 5.2 and 5.3
(at work) and of gawk on Linux at home I am under the impression
that it should print "04".

Erik.

-- System Information:
Debian Release: 3.1
Architecture: i386 (i586)
Kernel: Linux 2.4.18
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages mawk depends on:
ii  libc6                       2.3.2.ds1-22 GNU C Library: Shared libraries an

-- no debconf information



Message sent on to "Erik C.J. Laan" <deb@elaan.dds.nl>:
Bug#339799. (Fri, 31 Jul 2009 00:06:02 GMT) Full text and rfc822 format available.

Message #8 received at 339799-submitter@bugs.debian.org (full text, mbox):

From: Thomas Dickey <dickey@his.com>
To: 339799-submitter@bugs.debian.org
Subject: re: #339799 mawk: printf %02s does not result in a leadng zero being printed.
Date: Thu, 30 Jul 2009 20:02:40 -0400
[Message part 1 (text/plain, inline)]
However, both one-true-awk and heirloom-awk act the same as mawk.
POSIX is no help here, since 

	http://www.opengroup.org/onlinepubs/009695399/utilities/awk.html

does not mention leading zeros.  So we can only decide based on compatibility.
AIX and HPUX agree with Solaris - so it looks like a feature of "nawk" rather
than "awk".

-- 
Thomas E. Dickey <dickey@invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net
[signature.asc (application/pgp-signature, inline)]

Information stored :
Bug#339799; Package mawk. (Sat, 01 Aug 2009 21:21:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to elaan@dds.nl:
Extra info received and filed, but not forwarded. (Sat, 01 Aug 2009 21:21:03 GMT) Full text and rfc822 format available.

Message #13 received at 339799-quiet@bugs.debian.org (full text, mbox):

From: "Erik C.J. Laan" <elaan@dds.nl>
To: dickey@his.com, 339799-quiet@bugs.debian.org
Cc: 339799-submitter@bugs.debian.org
Subject: Re: Bug#339799: #339799 mawk: printf %02s does not result in a leadng zero being printed.
Date: Sat, 01 Aug 2009 23:17:13 +0200
Thomas Dickey wrote:
> However, both one-true-awk and heirloom-awk act the same as mawk.
> POSIX is no help here, since 
> 
> 	http://www.opengroup.org/onlinepubs/009695399/utilities/awk.html
> 
> does not mention leading zeros.  So we can only decide based on compatibility.
> AIX and HPUX agree with Solaris - so it looks like a feature of "nawk" rather
> than "awk".
> 

OK, I see. A leading 0 is only defined for the d, i, o, u, x, X, e, E, 
f, g, and G conversion specifiers, not the s conversion specifier. I 
guess that means this is not a bug because there is no standard. I guess 
I need to change the relevant awk piece to be

mawk ' { x = 4 ; printf("%02d\n",x ) } '

and than it should work as I wanted it to. I have just tried that with 
the example given in the bug-report and it works. Thanks, problem 
solved. Now I´ll have to find that piece of code I was writing at the 
time, that used this....

Erik.













Message sent on to "Erik C.J. Laan" <deb@elaan.dds.nl>:
Bug#339799. (Sat, 01 Aug 2009 21:21:04 GMT) Full text and rfc822 format available.

Information stored :
Bug#339799; Package mawk. (Sat, 01 Aug 2009 21:33:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Thomas Dickey <dickey@his.com>:
Extra info received and filed, but not forwarded. (Sat, 01 Aug 2009 21:33:02 GMT) Full text and rfc822 format available.

Message #21 received at 339799-quiet@bugs.debian.org (full text, mbox):

From: Thomas Dickey <dickey@his.com>
To: "Erik C.J. Laan" <elaan@dds.nl>
Cc: 339799-quiet@bugs.debian.org, 339799-submitter@bugs.debian.org
Subject: Re: Bug#339799: #339799 mawk: printf %02s does not result in a leadng zero being printed.
Date: Sat, 1 Aug 2009 17:30:46 -0400 (EDT)
[Message part 1 (text/plain, inline)]
On Sat, 1 Aug 2009, Erik C.J. Laan wrote:

> Thomas Dickey wrote:
>> However, both one-true-awk and heirloom-awk act the same as mawk.
>> POSIX is no help here, since
>> 	http://www.opengroup.org/onlinepubs/009695399/utilities/awk.html
>> 
>> does not mention leading zeros.  So we can only decide based on 
>> compatibility.
>> AIX and HPUX agree with Solaris - so it looks like a feature of "nawk" 
>> rather
>> than "awk".
>> 
>
> OK, I see. A leading 0 is only defined for the d, i, o, u, x, X, e, E, f, g, 
> and G conversion specifiers, not the s conversion specifier. I guess that

yes - for the C runtime.
mawk is using the C runtime for printf/sprintf.
I guess nawk is not doing it that way.

(Doing the numeric conversions is a lot of work, and is likely the reason 
why mawk uses the C runtime - but %s and %c are relatively simple).

> means this is not a bug because there is no standard. I guess I need to 
> change the relevant awk piece to be
>
> mawk ' { x = 4 ; printf("%02d\n",x ) } '
>
> and than it should work as I wanted it to. I have just tried that with the 
> example given in the bug-report and it works. Thanks, problem solved. Now 
> I´ll have to find that piece of code I was writing at the time, that used 
> this....

no problem - I've got a different slant, since I'm working to repair
mawk.

In the given context I decided that since nawk implements it, (on several 
platforms) that it's one of those things that the standards people didn't 
notice simply because it's not documented.

At least I'm not seeing it in the webpage (someone might be able to "see" 
it).

Anyway - I implemented the 0's this morning, so it'll be in my next 
snapshot of mawk.  However, none of my fixes have been applied to Debian, 
yet.

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

Message sent on to "Erik C.J. Laan" <deb@elaan.dds.nl>:
Bug#339799. (Sat, 01 Aug 2009 21:33:04 GMT) Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org, Steve Langasek <vorlon@debian.org>:
Bug#339799; Package mawk. (Fri, 21 Aug 2009 08:42:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to dickey@his.com:
Extra info received and forwarded to list. Copy sent to Steve Langasek <vorlon@debian.org>. (Fri, 21 Aug 2009 08:42:07 GMT) Full text and rfc822 format available.

Message #29 received at 339799@bugs.debian.org (full text, mbox):

From: Thomas Dickey <dickey@his.com>
To: 339799@bugs.debian.org
Cc: 339799-submitter@bugs.debian.org
Subject: re: #339799 mawk: printf %02s does not result in a leadng zero being printed.
Date: Fri, 21 Aug 2009 04:39:31 -0400
[Message part 1 (text/plain, inline)]
Further discussion with Aharon Robbins and Mike Brennan brought forth
this information:

	a) X/Open awk uses standard printf formatting, which does not produce
	   leading 0's.

	b) platforms which produce leading 0's (Solaris, AIX, HPUX, IRIX64)
	   do this as a legacy (pre-standardization) feature.

	c) if mawk was built on such a platform, it would have produced leading
	   0's, built on other platforms it did not.

	d) Aharon Robbins changed gawk to no longer produce leading 0's.

So I modified mawk to explicitly not produce leading 0's, for consistent
and conformance with the standard.  That change is in the 20090820 snapshot
here:

	ftp://invisible-island.net/mawk/

-- 
Thomas E. Dickey <dickey@invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net
[signature.asc (application/pgp-signature, inline)]

Message sent on to "Erik C.J. Laan" <deb@elaan.dds.nl>:
Bug#339799. (Fri, 21 Aug 2009 08:42:13 GMT) Full text and rfc822 format available.

Added tag(s) fixed-upstream. Request was from Thomas Dickey <dickey@his.com> to control@bugs.debian.org. (Fri, 21 Aug 2009 08:48:08 GMT) Full text and rfc822 format available.

Information stored :
Bug#339799; Package mawk. (Fri, 21 Aug 2009 20:21:06 GMT) Full text and rfc822 format available.

Acknowledgement sent to elaan@dds.nl:
Extra info received and filed, but not forwarded. (Fri, 21 Aug 2009 20:21:07 GMT) Full text and rfc822 format available.

Message #39 received at 339799-quiet@bugs.debian.org (full text, mbox):

From: "Erik C.J. Laan" <elaan@dds.nl>
To: dickey@his.com, 339799-quiet@bugs.debian.org
Subject: Re: Bug#339799: #339799 mawk: printf %02s does not result in a leadng zero being printed.
Date: Fri, 21 Aug 2009 22:07:18 +0200
Thomas Dickey wrote:
> Further discussion with Aharon Robbins and Mike Brennan brought forth
> this information:
> 
> 	a) X/Open awk uses standard printf formatting, which does not produce
> 	   leading 0's.
> 
> 	b) platforms which produce leading 0's (Solaris, AIX, HPUX, IRIX64)
> 	   do this as a legacy (pre-standardization) feature.
> 
> 	c) if mawk was built on such a platform, it would have produced leading
> 	   0's, built on other platforms it did not.
> 
> 	d) Aharon Robbins changed gawk to no longer produce leading 0's.
> 
> So I modified mawk to explicitly not produce leading 0's, for consistent
> and conformance with the standard.  That change is in the 20090820 snapshot
> here:
> 
> 	ftp://invisible-island.net/mawk/
> 

Great, I'm all for standardization. I have no problem with this 
behaviour or even gawk's change, as I do not have the script that used 
the printf(... %02s ...) in use anymore. If I find an old copy of it 
somewhere I will try to remember to change it to %02i or %02d. Those are 
more appropriate anyway. Case closed as far as I'm concerned.

Erik.




Reply sent to Jonathan Nieder <jrnieder@gmail.com>:
You have taken responsibility. (Mon, 01 Mar 2010 19:33:12 GMT) Full text and rfc822 format available.

Notification sent to "Erik C.J. Laan" <deb@elaan.dds.nl>:
Bug acknowledged by developer. (Mon, 01 Mar 2010 19:33:12 GMT) Full text and rfc822 format available.

Message #44 received at 339799-done@bugs.debian.org (full text, mbox):

From: Jonathan Nieder <jrnieder@gmail.com>
To: 339799-done@bugs.debian.org
Cc: dickey@his.com
Subject: Re: mawk: printf %02s does not result in a leadng zero being printed.
Date: Mon, 1 Mar 2010 13:32:46 -0600
Erik C.J. Laan wrote:
> Thomas Dickey wrote:

>> Further discussion with Aharon Robbins and Mike Brennan brought forth
>> this information:
>>
>>	a) X/Open awk uses standard printf formatting, which does not produce
>>	   leading 0's.
>>
>>	b) platforms which produce leading 0's (Solaris, AIX, HPUX, IRIX64)
>>	   do this as a legacy (pre-standardization) feature.
>>
>>	c) if mawk was built on such a platform, it would have produced leading
>>	   0's, built on other platforms it did not.
>>
>>	d) Aharon Robbins changed gawk to no longer produce leading 0's.
>>
>> So I modified mawk to explicitly not produce leading 0's, for consistent
>> and conformance with the standard.
[...]
> Great, I'm all for standardization. I have no problem with this
> behaviour or even gawk's change, as I do not have the script that
> used the printf(... %02s ...) in use anymore. If I find an old copy
> of it somewhere I will try to remember to change it to %02i or %02d.
> Those are more appropriate anyway. Case closed as far as I'm
> concerned.

Thanks for the explanation.

Since the input is non-conforming, I am not too concerned with what
Debian does here.  Arnold Robbins’s corresponding change to gawk is
also upstream but not in Debian yet.

mawk lets glibc decide what to do, and glibc does not have the strange
behavior of some other platforms, so closing.




Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Tue, 30 Mar 2010 07:44:20 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Fri Apr 18 16:56:07 2014; Machine Name: beach.debian.org

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