bug-gawk
[Top][All Lists]
Advanced

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

Re: gawk - printf discards field-width when space modifier used [SOLVED]


From: arnold
Subject: Re: gawk - printf discards field-width when space modifier used [SOLVED]
Date: Sun, 09 Jan 2022 01:56:37 -0700
User-agent: Heirloom mailx 12.5 7/5/10

Hi David.

Thanks for taking the time to report an issue, even though it
turns out to not have been one. Don't worry about the CRI, it
happens to all of us now and then.

Take it easy,

Arnold

"David C. Rankin" <drankinatty@suddenlinkmail.com> wrote:

> On 1/8/22 9:40 AM, Ed Morton wrote:
> >        printf j ? " % 4d%s" : "% 4d%s", rv, (j<cols-1) ? "" : ORS > 
> > "file.txt"
>
> Ed, All,
>
>   I apologize. I was suffering from a momentary CRI. This can be closed. I was
> short by 1 on my field-width thinking the space-modifier provided the
> additional space before the specified field-width for the minus sign instead
> of the space being reserved out of the specified field-width.
>
> (a field-width of 5 was needed instead of 4)
>
>   So:
>
> printf (j) ? " % 5d%s" : "% 5d%s", rv, (j<cols-1) ? "" : ORS > "file.txt"
>
>   works just fine, or more appropriately as Ed suggested:
>
> printf (j ? " % 5d%s" : "% 5d%s"), rv, ((j<cols-1) ? "" : ORS) > "file.txt"
>
>   So, hat-in-hand, this can be closed.
>
> (CRI - cranal-rectal inversion, e.g. head up my ...)
>
> -- 
> David C. Rankin, J.D.,P.E.



reply via email to

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