1
0
mirror of https://github.com/robertkrimen/otto synced 2025-09-28 18:45:22 +08:00

Avoid backing up when checking for line terminator

This commit is contained in:
Robert Krimen 2012-10-17 01:05:52 -07:00
parent a780c85861
commit 32cbffe7b8
2 changed files with 3 additions and 2 deletions

View File

@ -25,6 +25,7 @@ func builtinGlobal_eval(call FunctionCall) Value {
runtime := call.runtime
runtime.EnterEvalExecutionContext(call)
defer runtime.LeaveExecutionContext()
// TODO Catch syntax error and convert to... SyntaxError
returnValue := runtime.evaluate(program)
if returnValue.isEmpty() {
return UndefinedValue()

View File

@ -95,8 +95,8 @@ func (self *_lexer) scanEndOfLine(chr rune, consume bool) bool {
if consume {
self.Next()
}
if chr == '\r' && self.Next() != '\n' {
self.Back() // Back because the next character was NOT \n
if chr == '\r' && self.Peek() == '\n' {
self.Next() // Consume \n
}
self.Line += 1
return true