From b6a3ec9df2e597050e607e34671c0663366e37ea Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 26 Feb 2018 11:49:01 +0200 Subject: Skip multiple CR in CRLF sequence in cc::lexer --- build2/cc/lexer.cxx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/build2/cc/lexer.cxx b/build2/cc/lexer.cxx index 8a64ce7..1a11e66 100644 --- a/build2/cc/lexer.cxx +++ b/build2/cc/lexer.cxx @@ -62,18 +62,22 @@ 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. + // Handle Windows CRLF sequence. Similar to char_scanner, we treat a + // single CR as if it was followed by LF and also collapse multiple + // CRs. // - if (p == '\r') + while (p == '\r') { get (p); p = base::peek (); - if (p != '\n') // Pretend it was there. - return peek (e); // Recurse. + if (p == '\n') + break; - // Fall through. + // Pretend '\n' was there and recurse. + // + if (p != '\r') + return peek (e); } if (p == '\n') -- cgit v1.1