From 5ae7409dc6f327262058326cf14735ac1772310c Mon Sep 17 00:00:00 2001 From: Joao Paulo Magalhaes Date: Mon, 21 Mar 2022 18:59:07 +0000 Subject: [PATCH] [fix] re #233: accept leading colon in UNK mode --- src/c4/yml/parse.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/c4/yml/parse.cpp b/src/c4/yml/parse.cpp index 4e3366f95..8fdc88cf2 100644 --- a/src/c4/yml/parse.cpp +++ b/src/c4/yml/parse.cpp @@ -65,7 +65,7 @@ void _parse_dump(DumpFn dumpfn, c4::csubstr fmt, Args&& ...args) bool _is_scalar_next__runk(csubstr s) { - return !(s.begins_with(": ") || s.begins_with_any("#,:{}[]%&") || s.begins_with("? ") || s == "-" || s.begins_with("- ")); + return !(s.begins_with(": ") || s.begins_with_any("#,{}[]%&") || s.begins_with("? ") || s == "-" || s.begins_with("- ") || s.begins_with(":\"") || s.begins_with(":'")); } bool _is_scalar_next__rseq_rval(csubstr s) @@ -2465,8 +2465,10 @@ bool Parser::_scan_scalar(csubstr *C4_RESTRICT scalar, bool *C4_RESTRICT quoted) _c4dbgp("RUNK: no scalar next"); return false; } - s = s.left_of(s.find(" #")); - size_t pos = s.find(": "); + size_t pos = s.find(" #"); + if(pos != npos) + s = s.left_of(pos); + pos = s.find(": "); if(pos != npos) s = s.left_of(pos); else if(s.ends_with(':'))