bug-gawk
[Top][All Lists]
Advanced

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

Re: Bugs in printf/sprintf formatted output


From: arnold
Subject: Re: Bugs in printf/sprintf formatted output
Date: Sat, 06 Jul 2024 22:57:23 -0600
User-agent: Heirloom mailx 12.5 7/5/10

Hi.

Thanks for the patches. I will review and apply and credit appropriately.

With respect to "nan" as input, the gawk manual is clear that "nan" and
"inf" must be written as "+nan", "-nan", "+inf" or "-inf" to be
recognized. Otherwise something like

        echo nancy | awk '{ print $1 + 1 }'

prints "nan" instead of 1.

Thanks,

Arnold

"Maciej W. Rozycki" <macro@redhat.com> wrote:

> Hi,
>
> On Mon, 24 Jun 2024, Maciej W. Rozycki wrote:
>
> > > First, did you look at test/printf-corners.awk? Did that cover
> > > your origial set of issues? If not, what else needs to be
> > > included there?
> > 
> >  I haven't, I have only run verification against glibc, which already took 
> > a couple of hours.  I'll have a look.
>
>  I have looked at test/printf-corners.awk now and it seems to correctly 
> cover the cases listed, except for those that use "nan" literally as input 
> and produce zero formatted according to the conversion format supplied.  
> As I discussed previously this is a questionable case, so maybe it's best 
> not to handle it at this time.
>
>  I have now submitted a patch series separately that extends testing so as 
> to cover the bignum code paths as well, and also to cover further specific 
> cases.
>
>  I need to correct myself here:
>
> > > >  Preexisting issues still unresolved:
> > > >
> > > > - missing + character in the non-bignum mode only for the input of 0 
> > > > with 
> > > >   the + flag, precision of 0 and the signed integer conversions, e.g.
> > > >   { printf "%+.i", 0 } produces "" rather than "+",
> > > >
> > > > - missing space character in the non-bignum mode only for the input of 
> > > > 0 
> > > >   with the space flag, precision of 0 and the signed integer 
> > > > conversions, 
> > > >   e.g. { printf "% .i", 0 } produces "" rather than " ".
>
> -- these have been partially resolved in that for the field width of 0, as 
> with { printf "%+.i", 0 } and { printf "% .i", 0 }, output produced is 
> correctly "+" and " " respectively, however not for the field width of 1, 
> as with { printf "%+1.i", 0 } (" " produced, "+" expected) or the unsigned 
> conversions such as { printf "%+.u", 0 } ("+" produced, "" expected) or
> { printf "% .u", 0 } (" " produced, "" expected).  This is an oversight of 
> mine, sorry.  These cases have been covered in the patch series submitted.
>
>   Maciej



reply via email to

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