bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: printf/sprintf-modifier "0" not working in gawk 3.1.8 under Cygwin


From: Aharon Robbins
Subject: Re: printf/sprintf-modifier "0" not working in gawk 3.1.8 under Cygwin
Date: Tue, 18 May 2010 12:20:20 +0300
User-agent: Heirloom mailx 12.4 7/29/08

Greetings. Re this:

> Subject: printf/sprintf-modifier "0" not working in gawk 3.1.8 under Cygwin
> To: address@hidden
> From: address@hidden
> Date: Mon, 17 May 2010 11:55:25 +0200
>
> Hi,
>
> I recently ugraded to gawk 3.1.8. and stumbled upon a different behaviour
> to gawk 3.1.7.
> To reproduce, execute the following program:
> BEGIN {
>     number = 25
>     padded_number = sprintf("%04s", number)
>     print(padded_number)
>     printf("%04s", 25)
> }
>
> With 3.1.7 I get the expected result:
> 0025
> 0025
>
> With 3.1.8 I get:
>   25
>   25
>
> Best regards,
>
> Christian
>
>
> Vistec Electron Beam GmbH, GmbH mit Sitz in Jena
> Amtsgericht Jena HRB 205835, USt-IdNr.: DE 81 200 7851
> Geschaeftsfuehrer: Martyn P. Ansell, Wolfgang Dorl
> Tel.: +493641 6519 00, Fax: +493641 6519 22

The change is on purpose. Please see the top of the NEWS file:

> Changes from 3.1.7 to 3.1.8
> ---------------------------
> 1. The zero flag no longer applies to %c and %s; apparently the standards
>    changed at some point.

You can get the same result using

        sprintf("%04d", 25)

Thanks for taking the time to send in a report.

Arnold



reply via email to

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