svn commit: r210309 - stable/7/sys/kern
Jung-uk Kim
jkim at FreeBSD.org
Tue Jul 20 19:11:47 UTC 2010
Author: jkim
Date: Tue Jul 20 19:11:47 2010
New Revision: 210309
URL: http://svn.freebsd.org/changeset/base/210309
Log:
MFC: r209836, r209949
Implement optional 'precision' for numbers. Previously, it was parsed but
ignored. Some third-party modules (e.g., ACPICA) prefer this format over
zero padding flag '0'.
Modified:
stable/7/sys/kern/subr_prf.c
Directory Properties:
stable/7/sys/ (props changed)
stable/7/sys/cddl/contrib/opensolaris/ (props changed)
stable/7/sys/contrib/dev/acpica/ (props changed)
stable/7/sys/contrib/pf/ (props changed)
Modified: stable/7/sys/kern/subr_prf.c
==============================================================================
--- stable/7/sys/kern/subr_prf.c Tue Jul 20 19:06:37 2010 (r210308)
+++ stable/7/sys/kern/subr_prf.c Tue Jul 20 19:11:47 2010 (r210309)
@@ -822,7 +822,8 @@ number:
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++;
@@ -832,10 +833,13 @@ number:
if (neg)
tmp++;
- if (!ladjust && padc != '0' && width
- && (width -= tmp) > 0)
- while (width--)
- PCHAR(padc);
+ if (!ladjust && padc == '0')
+ dwidth = width - tmp;
+ width -= tmp + imax(dwidth, n);
+ dwidth -= n;
+ if (!ladjust)
+ while (width-- > 0)
+ PCHAR(' ');
if (neg)
PCHAR('-');
if (sharpflag && num != 0) {
@@ -846,16 +850,15 @@ number:
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:
More information about the svn-src-stable-7
mailing list