summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-07-13 16:14:03 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-07-13 16:14:03 (GMT)
commit80b91ac5f579b5cc310366fb0ea4aa4c813c04bf (patch)
tree75f87410e58fcaca1f2d239ddc21609bfc1c5211
parentc3b6b687e340d4d0c65789c3ac80dbaf2eb513b5 (diff)
parent41370bc3d87afbb5485d1246dc4bcd8ab6498aa8 (diff)
downloadQt-80b91ac5f579b5cc310366fb0ea4aa4c813c04bf.zip
Qt-80b91ac5f579b5cc310366fb0ea4aa4c813c04bf.tar.gz
Qt-80b91ac5f579b5cc310366fb0ea4aa4c813c04bf.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1: make argument quoting code on windows less arcane fix argument quoting on windows
-rw-r--r--src/corelib/io/qprocess_win.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 1761c0e..510f723 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -46,6 +46,7 @@
#include <qdatetime.h>
#include <qdir.h>
#include <qfileinfo.h>
+#include <qregexp.h>
#include <qtimer.h>
#include <qthread.h>
#include <qmutex.h>
@@ -256,24 +257,19 @@ static QString qt_create_commandline(const QString &program, const QStringList &
for (int i=0; i<arguments.size(); ++i) {
QString tmp = arguments.at(i);
- // in the case of \" already being in the string the \ must also be escaped
- tmp.replace( QLatin1String("\\\""), QLatin1String("\\\\\"") );
- // escape a single " because the arguments will be parsed
- tmp.replace( QLatin1Char('\"'), QLatin1String("\\\"") );
+ // Quotes are escaped and their preceding backslashes are doubled.
+ tmp.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\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.
// rather use "foo"\ than "foo\"
- QString endQuote(QLatin1Char('\"'));
int i = tmp.length();
- while (i>0 && tmp.at(i-1) == QLatin1Char('\\')) {
+ while (i > 0 && tmp.at(i - 1) == QLatin1Char('\\'))
--i;
- endQuote += QLatin1Char('\\');
- }
- args += QLatin1String(" \"") + tmp.left(i) + endQuote;
- } else {
- args += QLatin1Char(' ') + tmp;
+ tmp.insert(i, QLatin1Char('"'));
+ tmp.prepend(QLatin1Char('"'));
}
+ args += QLatin1Char(' ') + tmp;
}
return args;
}