Subject: printf ignores length modifier

From: "Marcel Böhme" <[email-masked]>
Date: Sat, 26 Jan 2013 10:41:59 +0100 (CET)

Dear all,

I've been looking into the semantic changes introduced to printf with the commit 62e1d5259df82155ae52201678093381a35d898e (08.07.2004) and found besides a lot of progression (conformance to C99 etc.) the following oddities:

The tool printf ignores length modifiers (cf. http://linux.die.net/man/3/printf)
In fact, any (combination of) length modifier is substituted by "ll" as length modifier. Is this intended?

$old/printf "%hi\n" 0xFFFF
-1
$printf "%hi\n" 0xFFFF
65535

$old/printf  "%hi\n" 0xFFF
4095
$old/printf  "%hhLljtzllhi\n" 0xFFF
printf: %h: invalid directive
$printf  "%hhLljtzllhi\n" 0xFFF
4095

On the on hand the comment reads:
 332   /* Create a null-terminated copy of the % directive, with an
 333      intmax_t-wide length modifier substituted for any existing
 334      integer length modifier.  */

On the other hand the commit comment reads:
> Add support for C99 'j', 't', 'z' length modifiers (like Bash).

Best regards,
 Marcel

PS: http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=62e1d5259df82155ae52201678093381a35d898e