aboutsummaryrefslogtreecommitdiff
path: root/libbutl/manifest-parser.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2021-11-23 19:24:00 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2021-11-24 13:59:15 +0300
commit405dfa3e28ab71d4f6b5210faba0e3600070a0f3 (patch)
treee2e1de8213968c8b299904b48a60d4914eb1487b /libbutl/manifest-parser.cxx
parentb90126986fbeec6f42d469e99574096c3f6abc22 (diff)
Add support for new-fashioned multi-line manifest value introducer
Diffstat (limited to 'libbutl/manifest-parser.cxx')
-rw-r--r--libbutl/manifest-parser.cxx35
1 files changed, 34 insertions, 1 deletions
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:\<newline>').
//
bool ml (false);
if (c == '\\')
@@ -245,6 +246,38 @@ namespace butl
unget (c);
}
+ // Detect the new-fashioned multi-line mode introducer (like in
+ // 'foo:<newline>\<newline>').
+ //
+ 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)