mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-14 15:05:34 +02:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a304d61a7b | ||
![]() |
0a97e38ea5 | ||
![]() |
894e78bff1 | ||
![]() |
126bdc2b05 | ||
![]() |
094a7d8564 | ||
![]() |
b9afdf190d | ||
![]() |
80a82ea269 | ||
![]() |
f78f685bab | ||
![]() |
7d8eddb98c | ||
![]() |
7e0571b444 | ||
![]() |
b14c8c1423 | ||
![]() |
b299d3581f | ||
![]() |
48d2a69d47 | ||
![]() |
772e257fc9 | ||
![]() |
101fcf0806 |
@@ -64,7 +64,7 @@ ENDMACRO()
|
||||
#SET( JSONCPP_VERSION_MAJOR X )
|
||||
#SET( JSONCPP_VERSION_MINOR Y )
|
||||
#SET( JSONCPP_VERSION_PATCH Z )
|
||||
SET( JSONCPP_VERSION 1.7.3 )
|
||||
SET( JSONCPP_VERSION 1.7.5 )
|
||||
jsoncpp_parse_version( ${JSONCPP_VERSION} JSONCPP_VERSION )
|
||||
#IF(NOT JSONCPP_VERSION_FOUND)
|
||||
# MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z")
|
||||
|
@@ -152,8 +152,8 @@ typedef unsigned int LargestUInt;
|
||||
typedef __int64 Int64;
|
||||
typedef unsigned __int64 UInt64;
|
||||
#else // if defined(_MSC_VER) // Other platforms, use long long
|
||||
typedef long long int Int64;
|
||||
typedef unsigned long long int UInt64;
|
||||
typedef int64_t Int64;
|
||||
typedef uint64_t UInt64;
|
||||
#endif // if defined(_MSC_VER)
|
||||
typedef Int64 LargestInt;
|
||||
typedef UInt64 LargestUInt;
|
||||
|
@@ -3,10 +3,10 @@
|
||||
#ifndef JSON_VERSION_H_INCLUDED
|
||||
# define JSON_VERSION_H_INCLUDED
|
||||
|
||||
# define JSONCPP_VERSION_STRING "1.7.3"
|
||||
# define JSONCPP_VERSION_STRING "1.7.5"
|
||||
# define JSONCPP_VERSION_MAJOR 1
|
||||
# define JSONCPP_VERSION_MINOR 7
|
||||
# define JSONCPP_VERSION_PATCH 3
|
||||
# define JSONCPP_VERSION_PATCH 5
|
||||
# define JSONCPP_VERSION_QUALIFIER
|
||||
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=${prefix}
|
||||
libdir=@LIBRARY_INSTALL_DIR@
|
||||
includedir=@INCLUDE_INSTALL_DIR@
|
||||
libdir=${exec_prefix}/@LIBRARY_INSTALL_DIR@
|
||||
includedir=${prefix}/@INCLUDE_INSTALL_DIR@
|
||||
|
||||
Name: jsoncpp
|
||||
Description: A C++ library for interacting with JSON
|
||||
|
@@ -1068,7 +1068,7 @@ bool OurReader::parse(const char* beginDoc,
|
||||
Token token;
|
||||
skipCommentTokens(token);
|
||||
if (features_.failIfExtra_) {
|
||||
if (token.type_ != tokenError && token.type_ != tokenEndOfStream) {
|
||||
if ((features_.strictRoot_ || token.type_ != tokenError) && token.type_ != tokenEndOfStream) {
|
||||
addError("Extra non-whitespace after JSON value.", token);
|
||||
return false;
|
||||
}
|
||||
@@ -1619,6 +1619,7 @@ bool OurReader::decodeDouble(Token& token, Value& decoded) {
|
||||
Char buffer[bufferSize + 1];
|
||||
memcpy(buffer, token.start_, ulength);
|
||||
buffer[length] = 0;
|
||||
fixNumericLocaleInput(buffer, buffer + length);
|
||||
count = sscanf(buffer, format, &value);
|
||||
} else {
|
||||
JSONCPP_STRING buffer(token.start_, token.end_);
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||
#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||
#include <clocale>
|
||||
|
||||
/* This header provides common string manipulation support, such as UTF-8,
|
||||
* portable conversion from/to string...
|
||||
@@ -14,6 +15,26 @@
|
||||
|
||||
namespace Json {
|
||||
|
||||
/// Fallback for decimal_point on android, where the lconv is an empty struct.
|
||||
template<typename Lconv, bool=(sizeof(Lconv) >= sizeof(char*))>
|
||||
struct Locale {
|
||||
static char decimalPoint() {
|
||||
return '\0';
|
||||
}
|
||||
};
|
||||
|
||||
/// Return decimal_point for the current locale.
|
||||
template<typename Lconv>
|
||||
struct Locale<Lconv, true> {
|
||||
static char decimalPoint() {
|
||||
Lconv* lc = localeconv();
|
||||
if (lc == NULL) {
|
||||
return '\0';
|
||||
}
|
||||
return *(lc->decimal_point);
|
||||
}
|
||||
};
|
||||
|
||||
/// Converts a unicode code-point to UTF-8.
|
||||
static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
|
||||
JSONCPP_STRING result;
|
||||
@@ -82,6 +103,18 @@ static inline void fixNumericLocale(char* begin, char* end) {
|
||||
}
|
||||
}
|
||||
|
||||
static inline void fixNumericLocaleInput(char* begin, char* end) {
|
||||
char decimalPoint = Locale<struct lconv>::decimalPoint();
|
||||
if (decimalPoint != '\0' && decimalPoint != '.') {
|
||||
while (begin < end) {
|
||||
if (*begin == '.') {
|
||||
*begin = decimalPoint;
|
||||
}
|
||||
++begin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Json {
|
||||
|
||||
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||
|
@@ -39,8 +39,8 @@ namespace Json {
|
||||
// static
|
||||
Value const& Value::nullSingleton()
|
||||
{
|
||||
static Value const* nullStatic = new Value;
|
||||
return *nullStatic;
|
||||
static Value const nullStatic;
|
||||
return nullStatic;
|
||||
}
|
||||
|
||||
// for backwards compatibility, we'll leave these global references around, but DO NOT
|
||||
@@ -343,6 +343,7 @@ bool Value::CZString::isStaticString() const { return storage_.policy_ == noDupl
|
||||
* This optimization is used in ValueInternalMap fast allocator.
|
||||
*/
|
||||
Value::Value(ValueType vtype) {
|
||||
static char const empty[] = "";
|
||||
initBasic(vtype);
|
||||
switch (vtype) {
|
||||
case nullValue:
|
||||
@@ -355,7 +356,8 @@ Value::Value(ValueType vtype) {
|
||||
value_.real_ = 0.0;
|
||||
break;
|
||||
case stringValue:
|
||||
value_.string_ = 0;
|
||||
// allocated_ == false, so this is safe.
|
||||
value_.string_ = const_cast<char*>(static_cast<char const*>(empty));
|
||||
break;
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
@@ -500,8 +502,7 @@ Value::~Value() {
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
|
||||
if (comments_)
|
||||
delete[] comments_;
|
||||
delete[] comments_;
|
||||
|
||||
value_.uint_ = 0;
|
||||
}
|
||||
|
@@ -353,7 +353,7 @@ void FastWriter::writeValue(const Value& value) {
|
||||
break;
|
||||
case stringValue:
|
||||
{
|
||||
// Is NULL possible for value.string_?
|
||||
// Is NULL possible for value.string_? No.
|
||||
char const* str;
|
||||
char const* end;
|
||||
bool ok = value.getString(&str, &end);
|
||||
@@ -423,7 +423,7 @@ void StyledWriter::writeValue(const Value& value) {
|
||||
break;
|
||||
case stringValue:
|
||||
{
|
||||
// Is NULL possible for value.string_?
|
||||
// Is NULL possible for value.string_? No.
|
||||
char const* str;
|
||||
char const* end;
|
||||
bool ok = value.getString(&str, &end);
|
||||
@@ -640,7 +640,7 @@ void StyledStreamWriter::writeValue(const Value& value) {
|
||||
break;
|
||||
case stringValue:
|
||||
{
|
||||
// Is NULL possible for value.string_?
|
||||
// Is NULL possible for value.string_? No.
|
||||
char const* str;
|
||||
char const* end;
|
||||
bool ok = value.getString(&str, &end);
|
||||
@@ -921,7 +921,7 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
|
||||
break;
|
||||
case stringValue:
|
||||
{
|
||||
// Is NULL is possible for value.string_?
|
||||
// Is NULL is possible for value.string_? No.
|
||||
char const* str;
|
||||
char const* end;
|
||||
bool ok = value.getString(&str, &end);
|
||||
@@ -1002,7 +1002,7 @@ void BuiltStyledStreamWriter::writeArrayValue(Value const& value) {
|
||||
if (!indentation_.empty()) *sout_ << " ";
|
||||
for (unsigned index = 0; index < size; ++index) {
|
||||
if (index > 0)
|
||||
*sout_ << ", ";
|
||||
*sout_ << ((!indentation_.empty()) ? ", " : ",");
|
||||
*sout_ << childValues_[index];
|
||||
}
|
||||
if (!indentation_.empty()) *sout_ << " ";
|
||||
|
Reference in New Issue
Block a user