diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-02-05 21:10:35 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-02-08 14:00:44 +0000 |
commit | f7bc003aa12270da905e8f665bc0ad221a132f89 (patch) | |
tree | 0c615aa88a38c7d49acb0cc072b423ea5163feb9 /src/qml/parser/qqmljslexer.cpp | |
parent | 0e7dd897923bc5dd8e3eaf8b4f5255174c766199 (diff) |
Unify error handling in decodeUnicodeEscapeSequence
Change-Id: I69b9b9308b278ab50207e355467bf3db4b8ccbc9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljslexer.cpp')
-rw-r--r-- | src/qml/parser/qqmljslexer.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/qml/parser/qqmljslexer.cpp b/src/qml/parser/qqmljslexer.cpp index c0591f1b9b..a3382fa92e 100644 --- a/src/qml/parser/qqmljslexer.cpp +++ b/src/qml/parser/qqmljslexer.cpp @@ -340,12 +340,14 @@ QChar Lexer::decodeUnicodeEscapeCharacter(bool *ok) const QChar c4 = _char; scanChar(); - if (ok) - *ok = true; + *ok = true; return convertUnicode(c1, c2, c3, c4); } + _errorCode = IllegalUnicodeEscapeSequence; + _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence"); + *ok = false; return QChar(); } @@ -714,11 +716,8 @@ again: case 'u': { bool ok = false; u = decodeUnicodeEscapeCharacter(&ok); - if (! ok) { - _errorCode = IllegalUnicodeEscapeSequence; - _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence"); + if (!ok) return T_ERROR; - } } break; // hex escape sequence @@ -806,11 +805,8 @@ again: identifierWithEscapeChars = true; bool ok = false; c = decodeUnicodeEscapeCharacter(&ok); - if (! ok) { - _errorCode = IllegalUnicodeEscapeSequence; - _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence"); + if (!ok) return T_ERROR; - } } if (isIdentifierStart(c)) { if (identifierWithEscapeChars) { @@ -831,11 +827,8 @@ again: scanChar(); // skip '\\' bool ok = false; c = decodeUnicodeEscapeCharacter(&ok); - if (! ok) { - _errorCode = IllegalUnicodeEscapeSequence; - _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence"); + if (!ok) return T_ERROR; - } if (isIdentifierPart(c)) _tokenText += c; continue; |