Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79605 - branches/release/boost
From: antoshkka_at_[hidden]
Date: 2012-07-19 14:42:34


Author: apolukhin
Date: 2012-07-19 14:42:34 EDT (Thu, 19 Jul 2012)
New Revision: 79605
URL: http://svn.boost.org/trac/boost/changeset/79605

Log:
Merge fix of VC warning (fixes #7116)
Text files modified:
   branches/release/boost/lexical_cast.hpp | 36 +++++++++++++++++++++---------------
   1 files changed, 21 insertions(+), 15 deletions(-)

Modified: branches/release/boost/lexical_cast.hpp
==============================================================================
--- branches/release/boost/lexical_cast.hpp (original)
+++ branches/release/boost/lexical_cast.hpp 2012-07-19 14:42:34 EDT (Thu, 19 Jul 2012)
@@ -1344,25 +1344,30 @@
                 return shl_input_streamable(val);
             }
 
-#if (defined _MSC_VER)
-# pragma warning( push )
-// C4996: This function or variable may be unsafe. Consider using sprintf_s instead
-# pragma warning( disable : 4996 )
-#endif
             static bool shl_real_type(float val, char* begin, char*& end)
             { using namespace std;
                 if (put_inf_nan(begin, end, val)) return true;
- end = begin;
                 const double val_as_double = val;
- end += sprintf(begin,"%.*g", static_cast<int>(boost::detail::lcast_get_precision<float>()), val_as_double);
+ end = begin +
+#if (defined _MSC_VER)
+ sprintf_s(begin, end-begin,
+#else
+ sprintf(begin,
+#endif
+ "%.*g", static_cast<int>(boost::detail::lcast_get_precision<float>()), val_as_double);
                 return end > begin;
             }
 
             static bool shl_real_type(double val, char* begin, char*& end)
             { using namespace std;
                 if (put_inf_nan(begin, end, val)) return true;
- end = begin;
- end += sprintf(begin,"%.*g", static_cast<int>(boost::detail::lcast_get_precision<double>()), val);
+ end = begin +
+#if (defined _MSC_VER)
+ sprintf_s(begin, end-begin,
+#else
+ sprintf(begin,
+#endif
+ "%.*g", static_cast<int>(boost::detail::lcast_get_precision<double>()), val);
                 return end > begin;
             }
 
@@ -1370,16 +1375,17 @@
             static bool shl_real_type(long double val, char* begin, char*& end)
             { using namespace std;
                 if (put_inf_nan(begin, end, val)) return true;
- end = begin;
- end += sprintf(begin,"%.*Lg", static_cast<int>(boost::detail::lcast_get_precision<long double>()), val );
+ end = begin +
+#if (defined _MSC_VER)
+ sprintf_s(begin, end-begin,
+#else
+ sprintf(begin,
+#endif
+ "%.*Lg", static_cast<int>(boost::detail::lcast_get_precision<long double>()), val );
                 return end > begin;
             }
 #endif
 
-#if (defined _MSC_VER)
-# pragma warning( pop )
-#endif
-
 
 #if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_SWPRINTF) && !defined(__MINGW32__)
             static bool shl_real_type(float val, wchar_t* begin, wchar_t*& end)


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk