Re: [PATCH 1/1] lib/vsprintf.c: "%#o",0 becomes '0' instead of '00'

From: Pierre Carrier
Date: Sun May 06 2012 - 22:20:50 EST


On Mon, May 7, 2012 at 3:59 AM, Joe Perches <joe@xxxxxxxxxxx> wrote:
> If you do this, why not change 0-7 instead of just 0?

Consistency with POSIX *printf.

"#: Specifies that the value is to be converted to an alternative
form. For o conversion, it increases the precision (if necessary) to
force the first digit of the result to be zero."
-- http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html

% cat octal.c;gcc -o octal octal.c;./octal
#include <stdio.h>
void main() {
int i;
for (i=0;i<10;i++) printf("%#o ", i);
puts("");
}
0 01 02 03 04 05 06 07 010 011

--
Pierre
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/