aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-02-26 11:49:01 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-02-26 11:49:01 +0200
commitb6a3ec9df2e597050e607e34671c0663366e37ea (patch)
tree73997375dcf0adab7a2fb98a8c954ea67f92bc64
parent272e053941c75349144d4b8b18dfea2f3cb02e9f (diff)
Skip multiple CR in CRLF sequence in cc::lexer
-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')