summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-02-26 01:00:25 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2020-02-26 18:39:21 +0100
commit75c0ffaf6d2b92cdf26092e01acdd5af4afeac97 (patch)
treebb9e85c21248790ec99b3665928872e39b14db64 /src/corelib/io/qprocess.cpp
parent4753d69d8934258de7fb64550e50a5cbb9b5603f (diff)
parent462c2745a5168a5b57381d05779b5d16aebe018e (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: examples/network/bearermonitor/CMakeLists.txt examples/network/CMakeLists.txt src/corelib/tools/qlinkedlist.h src/sql/kernel/qsqldriver_p.h src/sql/kernel/qsqlresult_p.h src/widgets/kernel/qwidget.cpp src/widgets/kernel/qwidget_p.h tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp tests/auto/tools/moc/allmocs_baseline_in.json Change-Id: I21a3c34570ae79ea9d30107fae71759d7eac17d9
Diffstat (limited to 'src/corelib/io/qprocess.cpp')
-rw-r--r--src/corelib/io/qprocess.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 5d5b0b2a29..acc60915e7 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -2230,8 +2230,16 @@ void QProcessPrivate::start(QIODevice::OpenMode mode)
startProcess();
}
+/*!
+ \since 5.15
+
+ Splits the string \a command into a list of tokens, and returns
+ the list.
-static QStringList parseCombinedArgString(const QString &program)
+ Tokens with spaces can be surrounded by double quotes; three
+ consecutive double quotes represent the quote character itself.
+*/
+QStringList QProcess::splitCommand(const QString &command)
{
QStringList args;
QString tmp;
@@ -2241,13 +2249,13 @@ static QStringList parseCombinedArgString(const QString &program)
// handle quoting. tokens can be surrounded by double quotes
// "hello world". three consecutive double quotes represent
// the quote character itself.
- for (int i = 0; i < program.size(); ++i) {
- if (program.at(i) == QLatin1Char('"')) {
+ for (int i = 0; i < command.size(); ++i) {
+ if (command.at(i) == QLatin1Char('"')) {
++quoteCount;
if (quoteCount == 3) {
// third consecutive quote
quoteCount = 0;
- tmp += program.at(i);
+ tmp += command.at(i);
}
continue;
}
@@ -2256,13 +2264,13 @@ static QStringList parseCombinedArgString(const QString &program)
inQuote = !inQuote;
quoteCount = 0;
}
- if (!inQuote && program.at(i).isSpace()) {
+ if (!inQuote && command.at(i).isSpace()) {
if (!tmp.isEmpty()) {
args += tmp;
tmp.clear();
}
} else {
- tmp += program.at(i);
+ tmp += command.at(i);
}
}
if (!tmp.isEmpty())
@@ -2272,6 +2280,7 @@ static QStringList parseCombinedArgString(const QString &program)
}
/*!
+ \obsolete
\overload
Starts the command \a command in a new process.
@@ -2308,11 +2317,13 @@ static QStringList parseCombinedArgString(const QString &program)
list-based API. In these rare cases you need to use setProgram() and
setNativeArguments() instead of this function.
+ \sa splitCommand()
+
*/
#if !defined(QT_NO_PROCESS_COMBINED_ARGUMENT_START)
void QProcess::start(const QString &command, OpenMode mode)
{
- QStringList args = parseCombinedArgString(command);
+ QStringList args = splitCommand(command);
if (args.isEmpty()) {
Q_D(QProcess);
d->setErrorAndEmit(QProcess::FailedToStart, tr("No program defined"));
@@ -2477,6 +2488,7 @@ int QProcess::execute(const QString &program, const QStringList &arguments)
}
/*!
+ \obsolete
\overload
Starts the program \a command in a new process, waits for it to finish,
@@ -2487,7 +2499,7 @@ int QProcess::execute(const QString &program, const QStringList &arguments)
After the \a command string has been split and unquoted, this function
behaves like the overload which takes the arguments as a string list.
- \sa start()
+ \sa start(), splitCommand()
*/
int QProcess::execute(const QString &command)
{
@@ -2543,6 +2555,7 @@ bool QProcess::startDetached(const QString &program,
}
/*!
+ \obsolete
\overload startDetached()
Starts the command \a command in a new process, and detaches from it.
@@ -2553,11 +2566,11 @@ bool QProcess::startDetached(const QString &program,
After the \a command string has been split and unquoted, this function
behaves like the overload which takes the arguments as a string list.
- \sa start(const QString &command, QIODevice::OpenMode mode)
+ \sa start(const QString &command, QIODevice::OpenMode mode), splitCommand()
*/
bool QProcess::startDetached(const QString &command)
{
- QStringList args = parseCombinedArgString(command);
+ QStringList args = splitCommand(command);
if (args.isEmpty())
return false;