[syslinux] [PATCH] syslinux/com32: Fix the printing of left zero padded hexadecimals with a leading '0x'.

Brett Walker brett.walker at geometry.com.au
Thu Feb 8 13:08:46 PST 2018


You are right Martin. I haven't a lot of experience with C/C++.

What I find somewhat confusing is if hexnum is 0xFFFF1234 I would get 10 characters.

I now have a better understanding of printf's operation; the width specifier is a minimum width specifier.

Thanks for pointing out the noobie mistake. The patch is bad.

Thanks,
Brett

________________________________
From: Syslinux <syslinux-bounces at zytor.com> on behalf of Martin Str|mberg via Syslinux <syslinux at zytor.com>
Sent: Friday, 9 February 2018 2:19 AM
To: Brett Walker via Syslinux
Subject: Re: [syslinux] [PATCH] syslinux/com32: Fix the printing of left zero padded hexadecimals with a leading '0x'.

On Thu, Feb 08, 2018 at 11:01:21AM +0000, Brett Walker via Syslinux wrote:
> From: Brett Walker <brett.walker at geometry.com.au>
>
> When printing hexadecimal numbers to a fixed width, padded with leading zeros,
> and also having a leading '0x'; the resultant string can be shortened by up to
> two characters if any leading zero padding character required is.
>
>     int hexnum = 0x00001234;
>
>     printf("%08X", hexnum);  // results in 00001234
>     printf("%#08X", hexnum); // results in 0x001234
>
> To correct this, the zero padding counting logic needs to use ndigits instead of
> nchars.

No. You asked for at least 8 chars output. You got 8 chars output. If you
want/expect at least 10 chars output, ask for 10 chars.


--
MartinS
_______________________________________________
Syslinux mailing list
Submissions to Syslinux at zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux


More information about the Syslinux mailing list