[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nmh-workers] <Happy Dance!>
From: |
Ken Hornstein |
Subject: |
Re: [Nmh-workers] <Happy Dance!> |
Date: |
Wed, 16 Aug 2017 19:41:47 -0400 |
> $ fmttest -raw -format '_%4(putnumf)_' ''
> _ 0_
> $ fmttest -raw -format '_%0(putnumf)_' ''
> ^C
Hm, was it always like that? No, looks like that happened when cpnumber()
was re-written.
Sigh. This exposes some warts. cpnumber() always took an unsigned int
as the "width" argument, but if you do something like:
fmttest -raw -format '_%-4(putnumf)_' ''
Then due to integer promotion rules width ends up as something like
4294967292 which is almost certainly what you don't want. The 1.5
cpnumber() would at least handle a width of 0 correctly, but checked
to see if width was negative ... which could never happen, I think?
Oh, wait, it was assigned to a signed int in that function, so I guess
that worked correctly as well. Seems like for 1.7 we should change
cpnumber() to take a signed int and make sure that it changes a negative
width to positive and handles a width of 0 correctly.
--Ken