From e0f21c696a1f960d0e55f33eed9d1dc37d8edae0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 11 Dec 2012 21:09:47 +0100 Subject: [PATCH] Don't assume QChar::null() is the end of input The lexer currently assumes a null QChar implies the end of our input stream. Change it to take the full string into account. null QChar's inside comments or strings are now accepted, everywhere else they will cause a parse error. Change-Id: I60c40a32d5afe94c6c56d8a8092fc32726b98420 Reviewed-by: Erik Verbruggen --- src/qml/qml/parser/qqmljslexer.cpp | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/qml/qml/parser/qqmljslexer.cpp b/src/qml/qml/parser/qqmljslexer.cpp index 158640c..c3ddd0a 100644 --- a/src/qml/qml/parser/qqmljslexer.cpp +++ b/src/qml/qml/parser/qqmljslexer.cpp @@ -364,7 +364,7 @@ again: _tokenStartPtr = _codePtr - 1; _tokenLine = _currentLineNumber; - if (_char.isNull()) + if (_codePtr > _endPtr) return EOF_SYMBOL; const QChar ch = _char; @@ -609,7 +609,7 @@ again: const QChar *startCode = _codePtr; if (_engine) { - while (!_char.isNull()) { + while (_codePtr <= _endPtr) { if (isLineTerminator()) { if (qmlMode()) break; @@ -634,7 +634,7 @@ again: while (startCode != _codePtr - 1) _tokenText += *startCode++; - while (! _char.isNull()) { + while (_codePtr <= _endPtr) { if (unsigned sequenceLength = isLineTerminatorSequence()) { multilineStringLiteral = true; _tokenText += _char; @@ -984,7 +984,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix) _tokenText += _char; scanChar(); - if (_char.isNull() || isLineTerminator()) { + if (_codePtr > _endPtr || isLineTerminator()) { _errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression backslash sequence"); return false; } @@ -998,7 +998,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix) _tokenText += _char; scanChar(); - while (! _char.isNull() && ! isLineTerminator()) { + while (_codePtr <= _endPtr && ! isLineTerminator()) { if (_char == QLatin1Char(']')) break; else if (_char == QLatin1Char('\\')) { @@ -1006,7 +1006,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix) _tokenText += _char; scanChar(); - if (_char.isNull() || isLineTerminator()) { + if (_codePtr > _endPtr || isLineTerminator()) { _errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression backslash sequence"); return false; } @@ -1029,7 +1029,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix) break; default: - if (_char.isNull() || isLineTerminator()) { + if (_codePtr > _endPtr || isLineTerminator()) { _errorMessage = QCoreApplication::translate("QQmlParser", "Unterminated regular expression literal"); return false; } else { -- 1.7.2.5