char intbuf[INTBUF_LEN], **table = 0, *tstr;
int ibuf_loc = INTBUF_LEN, ilen, zlen = 0, plen = 0, elen = 0;
- if (fld_s.prec < 0) /* default precision is 1 */
- fld_s.prec = 1;
-
if (fld_s.base == BASE_OCTAL) /* select string table to use */
table = octal;
else if (fld_s.base == BASE_DECIMAL)
elen = 2; /* account for the length of 0x */
}
+ if (fld_s.prec < 0) { /* default precision is 1 */
+ if ((fld_s.flags & (FLAG_MINUS | FLAG_ZERO)) == FLAG_ZERO &&
+ fld_s.width) {
+ fld_s.prec = fld_s.width - elen;
+ fld_s.width = 0;
+ } else
+ fld_s.prec = 1;
+ }
+
/* If there's a sign flag, account for it */
if (fld_s.flags & (FLAG_PLUS | FLAG_SPACE | INFO_NEGATIVE))
elen++;