aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/cc/lexer.cxx16
1 files 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')