diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-04-05 11:26:13 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-05 11:26:13 -0700 |
| commit | d9e7f7488ce61028f7d644aec09969e041218903 (patch) | |
| tree | d56f3fec68d6d7d7ee9da5ace8a7035ff3017d9b /toolsrc/src | |
| parent | 35749685c353ba55550055c900f6f2fdeab1743f (diff) | |
| parent | 928ff24cbca717ac9b39589874b6e8ec17c236b8 (diff) | |
| download | vcpkg-d9e7f7488ce61028f7d644aec09969e041218903.tar.gz vcpkg-d9e7f7488ce61028f7d644aec09969e041218903.zip | |
Merge pull request #901 from sdcb/single_slashN
Fix a infinite skip_comment check in Paragraphs.cpp
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/Paragraphs.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/tests_paragraph.cpp | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/toolsrc/src/Paragraphs.cpp b/toolsrc/src/Paragraphs.cpp index 98eb64328..010da6700 100644 --- a/toolsrc/src/Paragraphs.cpp +++ b/toolsrc/src/Paragraphs.cpp @@ -34,7 +34,7 @@ namespace vcpkg::Paragraphs void skip_comment(char& ch) { - while (ch != '\r') + while (ch != '\r' && ch != '\n' && ch != '\0') next(ch); if (ch == '\r') next(ch); diff --git a/toolsrc/src/tests_paragraph.cpp b/toolsrc/src/tests_paragraph.cpp index ba972f437..10a84b703 100644 --- a/toolsrc/src/tests_paragraph.cpp +++ b/toolsrc/src/tests_paragraph.cpp @@ -289,6 +289,16 @@ namespace UnitTest1 Assert::AreEqual("v4", pghs[1]["f4"].c_str()); } + TEST_METHOD(parse_comment_before_single_slashN) + { + const char* str = + "f1: v1\r\n" + "#comment\n"; + auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO); + Assert::AreEqual(size_t(1), pghs[0].size()); + Assert::AreEqual("v1", pghs[0]["f1"].c_str()); + } + TEST_METHOD(BinaryParagraph_serialize_min) { std::stringstream ss; |
