Skip to content

Commit dd329fc

Browse files
committed
. 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
1 parent 7e4df50 commit dd329fc

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

include/json/config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
#define JSON_USE_EXCEPTION 1
2525
#endif
2626

27-
/// If defined, indicates that the source file is amalgated
27+
/// If defined, indicates that the source file is amalgamated
2828
/// to prevent private header inclusion.
29-
/// Remarks: it is automatically defined in the generated amalgated header.
29+
/// Remarks: it is automatically defined in the generated amalgamated header.
3030
// #define JSON_IS_AMALGAMATION
3131

3232
#ifdef JSON_IN_CPPTL

src/lib_json/json_reader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <memory>
1919
#include <set>
2020
#include <limits>
21+
#include <stdio.h>
22+
#include <string.h>
2123

2224
#if defined(_MSC_VER)
2325
#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above

src/lib_json/json_value.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#endif
1919
#include <cstddef> // size_t
2020
#include <algorithm> // min()
21+
#include <string.h>
2122

2223
#define JSON_ASSERT_UNREACHABLE assert(false)
2324

@@ -190,6 +191,7 @@ static inline void releaseStringValue(char* value, unsigned) {
190191

191192
namespace Json {
192193

194+
#if JSON_USE_EXCEPTION
193195
Exception::Exception(JSONCPP_STRING const& msg)
194196
: msg_(msg)
195197
{}
@@ -213,6 +215,7 @@ JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg)
213215
{
214216
throw LogicError(msg);
215217
}
218+
#endif
216219

217220
// //////////////////////////////////////////////////////////////////
218221
// //////////////////////////////////////////////////////////////////

src/lib_json/json_writer.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <cassert>
1616
#include <cstring>
1717
#include <cstdio>
18+
#include <stdio.h>
19+
#include <string.h>
1820

1921
#if defined(_MSC_VER) && _MSC_VER >= 1200 && _MSC_VER < 1800 // Between VC++ 6.0 and VC++ 11.0
2022
#include <float.h>
@@ -42,9 +44,11 @@
4244
#else
4345
#include <cmath>
4446
#if !(defined(__QNXNTO__)) // QNX already defines isfinite
47+
#ifndef isfinite
4548
#define isfinite std::isfinite
4649
#endif
4750
#endif
51+
#endif
4852

4953
#if defined(_MSC_VER)
5054
#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
143147
int len = -1;
144148

145149
char formatString[6];
146-
sprintf(formatString, "%%.%dg", precision);
150+
sprintf(formatString, "%%.%ug", precision);
147151

148152
// Print into the buffer. We need not request the alternative representation
149153
// that always has a decimal point because JSON doesn't distingish the

0 commit comments

Comments
 (0)