libcflat: support # flag in printf
The only use is with %#x, where we'll automatically get 0x prefix.
Advantage over 0x%x can be seen with padding.
A simple test:
printf(".%#08x.\n", 0);
printf(".%#8x.\n", 0);
printf(".%#-8x.\n", 0);
printf(".%#08x.\n", 1);
printf(".%#8x.\n", 1);
printf(".%#-8x.\n", 1);
printf(".%#08x.\n", 0x123456);
printf(".%#8x.\n", 0x123456);
printf(".%#-8x.\n", 0x123456);
printf(".%#02x.\n", 0);
printf(".%#2x.\n", 0);
printf(".%#-2x.\n", 0);
printf(".%#02x.\n", 1);
printf(".%#2x.\n", 1);
printf(".%#-2x.\n", 1);
looks just like glibc:
.00000000.
. 0.
.0 .
.0x000001.
. 0x1.
.0x1 .
.0x123456.
.0x123456.
.0x123456.
.00.
. 0.
.0 .
.0x1.
.0x1.
.0x1.
Signed-off-by:
Radim Krčmář <rkrcmar@redhat.com>
Please register or sign in to comment