diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-11-20 19:31:48 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-11-20 19:31:48 +0200 |
commit | 02f147782d890e1483df9faa17d20f6fcbc9e867 (patch) | |
tree | c0130d58cf9052052503c4f5a9e502ad8fba3a3f | |
parent | 64935e99b7f22fb761b90b9e57b6aab3c348830f (diff) |
Recognize CRLF sequences for line escaping in cc::lexer
-rw-r--r-- | build2/cc/lexer.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
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); |