From a6db7e32ac506d536596d31bdb2b365de1cf35a2 Mon Sep 17 00:00:00 2001 From: "Dr. Andre Vehreschild" <101638173+vehre-x41@users.noreply.github.com> Date: Fri, 1 Apr 2022 05:16:35 +0200 Subject: [PATCH] Fix single cr not recognized (#1094) Complies with YAML Standard [5.4](https://yaml.org/spec/1.2.2/#54-line-break-characters) [25] instead of matching `\r` only in combination with `\n`. --- src/exp.h | 2 +- test/integration/emitter_test.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/exp.h b/src/exp.h index 301449e..c623ec9 100644 --- a/src/exp.h +++ b/src/exp.h @@ -37,7 +37,7 @@ inline const RegEx& Blank() { return e; } inline const RegEx& Break() { - static const RegEx e = RegEx('\n') | RegEx("\r\n"); + static const RegEx e = RegEx('\n') | RegEx("\r"); return e; } inline const RegEx& BlankOrBreak() { diff --git a/test/integration/emitter_test.cpp b/test/integration/emitter_test.cpp index f1d6308..560f631 100644 --- a/test/integration/emitter_test.cpp +++ b/test/integration/emitter_test.cpp @@ -968,6 +968,14 @@ TEST_F(EmitterTest, UserType) { ExpectEmit("- x: 5\n bar: hello\n- x: 3\n bar: goodbye"); } +TEST_F(EmitterTest, UserType2) { + out << BeginSeq; + out << Foo(5, "\r"); + out << EndSeq; + + ExpectEmit("- x: 5\n bar: \"\\r\""); +} + TEST_F(EmitterTest, UserTypeInContainer) { std::vector fv; fv.push_back(Foo(5, "hello"));