On 08/18/2011 08:57 AM, Pádraig Brady wrote:

Oops I meant %H.
Even though a capital I discounted it as there are others used:
http://www.pixelbeat.org/programming/gcc/format_specs.html

I don't know of anything using %H, so that would indeed be viable, if we wanted to make printf(1) the way to expose conversion of a number into human-readable form.


Meanwhile, although both the bash builtin and coreutils' printf parse these two 
formats, they actually still end up widening to int before printing; arguably a 
bug:

$ printf %hhx -1
ffffffffffffffff
$ echo 'format(%hx,-1)' | m4

Typo - I meant %hhx in this example.

ff


I'd agree that's a bug.
I also notice that neither solaris or freebsd support %h

POSIX does not require %h support in printf(1), only in printf(3). And gnulib lists which platforms have incomplete printf(3) support, including %h support as one of its tests.

--
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Reply via email to