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

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

Re: might be a bug in gawk


From: Micah Cowan
Subject: Re: might be a bug in gawk
Date: Fri, 27 Mar 2009 09:47:35 -0700
User-agent: Thunderbird 2.0.0.21 (X11/20090318)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Aharon Robbins wrote:
> Hi All.
> 
>> Date: Wed, 25 Mar 2009 11:28:02 -0700
>> From: Micah Cowan <address@hidden>
>> To: Andreas Schwab <address@hidden>
>> CC: Dave B <address@hidden>, address@hidden
>> Subject: Re: might be a  bug  in  gawk
>>
>>>>> There is no formatting directive that reqires an argument.  %28b is
>>>>> unknown and %29% is treated the same as %%. 
>>>> Where is that documented?
>>> Nowhere.  Both are undefined.
>> To be pedantic, %29% is not undefined, AFAICT: % is an ordinary
>> conversion specifier, and I don't see anything anywhere that says it
>> can't take a field width (but neither would I particularly expect
>> real-world implementations to behave appropriately with them).
>>
>> - --
>> Micah J. Cowan
>> Programmer, musician, typesetting enthusiast, gamer.
>> Maintainer of GNU Wget and GNU Teseq
>> http://micah.cowan.name/
> 
> Here is what's in the gawk code:
> 
>               case '%':
>                       need_format = FALSE;
>                       /*
>                        * 29 Oct. 2002:
>                        * The C99 standard pages 274 and 279 seem to imply that
>                        * since there's no arg converted, the field width 
> doesn't
>                        * apply.  The code already was that way, but this
>                        * comment documents it, at least in the code.
>                        */

Note that this comment is documenting that the field width isn't
_applied_, not that it isn't accepted, so AFAICT my comments remain
appropriate. It's explaining why you didn't get a % right-justified in a
29-width field.

But at any rate C99 is not the relevant standard for awk printf
behavior; SUS is, and SUS doesn't define it in terms of the C function,
but in terms of its own printf-like "format specification"; I don't see
any license for field width to be ignored for the % specifier. Arguably,
the field width should be applied (but I'm not recommending that change,
just noting that it could be more conforming).

- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer.
Maintainer of GNU Wget and GNU Teseq
http://micah.cowan.name/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknNAycACgkQ7M8hyUobTrE7egCbBRx5o/RqFDYUWWIEKSzTZ/mB
Kv0An006divpJVrMYtJEmiiW30sttGhb
=Gx2R
-----END PGP SIGNATURE-----




reply via email to

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