[ros-diffs] [tkreuzer] 48317: [RTL] Revert accidental changes to sprintf in r47468

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Tue Jul 27 21:43:28 UTC 2010


Author: tkreuzer
Date: Tue Jul 27 21:43:26 2010
New Revision: 48317

URL: http://svn.reactos.org/svn/reactos?rev=48317&view=rev
Log:
[RTL]
Revert accidental changes to sprintf in r47468

Modified:
    branches/ros-amd64-bringup/reactos/lib/rtl/sprintf.c

Modified: branches/ros-amd64-bringup/reactos/lib/rtl/sprintf.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/rtl/sprintf.c?rev=48317&r1=48316&r2=48317&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/rtl/sprintf.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/rtl/sprintf.c [iso-8859-1] Tue Jul 27 21:43:26 2010
@@ -27,40 +27,33 @@
 #define SPECIAL	32		/* 0x */
 #define LARGE	64		/* use 'ABCDEF' instead of 'abcdef' */
 #define REMOVEHEX	256		/* use 256 as remve 0x frim BASE 16  */
-typedef struct {
-    unsigned int mantissal:32;
-    unsigned int mantissah:20;
-    unsigned int exponent:11;
-    unsigned int sign:1;
+typedef union {
+    struct {
+        unsigned int mantissal:32;
+        unsigned int mantissah:20;
+        unsigned int exponent:11;
+        unsigned int sign:1;
+    };
+    long long AsLongLong;
 } double_t;
+
+/* We depend on this being true */
+C_ASSERT(sizeof(double_t) == sizeof(double));
 
 static
 __inline
 int
-_isinf(double __x)
-{
-	union
-	{
-		double*   __x;
-		double_t*   x;
-	} x;
-
-	x.__x = &__x;
-	return ( x.x->exponent == 0x7ff  && ( x.x->mantissah == 0 && x.x->mantissal == 0 ));
+_isinf(double_t x)
+{
+	return ( x.exponent == 0x7ff  && ( x.mantissah == 0 && x.mantissal == 0 ));
 }
 
 static
 __inline
 int
-_isnan(double __x)
-{
-	union
-	{
-		double*   __x;
-		double_t*   x;
-	} x;
-    	x.__x = &__x;
-	return ( x.x->exponent == 0x7ff  && ( x.x->mantissah != 0 || x.x->mantissal != 0 ));
+_isnan(double_t x)
+{
+	return ( x.exponent == 0x7ff  && ( x.mantissah != 0 || x.mantissal != 0 ));
 }
 
 
@@ -180,14 +173,13 @@
 }
 
 static char *
-numberf(char * buf, char * end, double num, int base, int size, int precision, int type)
+numberf(char * buf, char * end, double_t num, int base, int size, int precision, int type)
 {
 	char c,sign,tmp[66];
 	const char *digits;
 	const char *small_digits = "0123456789abcdefghijklmnopqrstuvwxyz";
 	const char *large_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 	int i;
-	long long x;
 
     /* FIXME
        the float version of number is direcly copy of number
@@ -201,9 +193,9 @@
 	c = (type & ZEROPAD) ? '0' : ' ';
 	sign = 0;
 	if (type & SIGN) {
-		if (num < 0) {
+		if (num.sign) {
 			sign = '-';
-			num = -num;
+			num.sign = 0;
 			size--;
 		} else if (type & PLUS) {
 			sign = '+';
@@ -220,15 +212,11 @@
 			size--;
 	}
 	i = 0;
-	if (num == 0)
+	if (num.AsLongLong == 0)
 		tmp[i++] = '0';
-	else while (num != 0)
+	else while (num.AsLongLong != 0)
     {
-        x = num;
-		tmp[i++] = digits[do_div(&x,base)];
-#ifndef _M_ARM // Missing __floatdidf in CeGCC 0.55 -- GCC 4.4
-		num=x;
-#endif
+		tmp[i++] = digits[do_div(&num.AsLongLong,base)];
     }
 	if (i > precision)
 		precision = i;
@@ -389,7 +377,7 @@
 {
 	int len;
 	unsigned long long num;
-	double _double;
+	double_t _double;
 
 	int base;
 	char *str, *end;
@@ -603,7 +591,7 @@
 		case 'f':
 		case 'g':
 		case 'G':
-          _double = (double)va_arg(args, double);
+          _double = va_arg(args, double_t);
          if ( _isnan(_double) ) {
             s = "Nan";
             len = 3;
@@ -634,7 +622,7 @@
          } else {
             if ( precision == -1 )
                precision = 6;
-               	str = numberf(str, end, (int)_double, base, field_width, precision, flags);
+               	str = numberf(str, end, _double, base, field_width, precision, flags);
          }
 
           continue;




More information about the Ros-diffs mailing list