stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r551735 - /incubator/stdcxx/trunk/src/num_put.cpp
Date Thu, 28 Jun 2007 23:52:51 GMT
Author: sebor
Date: Thu Jun 28 16:52:50 2007
New Revision: 551735

URL: http://svn.apache.org/viewvc?view=rev&rev=551735
Log:
2007-06-28  Martin Sebor  <sebor@roguewave.com>

	STDCXX-461
	* num_put.cpp (__rw_fix_flt): Corrected the formatting of Infinities
	and NaN's when precision exceeds the length of the formatted string.

Modified:
    incubator/stdcxx/trunk/src/num_put.cpp

Modified: incubator/stdcxx/trunk/src/num_put.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/src/num_put.cpp?view=diff&rev=551735&r1=551734&r2=551735
==============================================================================
--- incubator/stdcxx/trunk/src/num_put.cpp (original)
+++ incubator/stdcxx/trunk/src/num_put.cpp Thu Jun 28 16:52:50 2007
@@ -22,16 +22,13 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 1994-2006 Rogue Wave Software.
+ * Copyright 2001-2006 Rogue Wave Software.
  * 
  **************************************************************************/
 
 #define _RWSTD_LIB_SRC
-
 #include <rw/_defs.h>
 
-#ifndef _RWSTD_NO_V3_LOCALE
-
 #include <limits>     // for numeric_limits
 
 #include <stdio.h>    // for snprintf()
@@ -621,13 +618,23 @@
 
     typedef unsigned char UChar;
 
-    if (43 /* '+' or '-' */ == __rw_digit_map [UChar (*beg)])
+    // is there a sign?
+    bool sgn = false;
+
+    if (43 /* '+' or '-' */ == __rw_digit_map [UChar (*beg)]) {
+        sgn = true;
         ++beg;
+    }
 
     const char* pstr;
 
     switch (__rw_digit_map [UChar (*beg)]) {
-    case 18 /* 'I' or 'i' */ : pstr = "iInNfF\0\0"; break;
+
+    case 18 /* 'I' or 'i' */ :
+        pstr = "iInNfF\0\0";
+        len  = 3;
+        break;
+
     case 23 /* 'N' or 'n' */ : {
 
         // distinguish between quiet and signaling NaN
@@ -638,12 +645,18 @@
         // AIX, output NaNQ and NaNS, respectively)
 
         const UChar last = __rw_digit_map [UChar (*(end - 1))];
-        if (26 /* 'Q' or 'q' */ == last)
+        if (26 /* 'Q' or 'q' */ == last) {
             pstr = "nNaAnNqQ";
-        else if (28 /* 'S' or 's' */ == last)
+            len  = 4;
+        }
+        else if (28 /* 'S' or 's' */ == last) {
             pstr = "nNaAnNsS";
-        else
+            len  = 4;
+        }
+        else {
             pstr = "nNaAnN\0\0";
+            len  = 3;
+        }
         break;
     }
 
@@ -657,9 +670,12 @@
     beg [1] = pstr [cap + 2];
     beg [2] = pstr [cap + 4];
     beg [3] = pstr [cap + 6];
-    beg [4] = '\0';
 
-    end = beg + 3 + ('0' != beg [3]);
+    end = beg + 3 + ('\0' != beg [3]);
+
+    // increase the length by one for the sign
+    if (sgn)
+        ++len;
 
 #endif   // _WIN{32,64}
 
@@ -900,6 +916,3 @@
 
 
 }   // namespace __rw
-
-
-#endif   // _V3_LOCALE



Mime
View raw message