Skip to content

Commit be8da92

Browse files
authored
Merge branch 'open-source-parsers:master' into master
2 parents ebfe2ea + 42e892d commit be8da92

18 files changed

+57
-32
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build matrix / environment variables are explained on:
2-
# http://about.travis-ci.org/docs/user/build-configuration/
2+
# http://about.travis-ci.com/docs/user/build-configuration/
33
# This file can be validated on: http://www.yamllint.com/
44
# Or using the Ruby based travel command line tool:
55
# gem install travis --no-rdoc --no-ri

.travis_scripts/meson_builder.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ninja --version
6464
_COMPILER_NAME=`basename ${CXX}`
6565
_BUILD_DIR_NAME="build-${BUILD_TYPE}_${LIB_TYPE}_${_COMPILER_NAME}"
6666

67-
./.travis_scripts/run-clang-format.sh
67+
#./.travis_scripts/run-clang-format.sh
6868
meson --fatal-meson-warnings --werror --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . "${_BUILD_DIR_NAME}"
6969
ninja -v -j 2 -C "${_BUILD_DIR_NAME}"
7070

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# policies that provide successful builds. By setting JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION
77
# to a value greater than the oldest policies, all policies between
88
# JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION and CMAKE_VERSION (used for this build)
9-
# are set to their NEW behaivor, thereby suppressing policy warnings related to policies
9+
# are set to their NEW behavior, thereby suppressing policy warnings related to policies
1010
# between the JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION and CMAKE_VERSION.
1111
#
1212
# CMake versions greater than the JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION policies will
@@ -72,11 +72,11 @@ project(jsoncpp
7272
# 2. ./include/json/version.h
7373
# 3. ./CMakeLists.txt
7474
# IMPORTANT: also update the PROJECT_SOVERSION!!
75-
VERSION 1.9.4 # <major>[.<minor>[.<patch>[.<tweak>]]]
75+
VERSION 1.9.5 # <major>[.<minor>[.<patch>[.<tweak>]]]
7676
LANGUAGES CXX)
7777

7878
message(STATUS "JsonCpp Version: ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
79-
set(PROJECT_SOVERSION 24)
79+
set(PROJECT_SOVERSION 25)
8080

8181
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInSourceBuilds.cmake)
8282
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInBuildInstalls.cmake)

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ See `doxybuild.py --help` for options.
7777
To add a test, you need to create two files in test/data:
7878

7979
* a `TESTNAME.json` file, that contains the input document in JSON format.
80-
* a `TESTNAME.expected` file, that contains a flatened representation of the
80+
* a `TESTNAME.expected` file, that contains a flattened representation of the
8181
input document.
8282

8383
The `TESTNAME.expected` file format is as follows:

example/readFromString/readFromString.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "json/json.h"
22
#include <iostream>
3+
#include <memory>
34
/**
45
* \brief Parse a raw string into Value object using the CharReaderBuilder
56
* class, or the legacy Reader class.

example/streamWrite/streamWrite.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "json/json.h"
22
#include <iostream>
3+
#include <memory>
34
/** \brief Write the Value object to a stream.
45
* Example Usage:
56
* $g++ streamWrite.cpp -ljsoncpp -std=c++11 -o streamWrite

include/json/allocator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
#include <cstring>
1010
#include <memory>
1111

12-
#pragma pack(push, 8)
12+
#pragma pack(push)
13+
#pragma pack()
1314

1415
namespace Json {
1516
template <typename T> class SecureAllocator {

include/json/json_features.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
#include "forwards.h"
1111
#endif // if !defined(JSON_IS_AMALGAMATION)
1212

13-
#pragma pack(push, 8)
13+
#pragma pack(push)
14+
#pragma pack()
1415

1516
namespace Json {
1617

include/json/reader.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
#pragma warning(disable : 4251)
2424
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
2525

26-
#pragma pack(push, 8)
26+
#pragma pack(push)
27+
#pragma pack()
2728

2829
namespace Json {
2930

@@ -33,8 +34,7 @@ namespace Json {
3334
* \deprecated Use CharReader and CharReaderBuilder.
3435
*/
3536

