forked from qt-creator/qt-creator
TextEditor: Fix regular expression to wildcard workaround
The used functionality turned out to do not what was expected. Fix this by a simpler but more correct way. This silences lots of warnings while running QC when using the minimum supported Qt version. Change-Id: I7c659c3cf6c1c090e992822f91bb644eec651ec9 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -112,8 +112,16 @@ bool StorageSettings::removeTrailingWhitespace(const QString &fileName) const
|
|||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
= QRegularExpression::wildcardToRegularExpression(pattern);
|
= QRegularExpression::wildcardToRegularExpression(pattern);
|
||||||
#else
|
#else
|
||||||
= QRegExp(pattern, Utils::HostOsInfo::fileNameCaseSensitivity(),
|
= pattern;
|
||||||
QRegExp::Wildcard).pattern();
|
// handle at least the most likely appearing
|
||||||
|
wildcardRegExp.replace('.', "\\.");
|
||||||
|
wildcardRegExp.replace('$', "\\$");
|
||||||
|
wildcardRegExp.replace('(', "\\(").replace(')', "\\)");
|
||||||
|
wildcardRegExp.replace('[', "\\[").replace(']', "\\]");
|
||||||
|
wildcardRegExp.replace('{', "\\{").replace('}', "\\}");
|
||||||
|
wildcardRegExp.replace('+', "\\+");
|
||||||
|
wildcardRegExp.replace('*', ".*");
|
||||||
|
wildcardRegExp.replace('?', '.');
|
||||||
#endif
|
#endif
|
||||||
QRegularExpression patternRegExp(wildcardRegExp);
|
QRegularExpression patternRegExp(wildcardRegExp);
|
||||||
QRegularExpressionMatch patternMatch = patternRegExp.match(fileName);
|
QRegularExpressionMatch patternMatch = patternRegExp.match(fileName);
|
||||||
|
Reference in New Issue
Block a user