Skip to content

Commit 826aeab

Browse files
committed
1 parent 0fa72f1 commit 826aeab

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
From fae5556fd4d4850f948aeabee25ddf0280494725 Mon Sep 17 00:00:00 2001
2+
From: lizz <lizz@sensetime.com>
3+
Date: Fri, 10 Apr 2020 23:02:21 +0800
4+
Subject: [PATCH] No trailing space for BuiltStyledStreamWriter
5+
6+
Signed-off-by: lizz <lizz@sensetime.com>
7+
---
8+
src/lib_json/json_writer.cpp | 10 +++++++++-
9+
src/test_lib_json/main.cpp | 4 ++--
10+
2 files changed, 11 insertions(+), 3 deletions(-)
11+
12+
diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp
13+
index ee45c43..e22eb17 100644
14+
--- a/src/lib_json/json_writer.cpp
15+
+++ b/src/lib_json/json_writer.cpp
16+
@@ -990,7 +990,15 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
17+
writeCommentBeforeValue(childValue);
18+
writeWithIndent(
19+
valueToQuotedStringN(name.data(), name.length(), emitUTF8_));
20+
- *sout_ << colonSymbol_;
21+
+ size_t n = colonSymbol_.size();
22+
+ if ((childValue.type() == objectValue && !childValue.empty()) ||
23+
+ (childValue.type() == arrayValue && !childValue.empty() &&
24+
+ ((cs_ == CommentStyle::All) || isMultilineArray(childValue)))) {
25+
+ // Line-ending colon, so trim any trailing space from it
26+
+ for (; n && colonSymbol_[n - 1] == ' '; --n)
27+
+ ;
28+
+ }
29+
+ sout_->write(colonSymbol_.data(), n);
30+
writeValue(childValue);
31+
if (++it == members.end()) {
32+
writeCommentAfterValueOnSameLine(childValue);
33+
diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp
34+
index 55ab224..28cb043 100644
35+
--- a/src/test_lib_json/main.cpp
36+
+++ b/src/test_lib_json/main.cpp
37+
@@ -2533,7 +2533,7 @@ JSONTEST_FIXTURE_LOCAL(StreamWriterTest, writeNumericValue) {
38+
JSONTEST_FIXTURE_LOCAL(StreamWriterTest, writeArrays) {
39+
Json::StreamWriterBuilder writer;
40+
const Json::String expected("{\n"
41+
- "\t\"property1\" : \n"
42+
+ "\t\"property1\" :\n"
43+
"\t[\n"
44+
"\t\t\"value1\",\n"
45+
"\t\t\"value2\"\n"
46+
@@ -2553,7 +2553,7 @@ JSONTEST_FIXTURE_LOCAL(StreamWriterTest, writeArrays) {
47+
JSONTEST_FIXTURE_LOCAL(StreamWriterTest, writeNestedObjects) {
48+
Json::StreamWriterBuilder writer;
49+
const Json::String expected("{\n"
50+
- "\t\"object1\" : \n"
51+
+ "\t\"object1\" :\n"
52+
"\t{\n"
53+
"\t\t\"bool\" : true,\n"
54+
"\t\t\"nested\" : 123\n"
55+
--
56+
2.52.0.vfs.0.5
57+

dep/vcpkg-overlay-ports/jsoncpp/portfile.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ vcpkg_from_github(
44
REF "${VERSION}"
55
SHA512 006d81f9f723dcfe875ebc2147449c07c5246bf97dd7b9eee1909decc914b051d6f3f06feb5c3dfa143d28773fb310aabb04a81dc447cc61513309df8eba8b08
66
HEAD_REF master
7+
PATCHES
8+
0001-No-trailing-space-for-BuildStyledStreamWriter.patch
79
)
810

911
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" JSONCPP_STATIC)

0 commit comments

Comments
 (0)