Skip to content

Commit 4dea76d

Browse files
authored
Merge branch 'master' into master
2 parents cf8a11e + 871f0cc commit 4dea76d

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ project(jsoncpp
6262
# 2. ./include/json/version.h
6363
# 3. ./CMakeLists.txt
6464
# IMPORTANT: also update the PROJECT_SOVERSION!!
65-
VERSION 1.9.6 # <major>[.<minor>[.<patch>[.<tweak>]]]
65+
VERSION 1.9.7 # <major>[.<minor>[.<patch>[.<tweak>]]]
6666
LANGUAGES CXX)
6767

6868
message(STATUS "JsonCpp Version: ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
69-
set(PROJECT_SOVERSION 26)
69+
set(PROJECT_SOVERSION 27)
7070

7171
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInSourceBuilds.cmake)
7272
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInBuildInstalls.cmake)

include/json/version.h

+2-2
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.6"
12+
#define JSONCPP_VERSION_STRING "1.9.7"
1313
#define JSONCPP_VERSION_MAJOR 1
1414
#define JSONCPP_VERSION_MINOR 9
15-
#define JSONCPP_VERSION_PATCH 6
15+
#define JSONCPP_VERSION_PATCH 7
1616
#define JSONCPP_VERSION_QUALIFIER
1717
#define JSONCPP_VERSION_HEXA \
1818
((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \

meson.build

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ project(
99
# 2. /include/json/version.h
1010
# 3. /CMakeLists.txt
1111
# IMPORTANT: also update the SOVERSION!!
12-
version : '1.9.6',
12+
version : '1.9.7',
1313
default_options : [
1414
'buildtype=release',
1515
'cpp_std=c++11',
@@ -50,7 +50,7 @@ jsoncpp_lib = library(
5050
'src/lib_json/json_value.cpp',
5151
'src/lib_json/json_writer.cpp',
5252
]),
53-
soversion : 26,
53+
soversion : 27,
5454
install : true,
5555
include_directories : jsoncpp_include_directories,
5656
cpp_args: dll_export_flag)

src/lib_json/json_value.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ template <typename T, typename U>
8787
static inline bool InRange(double d, T min, U max) {
8888
// The casts can lose precision, but we are looking only for
8989
// an approximate range. Might fail on edge cases though. ~cdunn
90-
return d >= static_cast<double>(min) && d <= static_cast<double>(max);
90+
return d >= static_cast<double>(min) && d <= static_cast<double>(max) &&
91+
!(static_cast<U>(d) == min && d != static_cast<double>(min));
9192
}
9293
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
9394
static inline double integerToDouble(Json::UInt64 value) {
@@ -101,7 +102,8 @@ template <typename T> static inline double integerToDouble(T value) {
101102

102103
template <typename T, typename U>
103104
static inline bool InRange(double d, T min, U max) {
104-
return d >= integerToDouble(min) && d <= integerToDouble(max);
105+
return d >= integerToDouble(min) && d <= integerToDouble(max) &&
106+
!(static_cast<U>(d) == min && d != integerToDouble(min));
105107
}
106108
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
107109

@@ -705,6 +707,11 @@ Value::Int64 Value::asInt64() const {
705707
JSON_ASSERT_MESSAGE(isInt64(), "LargestUInt out of Int64 range");
706708
return Int64(value_.uint_);
707709
case realValue:
710+
// If the double value is in proximity to minInt64, it will be rounded to
711+
// minInt64. The correct value in this scenario is indeterminable
712+
JSON_ASSERT_MESSAGE(
713+
value_.real_ != minInt64,
714+
"Double value is minInt64, precise value cannot be determined");
708715
JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt64, maxInt64),
709716
"double out of Int64 range");
710717
return Int64(value_.real_);

src/test_lib_json/main.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -1191,15 +1191,13 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, integers) {
11911191
JSONTEST_ASSERT_EQUAL(true, val.asBool());
11921192
JSONTEST_ASSERT_STRING_EQUAL("-9223372036854775808", val.asString());
11931193

1194-
// int64 min (floating point constructor). Note that kint64min *is* exactly
1195-
// representable as a double.
1194+
// int64 min (floating point constructor). Since double values in proximity of
1195+
// kint64min are rounded to kint64min, we don't check for conversion to int64.
11961196
val = Json::Value(double(kint64min));
11971197

11981198
JSONTEST_ASSERT_EQUAL(Json::realValue, val.type());
11991199

12001200
checks = IsCheck();
1201-
checks.isInt64_ = true;
1202-
checks.isIntegral_ = true;
12031201
checks.isDouble_ = true;
12041202
checks.isNumeric_ = true;
12051203
JSONTEST_ASSERT_PRED(checkIs(val, checks));
@@ -1208,8 +1206,6 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, integers) {
12081206
JSONTEST_ASSERT(!val.isConvertibleTo(Json::intValue));
12091207
JSONTEST_ASSERT(!val.isConvertibleTo(Json::uintValue));
12101208

1211-
JSONTEST_ASSERT_EQUAL(kint64min, val.asInt64());
1212-
JSONTEST_ASSERT_EQUAL(kint64min, val.asLargestInt());
12131209
JSONTEST_ASSERT_EQUAL(-9223372036854775808.0, val.asDouble());
12141210
JSONTEST_ASSERT_EQUAL(-9223372036854775808.0, val.asFloat());
12151211
JSONTEST_ASSERT_EQUAL(true, val.asBool());

0 commit comments

Comments
 (0)