From 188bc140c02e97423fac4f5efdb68e60bc0c37b0 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 28 May 2001 18:22:44 +0000 Subject: Handle printf ("%#.0o",0); --- newlib/libc/stdio/vfprintf.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'newlib/libc/stdio') diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index 9a2cf4fb6..f6bba4979 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -790,6 +790,18 @@ number: if ((dprec = prec) >= 0) goto skipsize; } } + /* + * ...result is to be converted to an 'alternate form'. + * For o conversion, it increases the precision to force + * the first digit of the result to be a zero." + * -- ANSI X3J11 + * + * To demonstrate this case, compile and run: + * printf ("%#.0o",0); + */ + else if (base == OCT && (flags & ALT)) + *--cp = '0'; + size = buf + BUF - cp; skipsize: break; -- cgit v1.2.3