Date: Tue, 20 Jul 2010 19:11:47 +0000 (UTC) From: Jung-uk Kim <jkim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r210309 - stable/7/sys/kern Message-ID: <201007201911.o6KJBlAg083868@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007201911.o6KJBlAg083868>