From 1e27db6c20913bf1c8b607f1eb5e899fc8f4112e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 6 Dec 2019 22:03:35 +0100 Subject: Avoid using a QRegExp for trivial replacements It's slow and we want to get rid of it. In this case, it's just as easy to do the replacing manually using a small loop. Task-number: QTBUG-72587 Change-Id: I32e1cc89642bc0e5b6f500d072960cd8871e0684 Reviewed-by: Friedemann Kleint Reviewed-by: Edward Welbourne --- src/corelib/io/qprocess_win.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 05af5a5aee..1527cf93ed 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -398,7 +397,17 @@ static QString qt_create_commandline(const QString &program, const QStringList & for (int i=0; i= 0) { + // Escape quote + tmp.insert(index++, QLatin1Char('\\')); + // Double preceding backslashes (ignoring the one we just inserted) + for (int i = index - 2 ; i >= 0 && tmp.at(i) == QLatin1Char('\\') ; --i) { + tmp.insert(i, QLatin1Char('\\')); + index++; + } + index = tmp.indexOf(QLatin1Char('"'), index + 1); + } if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) { // The argument must not end with a \ since this would be interpreted // as escaping the quote -- rather put the \ behind the quote: e.g. -- cgit v1.2.3