From fd06bfca792d327c9fc990bc1052c1bd0cbf7836 Mon Sep 17 00:00:00 2001 From: Cory Quammen Date: Tue, 7 Oct 2014 23:53:16 -0400 Subject: [PATCH] Removed unneeded newlines from parsed comments Newlines from comments separated by lines are retained when comments are appended, so adding a newline between separate comments for a node is not needed. --- src/lib_json/json_reader.cpp | 2 -- test/data/test_comment_02.json | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index 36e4c4c..c6a35bf 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -358,8 +358,6 @@ Reader::addComment(Location begin, Location end, CommentPlacement placement) { assert(lastValue_ != 0); lastValue_->setComment(std::string(begin, end), placement); } else { - if (!commentsBefore_.empty()) - commentsBefore_ += "\n"; commentsBefore_ += std::string(begin, end); } } diff --git a/test/data/test_comment_02.json b/test/data/test_comment_02.json index ccf631f..297d889 100644 --- a/test/data/test_comment_02.json +++ b/test/data/test_comment_02.json @@ -9,7 +9,8 @@ }, // C++-style comment "cpp-test" : { - // Internal comment cpp-style + // Multiline comment cpp-style + // Second line "c" : 3, "d" : 4 }