Implement optional 'precision' for numbers. Previously, it was parsed but

ignored.  Some third-party modules (e.g., APCICA) prefer this format over
zero padding flag '0'.
This commit is contained in:
Jung-uk Kim 2010-07-08 22:13:23 +00:00
parent b48aee40b9
commit 4624e08a59
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=209836

View File

@ -800,7 +800,8 @@ reswitch: switch (ch = (u_char)*fmt++) {
neg = 1;
num = -(intmax_t)num;
}
p = ksprintn(nbuf, num, base, &tmp, upper);
p = ksprintn(nbuf, num, base, &n, upper);
tmp = 0;
if (sharpflag && num != 0) {
if (base == 8)
tmp++;
@ -810,10 +811,13 @@ reswitch: switch (ch = (u_char)*fmt++) {
if (neg)
tmp++;
if (!ladjust && padc != '0' && width
&& (width -= tmp) > 0)
while (width--)
PCHAR(padc);
if (!ladjust && padc == '0')
dwidth = width - tmp;
width -= tmp + MAX(dwidth, n);
dwidth -= n;
if (!ladjust)
while (width-- > 0)
PCHAR(' ');
if (neg)
PCHAR('-');
if (sharpflag && num != 0) {
@ -824,16 +828,15 @@ reswitch: switch (ch = (u_char)*fmt++) {
PCHAR('x');
}
}
if (!ladjust && width && (width -= tmp) > 0)
while (width--)
PCHAR(padc);
while (dwidth-- > 0)
PCHAR('0');
while (*p)
PCHAR(*p--);
if (ladjust && width && (width -= tmp) > 0)
while (width--)
PCHAR(padc);
if (ladjust)
while (width-- > 0)
PCHAR(' ');
break;
default: