From cac3aed22381d1b4ba716a4f4c9cd162b2759ebe Mon Sep 17 00:00:00 2001 From: fangyunzhong Date: Wed, 13 Dec 2023 14:53:26 +0800 Subject: [PATCH] Fix error whenparses the value of 5E-324 with libc++ Signed-off-by: fangyunzhong --- ...parses the value of 5E-324 with libc++.patch | 17 +++++++++++++++++ install.py | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100755 Fix error whenparses the value of 5E-324 with libc++.patch diff --git a/Fix error whenparses the value of 5E-324 with libc++.patch b/Fix error whenparses the value of 5E-324 with libc++.patch new file mode 100755 index 0000000..2985e69 --- /dev/null +++ b/Fix error whenparses the value of 5E-324 with libc++.patch @@ -0,0 +1,17 @@ +diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp +index f233abb..8f4c544 100755 +--- a/src/lib_json/json_reader.cpp ++++ b/src/lib_json/json_reader.cpp +@@ -1666,6 +1666,12 @@ bool OurReader::decodeDouble(Token& token, Value& decoded) { + const String buffer(token.start_, token.end_); + IStringStream is(buffer); + if (!(is >> value)) { ++ // the value could be lower than numeric_limits::min(), in this situtation we should return the value with the gurantee ++ // of conversion which has been performed and no occurances of range error. ++ if ((value > 0 && value < std::numeric_limits::min()) || (value < 0 && value > -std::numeric_limits::min())) { ++ decoded = value; ++ return true; ++ } + return addError( + "'" + String(token.start_, token.end_) + "' is not a number.", token); + } diff --git a/install.py b/install.py index 4c7ef83..30b47cc 100755 --- a/install.py +++ b/install.py @@ -47,7 +47,7 @@ def apply_patch(patch_file, target_dir): def do_patch(args, target_dir): - patch_file = [] + patch_file = [ "Fix error whenparses the value of 5E-324 with libc++.patch" ] for patch in patch_file: file_path = os.path.join(args.source_file, patch) @@ -62,6 +62,7 @@ def main(): tar_file_path = os.path.join(args.source_file, "jsoncpp-1.9.5.tar.gz") target_dir = os.path.join(args.gen_dir, "jsoncpp-1.9.5") untar_file(tar_file_path, target_dir, args) + do_patch(args, target_dir) return 0 -- Gitee