From dd329fc74960b86557cace4f12e8e7219ea0f79c Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 28 Jun 2016 09:35:03 -0500 Subject: [PATCH] . fix a bunch of missing string and stdio headers . typo amalgated -> amalgamated . add #if JSON_USE_EXCEPTION guard around exception-throwing code . change format string "%%.%dg" to "%%.%ug" for an unsigned int --- include/json/config.h | 4 ++-- src/lib_json/json_reader.cpp | 2 ++ src/lib_json/json_value.cpp | 3 +++ src/lib_json/json_writer.cpp | 6 +++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/json/config.h b/include/json/config.h index 085bdc00a..984b7a25e 100644 --- a/include/json/config.h +++ b/include/json/config.h @@ -24,9 +24,9 @@ #define JSON_USE_EXCEPTION 1 #endif -/// If defined, indicates that the source file is amalgated +/// If defined, indicates that the source file is amalgamated /// to prevent private header inclusion. -/// Remarks: it is automatically defined in the generated amalgated header. +/// Remarks: it is automatically defined in the generated amalgamated header. // #define JSON_IS_AMALGAMATION #ifdef JSON_IN_CPPTL diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index 4930c1739..ccfc0d53d 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -18,6 +18,8 @@ #include #include #include +#include +#include #if defined(_MSC_VER) #if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index 1d8688380..2c0628c75 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -18,6 +18,7 @@ #endif #include // size_t #include // min() +#include #define JSON_ASSERT_UNREACHABLE assert(false) @@ -190,6 +191,7 @@ static inline void releaseStringValue(char* value, unsigned) { namespace Json { +#if JSON_USE_EXCEPTION Exception::Exception(JSONCPP_STRING const& msg) : msg_(msg) {} @@ -213,6 +215,7 @@ JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg) { throw LogicError(msg); } +#endif // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp index 35f0b1f08..7ce352940 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -15,6 +15,8 @@ #include #include #include +#include +#include #if defined(_MSC_VER) && _MSC_VER >= 1200 && _MSC_VER < 1800 // Between VC++ 6.0 and VC++ 11.0 #include @@ -42,9 +44,11 @@ #else #include #if !(defined(__QNXNTO__)) // QNX already defines isfinite +#ifndef isfinite #define isfinite std::isfinite #endif #endif +#endif #if defined(_MSC_VER) #if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above @@ -143,7 +147,7 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int p int len = -1; char formatString[6]; - sprintf(formatString, "%%.%dg", precision); + sprintf(formatString, "%%.%ug", precision); // Print into the buffer. We need not request the alternative representation // that always has a decimal point because JSON doesn't distingish the