diff options
Diffstat (limited to 'src/corelib/io/qprocess_win.cpp')
-rw-r--r-- | src/corelib/io/qprocess_win.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 3e2257109d..6b29710c84 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -64,6 +64,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QProcessEnvironment QProcessEnvironment::systemEnvironment() { QProcessEnvironment env; @@ -391,44 +393,44 @@ static QString qt_create_commandline(const QString &program, const QStringList & QString args; if (!program.isEmpty()) { QString programName = program; - if (!programName.startsWith(QLatin1Char('\"')) && !programName.endsWith(QLatin1Char('\"')) && programName.contains(QLatin1Char(' '))) - programName = QLatin1Char('\"') + programName + QLatin1Char('\"'); - programName.replace(QLatin1Char('/'), QLatin1Char('\\')); + if (!programName.startsWith(u'\"') && !programName.endsWith(u'\"') && programName.contains(u' ')) + programName = u'\"' + programName + u'\"'; + programName.replace(u'/', u'\\'); // add the program as the first arg ... it works better - args = programName + QLatin1Char(' '); + args = programName + u' '; } for (qsizetype i = 0; i < arguments.size(); ++i) { QString tmp = arguments.at(i); // Quotes are escaped and their preceding backslashes are doubled. - qsizetype index = tmp.indexOf(QLatin1Char('"')); + qsizetype index = tmp.indexOf(u'"'); while (index >= 0) { // Escape quote - tmp.insert(index++, QLatin1Char('\\')); + tmp.insert(index++, u'\\'); // Double preceding backslashes (ignoring the one we just inserted) - for (qsizetype i = index - 2 ; i >= 0 && tmp.at(i) == QLatin1Char('\\') ; --i) { - tmp.insert(i, QLatin1Char('\\')); + for (qsizetype i = index - 2 ; i >= 0 && tmp.at(i) == u'\\' ; --i) { + tmp.insert(i, u'\\'); index++; } - index = tmp.indexOf(QLatin1Char('"'), index + 1); + index = tmp.indexOf(u'"', index + 1); } - if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) { + if (tmp.isEmpty() || tmp.contains(u' ') || tmp.contains(u'\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. // rather use "foo"\ than "foo\" qsizetype i = tmp.length(); - while (i > 0 && tmp.at(i - 1) == QLatin1Char('\\')) + while (i > 0 && tmp.at(i - 1) == u'\\') --i; - tmp.insert(i, QLatin1Char('"')); - tmp.prepend(QLatin1Char('"')); + tmp.insert(i, u'"'); + tmp.prepend(u'"'); } - args += QLatin1Char(' ') + tmp; + args += u' ' + tmp; } if (!nativeArguments.isEmpty()) { if (!args.isEmpty()) - args += QLatin1Char(' '); + args += u' '; args += nativeArguments; } @@ -441,7 +443,7 @@ static QByteArray qt_create_environment(const QProcessEnvironmentPrivate::Map &e QProcessEnvironmentPrivate::Map copy = environment; // add PATH if necessary (for DLL loading) - QProcessEnvironmentPrivate::Key pathKey(QLatin1String("PATH")); + QProcessEnvironmentPrivate::Key pathKey("PATH"_L1); if (!copy.contains(pathKey)) { QByteArray path = qgetenv("PATH"); if (!path.isEmpty()) @@ -449,7 +451,7 @@ static QByteArray qt_create_environment(const QProcessEnvironmentPrivate::Map &e } // add systemroot if needed - QProcessEnvironmentPrivate::Key rootKey(QLatin1String("SystemRoot")); + QProcessEnvironmentPrivate::Key rootKey("SystemRoot"_L1); if (!copy.contains(rootKey)) { QByteArray systemRoot = qgetenv("SystemRoot"); if (!systemRoot.isEmpty()) |