diff --git a/acorn.js b/acorn.js
index fbd3c92956..0500d20078 100644
--- a/acorn.js
+++ b/acorn.js
@@ -945,6 +945,10 @@
function setStrict(strct) {
strict = strct;
tokPos = lastEnd;
+ while (tokPos < tokLineStart) {
+ tokLineStart = input.lastIndexOf("\n", tokLineStart - 2) + 1;
+ --tokCurLine;
+ }
skipSpace();
readToken();
}
diff --git a/index.html b/index.html
index 257958c239..76826c38e0 100644
--- a/index.html
+++ b/index.html
@@ -590,7 +590,7 @@ will return null unless the integer has exactly len di
case 85: out += String.fromCharCode(readHexChar(8)); break; // 'U'
case 116: out += "\t"; break; // 't' -> '\t'
case 98: out += "\b"; break; // 'b' -> '\b'
- case 118: out += "\v"; break; // 'v' -> '\u000b'
+ case 118: out += "\u000b"; break; // 'v' -> '\u000b'
case 102: out += "\f"; break; // 'f' -> '\f'
case 48: out += "\0"; break; // 0 -> '\0'
case 13: if (input.charCodeAt(tokPos) === 10) ++tokPos; // '\r\n'
@@ -678,6 +678,10 @@ precedence levels that JavaScript defines.
function setStrict(strct) {
strict = strct;
tokPos = lastEnd;
+ while (tokPos < tokLineStart) {
+ tokLineStart = input.lastIndexOf("\n", tokLineStart - 2) + 1;
+ --tokCurLine;
+ }
skipSpace();
readToken();
}Start an AST node, attaching a start offset.
function node_t() {
diff --git a/test/tests.js b/test/tests.js
index b4c0005687..4bc875470d 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -25798,33 +25798,33 @@ test("foo: if (true) break foo;", {
]
});
-test("(function () { 'use strict'; '\0'; }())", {
+test("(function () {\n 'use strict';\n '\0';\n}())", {
type: "Program",
start: 0,
- end: 38,
+ end: 40,
loc: {
start: {
line: 1,
column: 0
},
end: {
- line: 1,
- column: 38
+ line: 4,
+ column: 4
}
},
body: [
{
type: "ExpressionStatement",
start: 0,
- end: 38,
+ end: 40,
loc: {
start: {
line: 1,
column: 0
},
end: {
- line: 1,
- column: 38
+ line: 4,
+ column: 4
}
},
expression: {
@@ -25836,22 +25836,22 @@ test("(function () { 'use strict'; '\0'; }())", {
column: 0
},
end: {
- line: 1,
- column: 38
+ line: 4,
+ column: 4
}
},
callee: {
type: "FunctionExpression",
start: 1,
- end: 35,
+ end: 37,
loc: {
start: {
line: 1,
column: 1
},
end: {
- line: 1,
- column: 35
+ line: 4,
+ column: 1
}
},
id: null,
@@ -25859,44 +25859,44 @@ test("(function () { 'use strict'; '\0'; }())", {
body: {
type: "BlockStatement",
start: 13,
- end: 35,
+ end: 37,
loc: {
start: {
line: 1,
column: 13
},
end: {
- line: 1,
- column: 35
+ line: 4,
+ column: 1
}
},
body: [
{
type: "ExpressionStatement",
- start: 15,
- end: 28,
+ start: 16,
+ end: 29,
loc: {
start: {
- line: 1,
- column: 15
+ line: 2,
+ column: 1
},
end: {
- line: 1,
- column: 28
+ line: 2,
+ column: 14
}
},
expression: {
type: "Literal",
- start: 15,
- end: 27,
+ start: 16,
+ end: 28,
loc: {
start: {
- line: 1,
- column: 15
+ line: 2,
+ column: 1
},
end: {
- line: 1,
- column: 27
+ line: 2,
+ column: 13
}
},
value: "use strict"
@@ -25904,30 +25904,30 @@ test("(function () { 'use strict'; '\0'; }())", {
},
{
type: "ExpressionStatement",
- start: 29,
- end: 33,
+ start: 31,
+ end: 35,
loc: {
start: {
- line: 1,
- column: 29
+ line: 3,
+ column: 1
},
end: {
- line: 1,
- column: 33
+ line: 3,
+ column: 5
}
},
expression: {
type: "Literal",
- start: 29,
- end: 32,
+ start: 31,
+ end: 34,
loc: {
start: {
- line: 1,
- column: 29
+ line: 3,
+ column: 1
},
end: {
- line: 1,
- column: 32
+ line: 3,
+ column: 4
}
},
value: "\u0000"
@@ -25937,7 +25937,7 @@ test("(function () { 'use strict'; '\0'; }())", {
}
},
arguments: [],
- end: 38
+ end: 40
}
}
]