summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libc/stdio/vfprintf.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
index 3c3d4d3..0f241de 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -306,8 +306,7 @@ vfprintf(fp, fmt0, ap)
u_quad_t uqval; /* %q integers */
int base; /* base for [diouxX] conversion */
int dprec; /* a copy of prec if [diouxX], 0 otherwise */
- int fieldsz; /* field size expanded by sign, etc */
- int realsz; /* field size expanded by dprec */
+ int realsz; /* field size expanded by dprec, sign, etc */
int size; /* size of converted field or string */
char *xdigs; /* digits for [xX] conversion */
#define NIOV 8
@@ -708,14 +707,13 @@ number: if ((dprec = prec) >= 0)
* floating precision; finally, if LADJUST, pad with blanks.
*
* Compute actual size, so we know how much to pad.
- * fieldsz excludes decimal prec; realsz includes it.
+ * size excludes decimal prec; realsz includes it.
*/
- fieldsz = size;
+ realsz = dprec > size ? dprec : size;
if (sign)
- fieldsz++;
+ realsz++;
else if (flags & HEXPREFIX)
- fieldsz += 2;
- realsz = dprec > fieldsz ? dprec : fieldsz;
+ realsz += 2;
/* right-adjusting blank padding */
if ((flags & (LADJUST|ZEROPAD)) == 0)
@@ -735,7 +733,7 @@ number: if ((dprec = prec) >= 0)
PAD(width - realsz, zeroes);
/* leading zeroes from decimal precision */
- PAD(dprec - fieldsz, zeroes);
+ PAD(dprec - size, zeroes);
/* the string or number proper */
#ifdef FLOATING_POINT
OpenPOWER on IntegriCloud