QtcProcess: Port to QRegularExpression

Task-number: QTCREATORBUG-24098
Change-Id: I9784989786ff65ceac6c9921f7f9f09d4e0f0a49
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2020-06-11 15:23:04 +02:00
parent 625a35e492
commit cbac89b0fd

View File

@@ -32,7 +32,7 @@
#include <QDir>
#include <QDebug>
#include <QCoreApplication>
#include <QRegExp>
#include <QRegularExpression>
#include <QStack>
#ifdef Q_OS_WIN
@@ -583,7 +583,7 @@ static QString quoteArgWin(const QString &arg)
// Quotes are escaped and their preceding backslashes are doubled.
// It's impossible to escape anything inside a quoted string on cmd
// level, so the outer quoting must be "suspended".
ret.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\"\\1\\1\\^\"\""));
ret.replace(QRegularExpression(QLatin1String("(\\\\*)\"")), QLatin1String("\"\\1\\1\\^\"\""));
// The argument must not end with a \ since this would be interpreted
// as escaping the quote -- rather put the \ behind the quote: e.g.
// rather use "foo"\ than "foo\"
@@ -1062,7 +1062,7 @@ bool QtcProcess::expandMacros(QString *cmd, AbstractMacroExpander *mx, OsType os
// Our expansion rules trigger in any context
if (state.dquote) {
// We are within a double-quoted string. Escape relevant meta characters.
rsts.replace(QRegExp(QLatin1String("([$`\"\\\\])")), QLatin1String("\\\\1"));
rsts.replace(QRegularExpression(QLatin1String("([$`\"\\\\])")), QLatin1String("\\\\1"));
} else if (state.current == MxSingleQuote) {
// We are within a single-quoted string. "Suspend" single-quoting and put a
// single escaped quote for each single quote inside the string.