From 02f147782d890e1483df9faa17d20f6fcbc9e867 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 20 Nov 2017 19:31:48 +0200 Subject: Recognize CRLF sequences for line escaping in cc::lexer --- build2/cc/lexer.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'build2') diff --git a/build2/cc/lexer.cxx b/build2/cc/lexer.cxx index 0615941..e904921 100644 --- a/build2/cc/lexer.cxx +++ b/build2/cc/lexer.cxx @@ -62,6 +62,20 @@ namespace build2 get (c); xchar p (base::peek ()); + // Handle Windows CRLF sequence. Similar to char_scanner, we treat + // a single CR as if it was followed by LF. + // + if (p == '\r') + { + get (p); + p = base::peek (); + + if (p != '\n') // Pretend it was there. + return peek (e); // Recurse. + + // Fall through. + } + if (p == '\n') { get (p); -- cgit v1.1