coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: human-readable / block-size as a general utility?


From: Eric Blake
Subject: Re: human-readable / block-size as a general utility?
Date: Thu, 18 Aug 2011 09:08:40 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.11

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   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]