forked from qt-creator/qt-creator
CPlusPlus: Fix finding end of raw string literal
The employed algorithm lacked proper backtracking, potentially causing us to miss the delimiter altogether. Change-Id: I7993c3c27d034925bd884e192779c85c54be9ec4 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
18
src/libs/3rdparty/cplusplus/Lexer.cpp
vendored
18
src/libs/3rdparty/cplusplus/Lexer.cpp
vendored
@@ -838,16 +838,16 @@ void Lexer::scanRawStringLiteral(Token *tok, unsigned char hint)
|
||||
|
||||
bool Lexer::scanUntilRawStringLiteralEndPrecise()
|
||||
{
|
||||
int matchLen = 0;
|
||||
QByteArray slidingWindow;
|
||||
slidingWindow.reserve(_expectedRawStringSuffix.size());
|
||||
while (_yychar) {
|
||||
if (_yychar == _expectedRawStringSuffix.at(matchLen)) {
|
||||
if (++matchLen == _expectedRawStringSuffix.length()) {
|
||||
_expectedRawStringSuffix.clear();
|
||||
yyinp();
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
matchLen = 0;
|
||||
slidingWindow.append(_yychar);
|
||||
if (slidingWindow.size() > _expectedRawStringSuffix.size())
|
||||
slidingWindow.removeFirst();
|
||||
if (slidingWindow == _expectedRawStringSuffix) {
|
||||
_expectedRawStringSuffix.clear();
|
||||
yyinp();
|
||||
return true;
|
||||
}
|
||||
yyinp();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user