svn commit: r210305 - stable/8/sys/kern

Jung-uk Kim jkim at FreeBSD.org
Tue Jul 20 18:55:14 UTC 2010


Author: jkim
Date: Tue Jul 20 18:55:13 2010
New Revision: 210305
URL: http://svn.freebsd.org/changeset/base/210305

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/8/sys/kern/subr_prf.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/kern/subr_prf.c
==============================================================================
--- stable/8/sys/kern/subr_prf.c	Tue Jul 20 18:43:15 2010	(r210304)
+++ stable/8/sys/kern/subr_prf.c	Tue Jul 20 18:55:13 2010	(r210305)
@@ -800,7 +800,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++;
@@ -810,10 +811,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) {
@@ -824,16 +828,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-8 mailing list