You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by fa...@apache.org on 2008/02/19 15:01:20 UTC

svn commit: r629100 - /stdcxx/trunk/src/num_put.cpp

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 <fa...@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