From 8da0aa53585a70cac7d39262aa7087cd3a090401 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Thu, 21 Apr 2011 13:41:16 -0400 Subject: [PATCH] Handle \r\n and \r newlines in get() with scanNewlines = true (that is, when they're not whitespace) --- lib/jslex.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/jslex.js b/lib/jslex.js index aeefd55..8964cdf 100644 --- a/lib/jslex.js +++ b/lib/jslex.js @@ -437,7 +437,9 @@ Narcissus.lexer = (function() { this.lexZeroNumber(ch); } else if (ch === '"' || ch === "'") { this.lexString(ch); - } else if (this.scanNewlines && ch === '\n') { + } else if (this.scanNewlines && (ch === '\n' || ch === '\r')) { + // if this was a \r, look for \r\n + if (ch === '\r' && input[this.cursor] === '\n') this.cursor++; token.type = NEWLINE; token.value = '\n'; this.lineno++;