aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-07 21:41:07 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-07 21:43:38 -0800
commitbb8c803bdff17a7045daeb4c7b1f7b7b0df35e41 (patch)
tree77a1ad7d269265d8340706ac59352f2587951646 /src
parent9d167deb1091ea067a43c910185b1667149151bd (diff)
downloadbun-bb8c803bdff17a7045daeb4c7b1f7b7b0df35e41.tar.gz
bun-bb8c803bdff17a7045daeb4c7b1f7b7b0df35e41.tar.zst
bun-bb8c803bdff17a7045daeb4c7b1f7b7b0df35e41.zip
Fix newline normalization
credit: @Validark
Diffstat (limited to 'src')
-rw-r--r--src/js_lexer.zig11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/js_lexer.zig b/src/js_lexer.zig
index da186eaf4..134497421 100644
--- a/src/js_lexer.zig
+++ b/src/js_lexer.zig
@@ -280,7 +280,8 @@ fn NewLexer_(
// include a <CR> or <CR><LF> sequence.
// Convert '\r\n' into '\n'
- iter.i += @as(u32, @boolToInt(iter.i < text.len and text[iter.i] == '\n'));
+ const next_i: usize = iter.i + 1;
+ iter.i += @as(u32, @boolToInt(next_i < text.len and text[next_i] == '\n'));
// Convert '\r' into '\n'
buf.append('\n') catch unreachable;
@@ -546,11 +547,11 @@ fn NewLexer_(
try lexer.syntaxError();
}
+ // Make sure Windows CRLF counts as a single newline
+ const next_i: usize = iter.i + 1;
+ iter.i += @as(u32, @boolToInt(next_i < text.len and text[next_i] == '\n'));
+
// Ignore line continuations. A line continuation is not an escaped newline.
- if (iter.i < text.len and text[iter.i + 1] == '\n') {
- // Make sure Windows CRLF counts as a single newline
- iter.i += 1;
- }
continue;
},
'\n', 0x2028, 0x2029 => {