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: Maciej W. Rozycki
Subject: Re: Bugs in printf/sprintf formatted output
Date: Wed, 7 Aug 2024 18:06:06 +0100 (BST)

On Tue, 6 Aug 2024, arnold@skeeve.com wrote:

> > - Missing leading zero for signed integer conversions for the specific 
> >   precision of one above the number of digits required to represent the 
> >   number and negative numbers, e.g.: { printf "%.2i", -1 } prints "-1" 
> >   rather than "-01"; similarly { printf "%.3i", -12 }' prints "-12" rather 
> >   than "-012".  Other precision values or natural numbers work correctly, 
> >   e.g. { printf "%.3i", -1 } prints "-001" as, { printf "%.2i", 1 } prints 
> >   "01", etc., as expected.
> >
> > - The + and space flags not ignored for unsigned integer conversions where 
> >   the precision specified causes any leading zeros to be printed, e.g.:
> >   { printf "%+.2u", 1 } prints "+01" rather than "01" and then similarly: 
> >   { printf "% .3u", 12 } prints " 012" rather than "012".  If no leading 
> >   zeros are printed, then output is correct, e.g. { printf "%+.2u", 12 } 
> >   prints "12" as expected.
> 
> I have added tests for these cases (in test/printf-corners.awk) and
> fixed the code so that they now pass. I have pushed to the
> stable/printf-rework branch.  Please review.

 This branch as at commit 8a88c089d0aa ("Fix some additional printf corner 
cases and add tests.") has passed my verification and I think it's good to 
go now.  Thank you for getting these issues sorted.

  Maciej




reply via email to

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