mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-08-10 13:36:29 -04:00
Merge branch 'master' into ecma404mode
This commit is contained in:
commit
3c04b38577
@ -6,7 +6,7 @@
|
||||
# policies that provide successful builds. By setting JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION
|
||||
# to a value greater than the oldest policies, all policies between
|
||||
# JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION and CMAKE_VERSION (used for this build)
|
||||
# are set to their NEW behaivor, thereby suppressing policy warnings related to policies
|
||||
# are set to their NEW behavior, thereby suppressing policy warnings related to policies
|
||||
# between the JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION and CMAKE_VERSION.
|
||||
#
|
||||
# CMake versions greater than the JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION policies will
|
||||
|
@ -77,7 +77,7 @@ See `doxybuild.py --help` for options.
|
||||
To add a test, you need to create two files in test/data:
|
||||
|
||||
* a `TESTNAME.json` file, that contains the input document in JSON format.
|
||||
* a `TESTNAME.expected` file, that contains a flatened representation of the
|
||||
* a `TESTNAME.expected` file, that contains a flattened representation of the
|
||||
input document.
|
||||
|
||||
The `TESTNAME.expected` file format is as follows:
|
||||
|
@ -217,7 +217,7 @@ private:
|
||||
* - otherwise, it the values do not fit on one line, or the array contains
|
||||
* object or non empty array, then print one value per line.
|
||||
*
|
||||
* If the Value have comments then they are outputed according to their
|
||||
* If the Value have comments then they are outputted according to their
|
||||
*#CommentPlacement.
|
||||
*
|
||||
* \sa Reader, Value, Value::setComment()
|
||||
@ -286,7 +286,7 @@ private:
|
||||
* - otherwise, it the values do not fit on one line, or the array contains
|
||||
* object or non empty array, then print one value per line.
|
||||
*
|
||||
* If the Value have comments then they are outputed according to their
|
||||
* If the Value have comments then they are outputted according to their
|
||||
#CommentPlacement.
|
||||
*
|
||||
* \sa Reader, Value, Value::setComment()
|
||||
|
@ -142,7 +142,7 @@ if(BUILD_STATIC_LIBS)
|
||||
set(STATIC_LIB ${PROJECT_NAME}_static)
|
||||
add_library(${STATIC_LIB} STATIC ${PUBLIC_HEADERS} ${JSONCPP_SOURCES})
|
||||
|
||||
# avoid name clashes on windows as the shared import lib is alse named jsoncpp.lib
|
||||
# avoid name clashes on windows as the shared import lib is also named jsoncpp.lib
|
||||
if(NOT DEFINED STATIC_SUFFIX AND BUILD_SHARED_LIBS)
|
||||
if (MSVC)
|
||||
set(STATIC_SUFFIX "_static")
|
||||
|
@ -12,6 +12,7 @@
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <istream>
|
||||
@ -600,9 +601,15 @@ bool Reader::decodeDouble(Token& token, Value& decoded) {
|
||||
double value = 0;
|
||||
String buffer(token.start_, token.end_);
|
||||
IStringStream is(buffer);
|
||||
if (!(is >> value))
|
||||
if (!(is >> value)) {
|
||||
if (value == std::numeric_limits<double>::max())
|
||||
value = std::numeric_limits<double>::infinity();
|
||||
else if (value == std::numeric_limits<double>::lowest())
|
||||
value = -std::numeric_limits<double>::infinity();
|
||||
else if (!std::isinf(value))
|
||||
return addError(
|
||||
"'" + String(token.start_, token.end_) + "' is not a number.", token);
|
||||
}
|
||||
decoded = value;
|
||||
return true;
|
||||
}
|
||||
@ -1607,7 +1614,7 @@ bool OurReader::decodeNumber(Token& token, Value& decoded) {
|
||||
const auto digit(static_cast<Value::UInt>(c - '0'));
|
||||
if (value >= threshold) {
|
||||
// We've hit or exceeded the max value divided by 10 (rounded down). If
|
||||
// a) we've only just touched the limit, meaing value == threshold,
|
||||
// a) we've only just touched the limit, meaning value == threshold,
|
||||
// b) this is the last digit, or
|
||||
// c) it's small enough to fit in that rounding delta, we're okay.
|
||||
// Otherwise treat this number as a double to avoid overflow.
|
||||
@ -1647,6 +1654,11 @@ bool OurReader::decodeDouble(Token& token, Value& decoded) {
|
||||
const String buffer(token.start_, token.end_);
|
||||
IStringStream is(buffer);
|
||||
if (!(is >> value)) {
|
||||
if (value == std::numeric_limits<double>::max())
|
||||
value = std::numeric_limits<double>::infinity();
|
||||
else if (value == std::numeric_limits<double>::lowest())
|
||||
value = -std::numeric_limits<double>::infinity();
|
||||
else if (!std::isinf(value))
|
||||
return addError(
|
||||
"'" + String(token.start_, token.end_) + "' is not a number.", token);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
|
||||
/// Removes the last PredicateContext added to the predicate stack
|
||||
/// chained list.
|
||||
/// Next messages will be targed at the PredicateContext that was removed.
|
||||
/// Next messages will be targeted at the PredicateContext that was removed.
|
||||
TestResult& popPredicateContext();
|
||||
|
||||
bool failed() const;
|
||||
|
3
test/data/legacy_test_real_13.expected
Normal file
3
test/data/legacy_test_real_13.expected
Normal file
@ -0,0 +1,3 @@
|
||||
.=[]
|
||||
.[0]=-inf
|
||||
.[1]=inf
|
1
test/data/legacy_test_real_13.json
Normal file
1
test/data/legacy_test_real_13.json
Normal file
@ -0,0 +1 @@
|
||||
[-1e+9999, 1e+9999]
|
Loading…
x
Reference in New Issue
Block a user