aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-03-20 23:17:41 +0000
committerGitHub <noreply@github.com>2020-03-21 07:17:41 +0800
commitb39228892d9737421027ce2e9d944976ffaee654 (patch)
treef6fc31302146077dd4d9b17ff238fea10e2b0958 /lib
parentff72eaa3c3e0d93cc4f5b111ede223e1a0ebef48 (diff)
downloadtracifyjs-b39228892d9737421027ce2e9d944976ffaee654.tar.gz
tracifyjs-b39228892d9737421027ce2e9d944976ffaee654.zip
fix line accounting in multi-line strings (#3752)
fixes #3748
Diffstat (limited to 'lib')
-rw-r--r--lib/parse.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/parse.js b/lib/parse.js
index 270af9b4..a04533a4 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -241,16 +241,16 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
if (signal_eof && !ch)
throw EX_EOF;
if (NEWLINE_CHARS[ch]) {
- S.newline_before = S.newline_before || !in_string;
- ++S.line;
S.col = 0;
- if (!in_string && ch == "\r" && peek() == "\n") {
- // treat a \r\n sequence as a single \n
- ++S.pos;
+ S.line++;
+ if (!in_string) S.newline_before = true;
+ if (ch == "\r" && peek() == "\n") {
+ // treat `\r\n` as `\n`
+ S.pos++;
ch = "\n";
}
} else {
- ++S.col;
+ S.col++;
}
return ch;
}