Merge fix of VC warning (fixes #7116)

[SVN r79605]
This commit is contained in:
Antony Polukhin
2012-07-19 18:42:34 +00:00
parent 80d480ca0b
commit 46c6cc911b

View File

@@ -1344,25 +1344,30 @@ namespace boost {
return shl_input_streamable(val); 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) static bool shl_real_type(float val, char* begin, char*& end)
{ using namespace std; { using namespace std;
if (put_inf_nan(begin, end, val)) return true; if (put_inf_nan(begin, end, val)) return true;
end = begin;
const double val_as_double = val; 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; return end > begin;
} }
static bool shl_real_type(double val, char* begin, char*& end) static bool shl_real_type(double val, char* begin, char*& end)
{ using namespace std; { using namespace std;
if (put_inf_nan(begin, end, val)) return true; if (put_inf_nan(begin, end, val)) return true;
end = begin; end = begin +
end += sprintf(begin,"%.*g", static_cast<int>(boost::detail::lcast_get_precision<double>()), val); #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; return end > begin;
} }
@@ -1370,16 +1375,17 @@ namespace boost {
static bool shl_real_type(long double val, char* begin, char*& end) static bool shl_real_type(long double val, char* begin, char*& end)
{ using namespace std; { using namespace std;
if (put_inf_nan(begin, end, val)) return true; if (put_inf_nan(begin, end, val)) return true;
end = begin; end = begin +
end += sprintf(begin,"%.*Lg", static_cast<int>(boost::detail::lcast_get_precision<long double>()), val ); #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; return end > begin;
} }
#endif #endif
#if (defined _MSC_VER)
# pragma warning( pop )
#endif
#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_SWPRINTF) && !defined(__MINGW32__) #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) static bool shl_real_type(float val, wchar_t* begin, wchar_t*& end)