Imported Upstream version 1.7.5 upstream/1.7.5
authorDongHun Kwak <dh0128.kwak@samsung.com>
Wed, 26 Oct 2016 07:47:20 +0000 (16:47 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Wed, 26 Oct 2016 07:47:20 +0000 (16:47 +0900)
Change-Id: Ib8551ed0cbd7f59efe9035d03f024a133f276cd2
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
CMakeLists.txt
include/json/config.h
include/json/version.h
src/lib_json/json_reader.cpp
src/lib_json/json_tool.h
src/lib_json/json_value.cpp
src/lib_json/json_writer.cpp
version

index d6554c9..1bb891e 100644 (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")
index 085bdc0..6519101 100644 (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;
index 3c05013..74380bb 100644 (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))
 
index 4930c17..b354be3 100644 (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_);
index d16d7b8..4a829b0 100644 (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...
 
 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
index 1d86883..7b6c89a 100644 (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;
 }
index 35f0b1f..1bb3b21 100644 (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_ << " ";
diff --git a/version b/version
index 10c0880..6a126f4 100644 (file)
--- a/version
+++ b/version
@@ -1 +1 @@
-1.7.4
+1.7.5