OSDN Git Service

Handle printf ("%#.0o",0);
authornickc <nickc>
Mon, 28 May 2001 18:22:44 +0000 (18:22 +0000)
committernickc <nickc>
Mon, 28 May 2001 18:22:44 +0000 (18:22 +0000)
newlib/ChangeLog
newlib/libc/stdio/vfprintf.c

index 5c23dec..d83c52f 100644 (file)
@@ -1,3 +1,7 @@
+2001-05-28  Nick Clifton  <nickc@cambridge.redhat.com>
+
+       * libc/stdio/vfprintf.c (_VFPRINTF_R): Handle printf ("%#.0o",0)
+
 2001-05-25  Nick Clifton  <nickc@cambridge.redhat.com>
 
        * libc/machine/xscale/memcmp.c: Fix bug when both pointers have
index 9a2cf4f..f6bba49 100644 (file)
@@ -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;