This is an automated email from the ASF dual-hosted git repository. qianzhang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 0b47b43d290494fc1c6a6f6241ddfbceeb686997 Author: Qian Zhang <[email protected]> AuthorDate: Sun Feb 23 09:53:32 2020 +0800 Added patch for RapidJSON. This commit updates the writer of RapidJSON to write infinite floating point numbers as "Infinity" and "-Infinity" (i.e., with double quotes) rather than Infinity and -Infinity. This is to ensure the strings converted from JSON objects conform to the rule defined by Protobuf: https://developers.google.com/protocol-buffers/docs/proto3#json Review: https://reviews.apache.org/r/72161 --- 3rdparty/CMakeLists.txt | 3 +++ 3rdparty/Makefile.am | 8 ++++++++ 3rdparty/rapidjson-1.1.0.patch | 45 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index c45d742..119813e 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -479,9 +479,12 @@ target_include_directories( rapidjson INTERFACE ${RAPIDJSON_ROOT}/include) +PATCH_CMD(RAPIDJSON_PATCH_CMD rapidjson-${RAPIDJSON_VERSION}.patch) + ExternalProject_Add( ${RAPIDJSON_TARGET} PREFIX ${RAPIDJSON_CMAKE_ROOT} + PATCH_COMMAND ${RAPIDJSON_PATCH_CMD} CONFIGURE_COMMAND ${CMAKE_NOOP} BUILD_COMMAND ${CMAKE_NOOP} INSTALL_COMMAND ${CMAKE_NOOP} diff --git a/3rdparty/Makefile.am b/3rdparty/Makefile.am index 243a619..c277627 100644 --- a/3rdparty/Makefile.am +++ b/3rdparty/Makefile.am @@ -127,6 +127,14 @@ EXTRA_DIST += \ EXTRA_DIST += \ $(ZOOKEEPER).patch +# We need to patch RapidJSON to make it write infinite floating point numbers +# as "Infinity" and "-Infinity" (i.e., with double quotes) rather than Infinity +# and -Infinity. This is to ensure the strings converted from JSON objects +# conform to the rule defined by Protobuf: +# https://developers.google.com/protocol-buffers/docs/proto3#json +EXTRA_DIST += \ + $(RAPIDJSON).patch + # We need the following patches for CMake and/or Windows builds. EXTRA_DIST += \ $(BOOST).patch \ diff --git a/3rdparty/rapidjson-1.1.0.patch b/3rdparty/rapidjson-1.1.0.patch new file mode 100644 index 0000000..8e655d9 --- /dev/null +++ b/3rdparty/rapidjson-1.1.0.patch @@ -0,0 +1,45 @@ +diff --git a/include/rapidjson/writer.h b/include/rapidjson/writer.h +index 94f22dd5..ac522f6b 100644 +--- a/include/rapidjson/writer.h ++++ b/include/rapidjson/writer.h +@@ -324,13 +324,17 @@ protected: + return true; + } + if (internal::Double(d).Sign()) { +- PutReserve(*os_, 9); ++ PutReserve(*os_, 11); ++ PutUnsafe(*os_, '\"'); + PutUnsafe(*os_, '-'); + } +- else +- PutReserve(*os_, 8); ++ else { ++ PutReserve(*os_, 10); ++ PutUnsafe(*os_, '\"'); ++ } + PutUnsafe(*os_, 'I'); PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'f'); + PutUnsafe(*os_, 'i'); PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'i'); PutUnsafe(*os_, 't'); PutUnsafe(*os_, 'y'); ++ PutUnsafe(*os_, '\"'); + return true; + } + +@@ -518,13 +522,17 @@ inline bool Writer<StringBuffer>::WriteDouble(double d) { + return true; + } + if (internal::Double(d).Sign()) { +- PutReserve(*os_, 9); ++ PutReserve(*os_, 11); ++ PutUnsafe(*os_, '\"'); + PutUnsafe(*os_, '-'); + } +- else +- PutReserve(*os_, 8); ++ else { ++ PutReserve(*os_, 10); ++ PutUnsafe(*os_, '\"'); ++ } + PutUnsafe(*os_, 'I'); PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'f'); + PutUnsafe(*os_, 'i'); PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'i'); PutUnsafe(*os_, 't'); PutUnsafe(*os_, 'y'); ++ PutUnsafe(*os_, '\"'); + return true; + }
