From 405dfa3e28ab71d4f6b5210faba0e3600070a0f3 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 23 Nov 2021 19:24:00 +0300 Subject: Add support for new-fashioned multi-line manifest value introducer --- libbutl/manifest-parser.cxx | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'libbutl/manifest-parser.cxx') diff --git a/libbutl/manifest-parser.cxx b/libbutl/manifest-parser.cxx index 1cb0ec7..ae0d43d 100644 --- a/libbutl/manifest-parser.cxx +++ b/libbutl/manifest-parser.cxx @@ -222,7 +222,8 @@ namespace butl string& v (r.value); string::size_type n (0); // Size of last non-space character (simple mode). - // Detect the multi-line mode introducer. + // Detect the old-fashioned multi-line mode introducer (like in + // 'foo:\'). // bool ml (false); if (c == '\\') @@ -245,6 +246,38 @@ namespace butl unget (c); } + // Detect the new-fashioned multi-line mode introducer (like in + // 'foo:\'). + // + if (!ml && c == '\n') + { + get (); + xchar p1 (peek ()); + + if (p1 == '\\') + { + get (); + xchar p2 (peek ()); + + if (p2 == '\n') + { + get (); // Newline is not part of the value so skip it. + c = peek (); + ml = true; + } + else if (eos (p2)) + { + c = p2; // Set to EOF. + ml = true; + } + else + unget (p1); // Unget '\\'. Note: '\n' will be ungot below. + } + + if (!ml) + unget (c); // Unget '\n'. + } + // Multi-line value starts from the line that follows the name. // if (ml) -- cgit v1.1