Skip to content

Commit

Permalink
Support for non-Unix (read: non-sense) newlines.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Richards authored and Gregor Richards committed Apr 18, 2011
1 parent b0cc62c commit dd85be8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/jslex.js
Expand Up @@ -135,6 +135,15 @@ Narcissus.lexer = (function() {
for (;;) {
var ch = input[this.cursor++];
var next = input[this.cursor];
// handle \r, \r\n and (always preferable) \n
if (ch === '\r') {
// if the next character is \n, we don't care about this at all
if (next === '\n') continue;

// otherwise, we want to consider this as a newline
ch = '\n';
}

if (ch === '\n' && !this.scanNewlines) {
this.lineno++;
} else if (ch === '/' && next === '*') {
Expand Down

0 comments on commit dd85be8

Please sign in to comment.