if precision is specified, 0 flag is ignored for diouXx conversions
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 20 May 1988 02:00:59 +0000 (18:00 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 20 May 1988 02:00:59 +0000 (18:00 -0800)
also, print out padding characters for special case 0 value, 0 precision

SCCS-vsn: lib/libc/stdio/vfprintf.c 5.26

usr/src/lib/libc/stdio/vfprintf.c

index 0eb7f59..f24636c 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)vfprintf.c 5.25 (Berkeley) %G%";
+static char sccsid[] = "@(#)vfprintf.c 5.26 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -247,13 +247,22 @@ rflag:            switch (*++fmt) {
 
                        /* unsigned conversions */
 nosign:                        sign = NULL;
 
                        /* unsigned conversions */
 nosign:                        sign = NULL;
+                       /*
+                        * ``... diouXx conversions ... if a precision is
+                        * specified, the 0 flag will be ignored.''
+                        *      -- ANSI X3J11
+                        */
+number:                        if (prec >= 0)
+                               padc = ' ';
                        /*
                         * ``The result of converting a zero value with an
                         * explicit precision of zero is no characters.''
                         *      -- ANSI X3J11
                         */
                        /*
                         * ``The result of converting a zero value with an
                         * explicit precision of zero is no characters.''
                         *      -- ANSI X3J11
                         */
-number:                        if (!_ulong && !prec)
-                               break;
+                       if (!_ulong && !prec) {
+                               size = 0;
+                               goto pforw;
+                       }
 
                        t = buf + BUF - 1;
                        do {
 
                        t = buf + BUF - 1;
                        do {