From 223281222d7fbb3df270b8d573a7b44a102a3283 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Thu, 26 Mar 2020 10:09:54 +0100 Subject: [PATCH] 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 --- src/plugins/texteditor/storagesettings.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/plugins/texteditor/storagesettings.cpp b/src/plugins/texteditor/storagesettings.cpp index 9a0f6e2c540..a4b805f92ff 100644 --- a/src/plugins/texteditor/storagesettings.cpp +++ b/src/plugins/texteditor/storagesettings.cpp @@ -112,8 +112,16 @@ bool StorageSettings::removeTrailingWhitespace(const QString &fileName) const #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) = QRegularExpression::wildcardToRegularExpression(pattern); #else - = QRegExp(pattern, Utils::HostOsInfo::fileNameCaseSensitivity(), - QRegExp::Wildcard).pattern(); + = 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 QRegularExpression patternRegExp(wildcardRegExp); QRegularExpressionMatch patternMatch = patternRegExp.match(fileName);