diff options
author | Christian Stenger <christian.stenger@qt.io> | 2020-04-29 15:06:32 +0200 |
---|---|---|
committer | Christian Stenger <christian.stenger@qt.io> | 2020-04-29 13:48:11 +0000 |
commit | 549b5719f6e560e68879850509f13ecbde1bf1f3 (patch) | |
tree | 0aca434d08ddc611cffc4120a398ff8615307632 /src/libs/qmljs | |
parent | 8806ae3bdf6a6233b2c4620566fa0414aef6daf9 (diff) | |
download | qt-creator-549b5719f6e560e68879850509f13ecbde1bf1f3.tar.gz |
QmlJS: Fix lexer handling of escape sequences (again)
The lexer handled escape sequences already, but not fully
correct.
This effectively reverts 63db0f271fd2f and fixes the wrong
offset.
Task-number: QTCREATORBUG-23830
Change-Id: I2cc1e9df5c0218cf9ee80998adce69bbc2eb4dab
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/libs/qmljs')
-rw-r--r-- | src/libs/qmljs/parser/qmljslexer.cpp | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/libs/qmljs/parser/qmljslexer.cpp b/src/libs/qmljs/parser/qmljslexer.cpp index ef3718da02..a85280fbc2 100644 --- a/src/libs/qmljs/parser/qmljslexer.cpp +++ b/src/libs/qmljs/parser/qmljslexer.cpp @@ -872,7 +872,6 @@ int Lexer::scanString(ScanStringMode mode) { QChar quote = (mode == TemplateContinuation) ? QChar(TemplateHead) : QChar(mode); bool multilineStringLiteral = false; - bool escaped = false; const QChar *startCode = _codePtr - 1; // in case we just parsed a \r, we need to reset this flag to get things working @@ -881,12 +880,6 @@ int Lexer::scanString(ScanStringMode mode) if (_engine) { while (_codePtr <= _endPtr) { - if (escaped) { // former char started an escape sequence - escaped = false; - _char = *_codePtr++; - ++_currentColumnNumber; - continue; - } if (isLineTerminator()) { if ((quote == QLatin1Char('`') || qmlMode())) break; @@ -894,10 +887,7 @@ int Lexer::scanString(ScanStringMode mode) _errorMessage = QCoreApplication::translate("QmlParser", "Stray newline in string literal"); return T_ERROR; } else if (_char == QLatin1Char('\\')) { - if (mode != DoubleQuote && mode != SingleQuote) - break; - else // otherwise we need to handle an escape sequence - escaped = true; + break; } else if (_char == '$' && quote == QLatin1Char('`')) { break; } else if (_char == quote) { @@ -923,6 +913,7 @@ int Lexer::scanString(ScanStringMode mode) // rewind by one char, so things gets scanned correctly --_codePtr; + --_currentColumnNumber; _validTokenText = true; _tokenText = QString(startCode, _codePtr - startCode); |