nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] <Happy Dance!>

2017-08-16 18:43:14
   $ 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

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>