Skip to content

Commit 52b5d92

Browse files
author
Erik Froseth
committed
Bug#30898701 UPGRADE THE RAPIDJSON LIBRARY [2/2, negative zero]
Backport the changes from bug#19504183, so that we do not change how negative zero is handled by rapidjson. Change-Id: I6bf56d2c0750baee4bad35b7173b0cbae0f1aef4
1 parent 1932c00 commit 52b5d92

File tree

6 files changed

+14
-6
lines changed

6 files changed

+14
-6
lines changed

extra/RAPIDJSON-README

+5
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,10 @@ The rapidjson library included in this directory is based on
2626
https://github.com/Tencent/rapidjson/,
2727
commit 418331e99f859f00bdc8306f69eba67e8693c55e
2828

29+
There is one change made to the library:
30+
31+
1) Rapidjson-specific changes in commit 91153f3385c4917a215aa4c7818b3f6265608286
32+
have been applied, so that negative zero is handled properly (bug#19504183).
33+
2934
We only include the contents of the folder "include/" so that we don't include
3035
any code licensed under the JSON License.

extra/rapidjson/include/rapidjson/document.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2470,7 +2470,7 @@ class GenericDocument : public GenericValue<Encoding, Allocator> {
24702470
bool Uint(unsigned i) { new (stack_.template Push<ValueType>()) ValueType(i); return true; }
24712471
bool Int64(int64_t i) { new (stack_.template Push<ValueType>()) ValueType(i); return true; }
24722472
bool Uint64(uint64_t i) { new (stack_.template Push<ValueType>()) ValueType(i); return true; }
2473-
bool Double(double d) { new (stack_.template Push<ValueType>()) ValueType(d); return true; }
2473+
bool Double(double d, bool is_int = false) { new (stack_.template Push<ValueType>()) ValueType(d); return true; }
24742474

24752475
bool RawNumber(const Ch* str, SizeType length, bool copy) {
24762476
if (copy)

extra/rapidjson/include/rapidjson/prettywriter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class PrettyWriter : public Writer<OutputStream, SourceEncoding, TargetEncoding,
9898
bool Uint(unsigned u) { PrettyPrefix(kNumberType); return Base::EndValue(Base::WriteUint(u)); }
9999
bool Int64(int64_t i64) { PrettyPrefix(kNumberType); return Base::EndValue(Base::WriteInt64(i64)); }
100100
bool Uint64(uint64_t u64) { PrettyPrefix(kNumberType); return Base::EndValue(Base::WriteUint64(u64)); }
101-
bool Double(double d) { PrettyPrefix(kNumberType); return Base::EndValue(Base::WriteDouble(d)); }
101+
bool Double(double d, bool is_int = false) { PrettyPrefix(kNumberType); return Base::EndValue(Base::WriteDouble(d)); }
102102

103103
bool RawNumber(const Ch* str, SizeType length, bool copy = false) {
104104
RAPIDJSON_ASSERT(str != 0);

extra/rapidjson/include/rapidjson/reader.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ struct BaseReaderHandler {
206206
bool Uint(unsigned) { return static_cast<Override&>(*this).Default(); }
207207
bool Int64(int64_t) { return static_cast<Override&>(*this).Default(); }
208208
bool Uint64(uint64_t) { return static_cast<Override&>(*this).Default(); }
209-
bool Double(double) { return static_cast<Override&>(*this).Default(); }
209+
bool Double(double, bool is_int = false) { return static_cast<Override&>(*this).Default(); }
210210
/// enabled via kParseNumbersAsStringsFlag, string is not null-terminated (use length)
211211
bool RawNumber(const Ch* str, SizeType len, bool copy) { return static_cast<Override&>(*this).String(str, len, copy); }
212212
bool String(const Ch*, SizeType, bool) { return static_cast<Override&>(*this).Default(); }
@@ -1722,7 +1722,10 @@ class GenericReader {
17221722
}
17231723
else {
17241724
if (minus)
1725-
cont = handler.Int(static_cast<int32_t>(~i + 1));
1725+
if (i == 0)
1726+
cont = handler.Double(-static_cast<double>(i), true);
1727+
else
1728+
cont = handler.Int(static_cast<int32_t>(~i + 1));
17261729
else
17271730
cont = handler.Uint(i);
17281731
}

extra/rapidjson/include/rapidjson/writer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class Writer {
191191
\param d The value to be written.
192192
\return Whether it is succeed.
193193
*/
194-
bool Double(double d) { Prefix(kNumberType); return EndValue(WriteDouble(d)); }
194+
bool Double(double d, bool is_int = false) { Prefix(kNumberType); return EndValue(WriteDouble(d)); }
195195

196196
bool RawNumber(const Ch* str, SizeType length, bool copy = false) {
197197
RAPIDJSON_ASSERT(str != 0);

mysql-test/r/gis.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,7 @@ GeoJSON WKB
16201620
DROP TABLE t1;
16211621
SELECT HEX(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[-0,-0.0]}')) AS g;
16221622
g
1623-
E6100000010100000000000000000000000000000000000080
1623+
E6100000010100000000000000000000800000000000000080
16241624
SELECT HEX(
16251625
ST_GeomFromGeoJSON('{"type":"Point","coordinates":[-0.0,-0.0]}')) AS g;
16261626
g

0 commit comments

Comments
 (0)