mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-04-06 02:45:02 +02:00
snprintf already calculated the length
This commit is contained in:
parent
fe2cd01e80
commit
64d591b720
@ -74,15 +74,18 @@ std::string valueToString(double value) {
|
||||
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) // Use secure version with
|
||||
// visual studio 2005 to
|
||||
// avoid warning.
|
||||
size_t len;
|
||||
#if defined(WINCE)
|
||||
_snprintf(buffer, sizeof(buffer), "%.16g", value);
|
||||
len = _snprintf(buffer, sizeof(buffer), "%.16g", value);
|
||||
#else
|
||||
sprintf_s(buffer, sizeof(buffer), "%.16g", value);
|
||||
len = sprintf_s(buffer, sizeof(buffer), "%.16g", value);
|
||||
#endif
|
||||
fixNumericLocale(buffer, buffer + len);
|
||||
#else
|
||||
if ( isfinite( value ))
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "%.16g", value);
|
||||
{
|
||||
size_t len = snprintf(buffer, sizeof(buffer), "%.16g", value);
|
||||
fixNumericLocale(buffer, buffer + len);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -99,12 +102,8 @@ std::string valueToString(double value) {
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "1e+9999");
|
||||
}
|
||||
// nothing more to do, return.
|
||||
return buffer;
|
||||
}
|
||||
|
||||
#endif
|
||||
fixNumericLocale(buffer, buffer + strlen(buffer));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user