snprintf does return a signed integer

assert if returned value is neagtive
This commit is contained in:
mloy 2014-08-19 14:34:00 +02:00 committed by Christopher Dunn
parent 64d591b720
commit 8eb6f88a87

View File

@ -74,17 +74,19 @@ 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;
int len;
#if defined(WINCE)
len = _snprintf(buffer, sizeof(buffer), "%.16g", value);
#else
len = sprintf_s(buffer, sizeof(buffer), "%.16g", value);
#endif
assert(len>=0);
fixNumericLocale(buffer, buffer + len);
#else
if ( isfinite( value ))
{
size_t len = snprintf(buffer, sizeof(buffer), "%.16g", value);
int len = snprintf(buffer, sizeof(buffer), "%.16g", value);
assert(len>=0);
fixNumericLocale(buffer, buffer + len);
}
else