stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r629100 - /stdcxx/trunk/src/num_put.cpp
Date Tue, 19 Feb 2008 14:01:20 GMT
Author: faridz
Date: Tue Feb 19 06:01:16 2008
New Revision: 629100

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

	STDCXX-2
	* src/num_put.cpp (__rw_fix_flt): Added new parameter: precision.
	Added workaround for STDCXX-2 issue.
	(__rw_put_num): Pass precision value in the __rw_fix_flt().

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=629100&r1=629099&r2=629100&view=diff
==============================================================================
--- stdcxx/trunk/src/num_put.cpp (original)
+++ stdcxx/trunk/src/num_put.cpp Tue Feb 19 06:01:16 2008
@@ -563,10 +563,33 @@
 
 
 static inline void
-__rw_fix_flt (char *&end, _RWSTD_SIZE_T &len, unsigned flags)
+__rw_fix_flt (char *&end, _RWSTD_SIZE_T &len,
+              unsigned flags, _RWSTD_STREAMSIZE prec)
 {
 #if defined (_WIN32) || defined (_WIN64)
 
+    char* beg = end - len;
+
+    // workaround for the STDCXX-2 issue
+    if (   !(flags & _RWSTD_IOS_FIXED)
+        && 2 < len
+        && '0' == beg [0]
+        && ('.' == beg [1] || ',' == beg [1])) {
+
+        // for the 0.0 value the MSVC libc inserts redundant '0' character
+        const char* ptr;
+        for (ptr = beg + 2; ptr != end && '0' == *ptr; ++ptr) ;
+
+        if (ptr == end) {
+            const _RWSTD_SIZE_T exp_len =
+                0 > prec ? 7 : (1 < prec ? prec + 1 : 2);
+            if (exp_len < len) {
+                end = beg + exp_len;
+                len = exp_len;
+            }
+        }
+    }
+
     if (len > 5) {
         // make Win32 output conform to C99 printf() requirements
         // on the exponent: The exponent always contains at least
@@ -608,6 +631,8 @@
 
 #else
 
+    _RWSTD_UNUSED (prec);
+
     // normalize the format of infinity and NaN to one of
     // { INF, inf, NAN, nan, NANQ, nanq, NANS, nans }
     // for portability
@@ -760,7 +785,7 @@
         end = *pbuf + len;
 
         // fix up output to conform to C99
-        __rw_fix_flt (end, len, flags);
+        __rw_fix_flt (end, len, flags, fpr);
         break;
 
     case __rw_facet::_C_double | __rw_facet::_C_ptr:
@@ -788,7 +813,7 @@
         end = *pbuf + len;
 
         // fix up output to conform to C99
-        __rw_fix_flt (end, len, flags);
+        __rw_fix_flt (end, len, flags, fpr);
         break;
 
 #ifndef _RWSTD_NO_LONG_DOUBLE
@@ -817,7 +842,7 @@
         end = *pbuf + len;
 
         // fix up output to conform to C99
-        __rw_fix_flt (end, len, flags);
+        __rw_fix_flt (end, len, flags, fpr);
         break;
 
 #endif   // _RWSTD_NO_LONG_DOUBLE



Mime
View raw message