fix compile problems with msvc6
[reactos.git] / reactos / tools / rbuild / ssprintf.cpp
index 5085f2d..36a190c 100644 (file)
@@ -1,5 +1,18 @@
-// ssprintf.cpp
-
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
 #include "pch.h"
 
 #include <malloc.h>
@@ -113,7 +126,7 @@ number(std::string& f, LONGLONG num, int base, int size, int precision ,int type
        if (type & LEFT)
                type &= ~ZEROPAD;
        if (base < 2 || base > 36)
-               return 0;
+               return false;
        c = (type & ZEROPAD) ? '0' : ' ';
        sign = 0;
        if (type & SIGN) {
@@ -192,7 +205,7 @@ wnumber(std::wstring& f, LONGLONG num, int base, int size, int precision ,int ty
        if (base < 2 || base > 36)
                return 0;
        c = (type & ZEROPAD) ? L'0' : L' ';
-       sign = 0;
+       sign = false;
        if (type & SIGN) {
                if (num < 0) {
                        sign = L'-';
@@ -292,7 +305,9 @@ numberf(std::string& f, double __n, char exp_sign,  int size, int precision, int
        if ( exp_sign == 'g' || exp_sign == 'G' ) {
                type |= ZEROTRUNC;
                if ( exponent < -4 || fabs(exponent) >= precision )
-                        exp_sign -= 2; // g -> e and G -> E
+                       exp_sign -= 2; // g -> e and G -> E
+               else
+                       exp_sign = 'f';
        }
 
        if ( exp_sign == 'e' ||  exp_sign == 'E' ) {
@@ -302,7 +317,7 @@ numberf(std::string& f, double __n, char exp_sign,  int size, int precision, int
                else if (  frac < -0.5  )
                        e--;
 
-               result = numberf(f,__n/pow(10.0L,e),'f',size-4, precision, type);
+               result = numberf(f,__n/pow(10.0L,(long double)e),'f',size-4, precision, type);
                if (result < 0)
                        return false;
                f += exp_sign;
@@ -482,7 +497,9 @@ wnumberf(std::wstring& f, double __n, wchar_t exp_sign,  int size, int precision
        {
                type |= ZEROTRUNC;
                if ( exponent < -4 || fabs(exponent) >= precision )
-                        exp_sign -= 2; // g -> e and G -> E
+                       exp_sign -= 2; // g -> e and G -> E
+               else
+                       exp_sign = L'f';
        }
 
        if ( exp_sign == L'e' ||  exp_sign == L'E' )
@@ -493,7 +510,7 @@ wnumberf(std::wstring& f, double __n, wchar_t exp_sign,  int size, int precision
                else if (  frac < -0.5  )
                        e--;
 
-               result = wnumberf(f,__n/pow(10.0L,e),L'f',size-4, precision, type);
+               result = wnumberf(f,__n/pow(10.0L,(long double) e),L'f',size-4, precision, type);
                if (result < 0)
                        return false;
                f += exp_sign;
@@ -681,7 +698,9 @@ numberfl(std::string& f, long double __n, char exp_sign,  int size, int precisio
        if ( exp_sign == 'g' || exp_sign == 'G' ) {
                type |= ZEROTRUNC;
                if ( exponent < -4 || fabs(exponent) >= precision ) 
-                        exp_sign -= 2; // g -> e and G -> E
+                       exp_sign -= 2; // g -> e and G -> E
+               else
+                       exp_sign = 'f';
        }
 
        if ( exp_sign == 'e' || exp_sign == 'E' ) {
@@ -776,7 +795,7 @@ numberfl(std::string& f, long double __n, char exp_sign,  int size, int precisio
                {
                        while ( intr > 0.0 )
                        {
-                               p=intr;
+                               p=intr;
                                intr/=10.0L;
                                modfl(intr, &intr);
 
@@ -883,7 +902,9 @@ wnumberfl(std::wstring& f, long double __n, wchar_t exp_sign,  int size, int pre
        if ( exp_sign == L'g' || exp_sign == L'G' ) {
                type |= ZEROTRUNC;
                if ( exponent < -4 || fabs(exponent) >= precision ) 
-                        exp_sign -= 2; // g -> e and G -> E
+                       exp_sign -= 2; // g -> e and G -> E
+               else
+                       exp_sign = 'f';
        }
 
        if ( exp_sign == L'e' || exp_sign == L'E' ) {