aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2025-01-22 11:08:00 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2025-01-22 11:08:00 +0200
commit4ed0fe15d139748784adb40841028b36704b2f4f (patch)
tree0c0e2060171525373cfdfea356540532a734a2a3 /libbuild2/parser.cxx
parenta3ba20c5216b7615b8d31b8d7943f94793fce621 (diff)
Treat CRLF as single delimiter when scanning lines with next_word()HEADmaster
Diffstat (limited to 'libbuild2/parser.cxx')
-rw-r--r--libbuild2/parser.cxx13
1 files changed, 11 insertions, 2 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 4242b96..cb1bccc 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -2385,9 +2385,16 @@ namespace build2
//
size_t b (0), e (0);
for (size_t m (0), n (text.size ());
- next_word (text, n, b, e, m, '\n', '\r'), b != n;
- sloc.line++)
+ next_word (text, n, b, e, m, '\n', '\r'), b != n; )
{
+ // Treat consecutive \r\n (CRLF) as if they were a single
+ // delimiter.
+ //
+ if (b != 0 && text[b - 1] == '\r' &&
+ e != n && text[e] == '\n' &&
+ m != 2)
+ continue;
+
s.assign (text, b, e - b);
if (!trim (s).empty ())
@@ -2401,6 +2408,8 @@ namespace build2
break;
}
}
+
+ sloc.line++;
}
if (b == e)