Compare commits

..

12 Commits
1.7.4 ... 1.7.5

Author SHA1 Message Date
Christopher Dunn
a304d61a7b 1.7.5 <- 1.7.4 2016-09-01 02:45:08 -05:00
Christopher Dunn
0a97e38ea5 Merge pull request #523 from prezi/fix-android-lconv
Workaround for missing lconv::decimal_point on android
2016-09-01 02:36:34 -05:00
Gida Pataki
894e78bff1 Workaround for missing lconv::decimal_point on android 2016-08-26 23:30:18 +02:00
Christopher Dunn
126bdc2b05 Reject extra chars if strictRoot
resolves #511
2016-08-21 20:32:16 -05:00
Christopher Dunn
094a7d8564 Fix locale for decimal points
resolves #514
2016-08-21 20:13:58 -05:00
Christopher Dunn
b9afdf190d Use int64_t for 64bit ints
resolves #509
2016-08-21 19:58:43 -05:00
Christopher Dunn
80a82ea269 Optional space after comma
resolves #513
2016-08-21 16:35:19 -05:00
Christopher Dunn
f78f685bab Remove needless if.
resolves #516
2016-08-21 16:31:14 -05:00
Christopher Dunn
7d8eddb98c Merge pull request #519 from open-source-parsers/fix-517
Avoid null for stringValue
2016-08-21 16:30:28 -05:00
Christopher Dunn
7e0571b444 Avoid null for stringValue
fixes #517
2016-08-21 16:25:29 -05:00
Christopher Dunn
b14c8c1423 Merge pull request #502 from open-source-parsers/null-object
Allow dtor for nullSingleton
2016-07-20 22:28:44 -07:00
Christopher Dunn
b299d3581f Allow dtor for nullSingleton
re #488 and #490
2016-07-20 11:31:41 -07:00
8 changed files with 52 additions and 17 deletions

View File

@@ -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.4 )
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")

View File

@@ -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;

View File

@@ -3,10 +3,10 @@
#ifndef JSON_VERSION_H_INCLUDED
# define JSON_VERSION_H_INCLUDED
# define JSONCPP_VERSION_STRING "1.7.4"
# define JSONCPP_VERSION_STRING "1.7.5"
# define JSONCPP_VERSION_MAJOR 1
# define JSONCPP_VERSION_MINOR 7
# define JSONCPP_VERSION_PATCH 4
# 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))

View File

@@ -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_);

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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_ << " ";

View File

@@ -1 +1 @@
1.7.4
1.7.5