36-
class JSONCPP_DEPRECATED(
37-
"Use CharReader and CharReaderBuilder instead.") JSON_API Reader {
37+
class JSON_API Reader {
3838
public:
3939
using Char = char;
4040
using Location = const Char*;
@@ -51,13 +51,13 @@ class JSONCPP_DEPRECATED(
5151
};
5252

5353
/** \brief Constructs a Reader allowing all features for parsing.
54+
* \deprecated Use CharReader and CharReaderBuilder.
5455
*/
55-
JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
5656
Reader();
5757

5858
/** \brief Constructs a Reader allowing the specified feature set for parsing.
59+
* \deprecated Use CharReader and CharReaderBuilder.
5960
*/
60-
JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
6161
Reader(const Features& features);
6262

6363
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
@@ -324,6 +324,9 @@ class JSON_API CharReaderBuilder : public CharReader::Factory {
324324
* - `"allowSpecialFloats": false or true`
325325
* - If true, special float values (NaNs and infinities) are allowed and
326326
* their values are lossfree restorable.
327+
* - `"skipBom": false or true`
328+
* - If true, if the input starts with the Unicode byte order mark (BOM),
329+
* it is skipped.
327330
*
328331
* You can examine 'settings_` yourself to see the defaults. You can also
329332
* write and read them just like any JSON Value.

include/json/value.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
#pragma warning(disable : 4251 4275)
5454
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
5555

56-
#pragma pack(push, 8)
56+
#pragma pack(push)
57+
#pragma pack()
5758

5859
/** \brief JSON (JavaScript Object Notation).
5960
*/

include/json/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
// 3. /CMakeLists.txt
1010
// IMPORTANT: also update the SOVERSION!!
1111

12-
#define JSONCPP_VERSION_STRING "1.9.4"
12+
#define JSONCPP_VERSION_STRING "1.9.5"
1313
#define JSONCPP_VERSION_MAJOR 1
1414
#define JSONCPP_VERSION_MINOR 9
15-
#define JSONCPP_VERSION_PATCH 4
15+
#define JSONCPP_VERSION_PATCH 5
1616
#define JSONCPP_VERSION_QUALIFIER
1717
#define JSONCPP_VERSION_HEXA \
1818
((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \

include/json/writer.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
#pragma warning(disable : 4251)
2121
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
2222

23-
#pragma pack(push, 8)
23+
#pragma pack(push)
24+
#pragma pack()
2425

2526
namespace Json {
2627

@@ -147,7 +148,7 @@ class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
147148
/** \brief Abstract class for writers.
148149
* \deprecated Use StreamWriter. (And really, this is an implementation detail.)
149150
*/
150-
class JSONCPP_DEPRECATED("Use StreamWriter instead") JSON_API Writer {
151+
class JSON_API Writer {
151152
public:
152153
virtual ~Writer();
153154

@@ -167,7 +168,7 @@ class JSONCPP_DEPRECATED("Use StreamWriter instead") JSON_API Writer {
167168
#pragma warning(push)
168169
#pragma warning(disable : 4996) // Deriving from deprecated class
169170
#endif
170-
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter
171+
class JSON_API FastWriter
171172
: public Writer {
172173
public:
173174
FastWriter();
@@ -217,7 +218,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter
217218
* - otherwise, it the values do not fit on one line, or the array contains
218219
* object or non empty array, then print one value per line.
219220
*
220-
* If the Value have comments then they are outputed according to their
221+
* If the Value have comments then they are outputted according to their
221222
*#CommentPlacement.
222223
*
223224
* \sa Reader, Value, Value::setComment()
@@ -227,7 +228,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter
227228
#pragma warning(push)
228229
#pragma warning(disable : 4996) // Deriving from deprecated class
229230
#endif
230-
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
231+
class JSON_API
231232
StyledWriter : public Writer {
232233
public:
233234
StyledWriter();
@@ -286,7 +287,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
286287
* - otherwise, it the values do not fit on one line, or the array contains
287288
* object or non empty array, then print one value per line.
288289
*
289-
* If the Value have comments then they are outputed according to their
290+
* If the Value have comments then they are outputted according to their
290291
#CommentPlacement.
291292
*
292293
* \sa Reader, Value, Value::setComment()
@@ -296,7 +297,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
296297
#pragma warning(push)
297298
#pragma warning(disable : 4996) // Deriving from deprecated class
298299
#endif
299-
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
300+
class JSON_API
300301
StyledStreamWriter {
301302
public:
302303
/**

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jsoncpp_lib = library(
5050
'src/lib_json/json_value.cpp',
5151
'src/lib_json/json_writer.cpp',
5252
]),
53-
soversion : 24,
53+
soversion : 25,
5454
install : true,
5555
include_directories : jsoncpp_include_directories,
5656
cpp_args: dll_export_flag)

src/lib_json/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ if(BUILD_SHARED_LIBS)
119119
OUTPUT_NAME jsoncpp
120120
VERSION ${PROJECT_VERSION}
121121
SOVERSION ${PROJECT_SOVERSION}
122-
POSITION_INDEPENDENT_CODE ON
122+
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
123123
)
124124

125125
# Set library's runtime search path on OSX
@@ -142,7 +142,7 @@ if(BUILD_STATIC_LIBS)
142142
set(STATIC_LIB ${PROJECT_NAME}_static)
143143
add_library(${STATIC_LIB} STATIC ${PUBLIC_HEADERS} ${JSONCPP_SOURCES})
144144

145-
# avoid name clashes on windows as the shared import lib is alse named jsoncpp.lib
145+
# avoid name clashes on windows as the shared import lib is also named jsoncpp.lib
146146
if(NOT DEFINED STATIC_SUFFIX AND BUILD_SHARED_LIBS)
147147
if (MSVC)
148148
set(STATIC_SUFFIX "_static")
@@ -180,7 +180,7 @@ if(BUILD_OBJECT_LIBS)
180180
OUTPUT_NAME jsoncpp
181181
VERSION ${PROJECT_VERSION}
182182
SOVERSION ${PROJECT_SOVERSION}
183-
POSITION_INDEPENDENT_CODE ON
183+
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
184184
)
185185

186186
# Set library's runtime search path on OSX

src/lib_json/json_reader.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#endif // if !defined(JSON_IS_AMALGAMATION)
1313
#include <algorithm>
1414
#include <cassert>
15+
#include <cmath>
1516
#include <cstring>
1617
#include <iostream>
1718
#include <istream>
@@ -600,9 +601,15 @@ bool Reader::decodeDouble(Token& token, Value& decoded) {
600601
double value = 0;
601602
String buffer(token.start_, token.end_);
602603
IStringStream is(buffer);
603-
if (!(is >> value))
604-
return addError(
604+
if (!(is >> value)) {
605+
if (value == std::numeric_limits<double>::max())
606+
value = std::numeric_limits<double>::infinity();
607+
else if (value == std::numeric_limits<double>::lowest())
608+
value = -std::numeric_limits<double>::infinity();
609+
else if (!std::isinf(value))
610+
return addError(
605611
"'" + String(token.start_, token.end_) + "' is not a number.", token);
612+
}
606613
decoded = value;
607614
return true;
608615
}
@@ -1607,7 +1614,7 @@ bool OurReader::decodeNumber(Token& token, Value& decoded) {
16071614
const auto digit(static_cast<Value::UInt>(c - '0'));
16081615
if (value >= threshold) {
16091616
// We've hit or exceeded the max value divided by 10 (rounded down). If
1610-
// a) we've only just touched the limit, meaing value == threshold,
1617+
// a) we've only just touched the limit, meaning value == threshold,
16111618
// b) this is the last digit, or
16121619
// c) it's small enough to fit in that rounding delta, we're okay.
16131620
// Otherwise treat this number as a double to avoid overflow.
@@ -1647,7 +1654,12 @@ bool OurReader::decodeDouble(Token& token, Value& decoded) {
16471654
const String buffer(token.start_, token.end_);
16481655
IStringStream is(buffer);
16491656
if (!(is >> value)) {
1650-
return addError(
1657+
if (value == std::numeric_limits<double>::max())
1658+
value = std::numeric_limits<double>::infinity();
1659+
else if (value == std::numeric_limits<double>::lowest())
1660+
value = -std::numeric_limits<double>::infinity();
1661+
else if (!std::isinf(value))
1662+
return addError(
16511663
"'" + String(token.start_, token.end_) + "' is not a number.", token);
16521664
}
16531665
decoded = value;

src/test_lib_json/jsontest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class TestResult {
7474

7575
/// Removes the last PredicateContext added to the predicate stack
7676
/// chained list.
77-
/// Next messages will be targed at the PredicateContext that was removed.
77+
/// Next messages will be targeted at the PredicateContext that was removed.
7878
TestResult& popPredicateContext();
7979

8080
bool failed() const;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.=[]
2+
.[0]=-inf
3+
.[1]=inf

test/data/legacy_test_real_13.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[-1e+9999, 1e+9999]

0 commit comments

Comments
 (0)