[ros-diffs] [fireball] 35764: Gregor Schneider <grschneider at gmail.com> - Only pad with zeroes if padding requested. - Show signs for floating point numbers without checking for SIGN type (since there is no unsigned float/double). See issue #3587 for more details.

fireball at svn.reactos.org fireball at svn.reactos.org
Fri Aug 29 20:57:31 CEST 2008


Author: fireball
Date: Fri Aug 29 13:57:31 2008
New Revision: 35764

URL: http://svn.reactos.org/svn/reactos?rev=35764&view=rev
Log:
Gregor Schneider <grschneider at gmail.com>
- Only pad with zeroes if padding requested.
- Show signs for floating point numbers without checking for SIGN type (since there is no unsigned float/double).
See issue #3587 for more details.

Modified:
    trunk/reactos/lib/sdk/crt/stdio/lnx_sprintf.c

Modified: trunk/reactos/lib/sdk/crt/stdio/lnx_sprintf.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdio/lnx_sprintf.c?rev=35764&r1=35763&r2=35764&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/stdio/lnx_sprintf.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/stdio/lnx_sprintf.c [iso-8859-1] Fri Aug 29 13:57:31 2008
@@ -167,18 +167,16 @@
 		return 0;
 	c = (type & ZEROPAD) ? '0' : ' ';
 	sign = 0;
-	if (type & SIGN) {
-		if (num < 0) {
-			sign = '-';
-			num = -num;
-			size--;
-		} else if (type & PLUS) {
-			sign = '+';
-			size--;
-		} else if (type & SPACE) {
-			sign = ' ';
-			size--;
-		}
+	if (num < 0) {
+		sign = '-';
+		num = -num;
+		size--;
+	} else if (type & PLUS) {
+		sign = '+';
+		size--;
+	} else if (type & SPACE) {
+		sign = ' ';
+		size--;
 	}
 	if (type & SPECIAL)  {
 		if (base == 16)
@@ -231,10 +229,12 @@
 			++buf;
 		}
 	}
-	while (i < precision--) {
-		if (buf <= end)
-			*buf = '0';
-		++buf;
+	if (type & ZEROPAD) {
+		while (i < precision--) {
+			if (buf <= end)
+				*buf = '0';
+			++buf;
+		}
 	}
 	while (i-- > 0) {
 		if (buf <= end)



More information about the Ros-diffs mailing list