stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r631678 - /stdcxx/trunk/src/num_put.cpp
Date Wed, 27 Feb 2008 18:58:51 GMT
Author: faridz
Date: Wed Feb 27 10:58:49 2008
New Revision: 631678

URL: http://svn.apache.org/viewvc?rev=631678&view=rev
Log:
2008-02-19 Farid Zaripov <farid_zaripov@epam.com>

	STDCXX-2
	* src/num_put.cpp (__rw_fix_flt): Updated workaround for STDCXX-2 issue.
	Fixed detection of infinity (#INF), added detection of the quiet NAN (#IND).

Modified:
    stdcxx/trunk/src/num_put.cpp

Modified: stdcxx/trunk/src/num_put.cpp
URL: http://svn.apache.org/viewvc/stdcxx/trunk/src/num_put.cpp?rev=631678&r1=631677&r2=631678&view=diff
==============================================================================
--- stdcxx/trunk/src/num_put.cpp (original)
+++ stdcxx/trunk/src/num_put.cpp Wed Feb 27 10:58:49 2008
@@ -571,12 +571,14 @@
     char* beg = end - len;
 
     // workaround for the STDCXX-2 issue
-    if (   !(flags & _RWSTD_IOS_FIXED)
+    if (   _RWSTD_IOS_FIXED != (flags & _RWSTD_IOS_FLOATFIELD)
+        && _RWSTD_IOS_SCIENTIFIC != (flags & _RWSTD_IOS_FLOATFIELD)
         && 2 < len
         && '0' == beg [0]
         && ('.' == beg [1] || ',' == beg [1])) {
 
         // for the 0.0 value the MSVC libc inserts redundant '0' character
+        // when %g format is used in sprintf()
         const char* ptr;
         for (ptr = beg + 2; ptr != end && '0' == *ptr; ++ptr) ;
 
@@ -602,15 +604,30 @@
             --end;
         }
         else if ('#' == end [-4]) {
-            // normalize the format of infinity to conform to C99
-
-            const char str[] = "iInNfF";
-
+            // may be #INF or #IND
             const bool cap = !!(flags & _RWSTD_IOS_UPPERCASE);
 
-            end [-6] = str [cap + 0];
-            end [-5] = str [cap + 2];
-            end [-4] = str [cap + 4];
+            if ('F' == end [-1]) {
+                // assuming #INF
+                // normalize the format of infinity to conform to C99
+
+                const char str[] = "iInNfF";
+
+                end [-6] = str [cap + 0];
+                end [-5] = str [cap + 2];
+                end [-4] = str [cap + 4];
+            }
+            else {
+                // assuming #IND
+                // normalize the format of NaN to conform to C99
+
+                const char str[] = "nNaA";
+
+                end [-6] = str [cap + 0];
+                end [-5] = str [cap + 2];
+                end [-4] = str [cap + 0];
+            }
+
             end -= 3;
             len -= 3;
         }



Mime
View raw message