Properly handle \r\n pairs in doc-comments.

This commit is contained in:
Stephen Chung 2022-01-17 23:15:51 +08:00
parent d58df1fb34
commit f0781c9736
2 changed files with 10 additions and 1 deletions

View File

@ -16,6 +16,7 @@ Bug fixes
* `remove` for arrays and BLOB's now treat negative index correctly.
* `parse_int` now works properly for negative numbers.
* `Engine::gen_fn_signatures` now generates signatures for external packages registered via `Engine::register_global_module`.
* `\r\n` pairs are now recognized correctly for doc-comments.
Enhancements
------------

View File

@ -1594,7 +1594,7 @@ fn get_next_token_inner(
eat_next(stream, pos);
pos.new_line();
// `\r\n
if stream.peek_next().map(|ch| ch == '\n').unwrap_or(false) {
if let Some('\n') = stream.peek_next() {
eat_next(stream, pos);
}
}
@ -1761,6 +1761,14 @@ fn get_next_token_inner(
};
while let Some(c) = stream.get_next() {
if c == '\r' {
pos.new_line();
// \r\n
if let Some('\n') = stream.peek_next() {
eat_next(stream, pos);
}
break;
}
if c == '\n' {
pos.new_line();
break;