mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-06-08 17:30:13 +02:00
Fixed some snprintf-related build breakages in Visual Studio.
This commit is contained in:
parent
36400ac0c1
commit
d2618806ba
@ -19,7 +19,11 @@ static std::string
|
|||||||
normalizeFloatingPointStr( double value )
|
normalizeFloatingPointStr( double value )
|
||||||
{
|
{
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
|
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__)
|
||||||
|
sprintf_s( buffer, sizeof(buffer), "%.16g", value );
|
||||||
|
#else
|
||||||
snprintf( buffer, sizeof(buffer), "%.16g", value );
|
snprintf( buffer, sizeof(buffer), "%.16g", value );
|
||||||
|
#endif
|
||||||
buffer[sizeof(buffer)-1] = 0;
|
buffer[sizeof(buffer)-1] = 0;
|
||||||
std::string s( buffer );
|
std::string s( buffer );
|
||||||
std::string::size_type index = s.find_last_of( "eE" );
|
std::string::size_type index = s.find_last_of( "eE" );
|
||||||
@ -89,7 +93,11 @@ printValueTree( FILE *fout, Json::Value &value, const std::string &path = "." )
|
|||||||
for ( int index =0; index < size; ++index )
|
for ( int index =0; index < size; ++index )
|
||||||
{
|
{
|
||||||
static char buffer[16];
|
static char buffer[16];
|
||||||
|
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__)
|
||||||
|
sprintf_s( buffer, sizeof(buffer), "[%d]", index );
|
||||||
|
#else
|
||||||
snprintf( buffer, sizeof(buffer), "[%d]", index );
|
snprintf( buffer, sizeof(buffer), "[%d]", index );
|
||||||
|
#endif
|
||||||
printValueTree( fout, value[index], path + buffer );
|
printValueTree( fout, value[index], path + buffer );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -868,7 +868,11 @@ Reader::getLocationLineAndColumn( Location location ) const
|
|||||||
int line, column;
|
int line, column;
|
||||||
getLocationLineAndColumn( location, line, column );
|
getLocationLineAndColumn( location, line, column );
|
||||||
char buffer[18+16+16+1];
|
char buffer[18+16+16+1];
|
||||||
|
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__)
|
||||||
|
sprintf_s(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
|
||||||
|
#else
|
||||||
snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
|
snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
|
||||||
|
#endif
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user