From b3366233d3723ba93d7e2b186feca07b07d88eb0 Mon Sep 17 00:00:00 2001
From: Alistair Braidwood
Date: Thu, 18 Oct 2012 16:46:13 +0100
Subject: [PATCH] skipLineComment
---
acorn.js | 10 ++++++----
index.html | 10 ++++++----
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/acorn.js b/acorn.js
index bdf80843de..88a5f36231 100644
--- a/acorn.js
+++ b/acorn.js
@@ -438,10 +438,12 @@
function skipLineComment() {
var start = tokPos;
- tokPos += 2;
- while (tokPos < inputLen && !newline.test(input.charAt(tokPos))) ++tokPos;
- if (options.trackComments)
- (tokComments || (tokComments = [])).push(input.slice(start, tokPos));
+ var ch = input.charCodeAt(tokPos+=2);
+ while (tokPos < inputLen && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8329) {
+ ++tokPos;
+ ch = input.charCodeAt(tokPos);
+ }
+ (tokComments || (tokComments = [])).push(input.slice(start, tokPos));
}
// Called at the start of the parse and after every token. Skips
diff --git a/index.html b/index.html
index 9a11c332fe..c2417029a9 100644
--- a/index.html
+++ b/index.html
@@ -257,10 +257,12 @@ the right position.
function skipLineComment() {
var start = tokPos;
- tokPos += 2;
- while (tokPos < inputLen && !newline.test(input.charAt(tokPos))) ++tokPos;
- if (options.trackComments)
- (tokComments || (tokComments = [])).push(input.slice(start, tokPos));
+ var ch = input.charCodeAt(tokPos+=2);
+ while (tokPos < inputLen && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8329) {
+ ++tokPos;
+ ch = input.charCodeAt(tokPos);
+ }
+ (tokComments || (tokComments = [])).push(input.slice(start, tokPos));
} | | Called at the start of the parse and after every token. Skips
whitespace and comments, and, if options.trackComments is on,
will store all skipped comments in tokComments. | |