From 389c9b225bff54eaf12c9c613d25f3b3aa2acd1b Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Tue, 8 Oct 2013 15:31:07 -0400 Subject: [PATCH] Fixed: tokLineStart and tokCurLine have no meaning if options.locations is false. Everywhere else (except one place which is a bug) those variables only appear within an `if (options.locations)` block. --- acorn.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/acorn.js b/acorn.js index e115f886a7..945439c5c3 100644 --- a/acorn.js +++ b/acorn.js @@ -529,8 +529,10 @@ } } else if (ch === 10 || ch === 8232 || ch === 8233) { ++tokPos; - ++tokCurLine; - tokLineStart = tokPos; + if (options.locations) { + ++tokCurLine; + tokLineStart = tokPos; + } } else if (ch > 8 && ch < 14) { ++tokPos; } else if (ch === 47) { // '/' @@ -967,9 +969,11 @@ function setStrict(strct) { strict = strct; tokPos = lastEnd; - while (tokPos < tokLineStart) { - tokLineStart = input.lastIndexOf("\n", tokLineStart - 2) + 1; - --tokCurLine; + if (options.locations) { + while (tokPos < tokLineStart) { + tokLineStart = input.lastIndexOf("\n", tokLineStart - 2) + 1; + --tokCurLine; + } } skipSpace(); readToken();