summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-04-21 18:32:36 +0200
committerOlivier Goffart <olivier.goffart@nokia.com>2011-05-10 12:54:52 +0200
commit4212ee7ec7f9ac77a4acd0796e56dbdd1e2c7baa (patch)
treefb53c250df21b57c82b1fcb8043f7386471c70f7 /src/corelib
parent3ab236d77ba47d7cbf332d12596564bce21ac6a7 (diff)
make QProcessEnvironment on Windows preserve variable name case
while windows itself does not care which case the variable names are in, they may be passed to unix tools which *do* care. note that this uses true case folding for string comparisons while windows uses uppercasing. this means that "ess" and "eß" will be considered the same by us, while not by windows. this is not expected to have real-world impact, particularly because non-ascii variable names are not used much. Task-number: QTCREATORBUG-3110 Reviewed-by: thiago Reviewed-by: dt (cherry picked from commit f3db5603871928ebed43a085a496397e65952b39)
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qprocess.cpp2
-rw-r--r--src/corelib/io/qprocess_p.h14
-rw-r--r--src/corelib/io/qprocess_win.cpp12
3 files changed, 21 insertions, 7 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index ecad92c33c..20efeae029 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -145,7 +145,7 @@ QT_BEGIN_NAMESPACE
*/
#ifdef Q_OS_WIN
static inline QProcessEnvironmentPrivate::Key prepareName(const QString &name)
-{ return name.toUpper(); }
+{ return QProcessEnvironmentPrivate::Key(name); }
static inline QString nameToString(const QProcessEnvironmentPrivate::Key &name)
{ return name; }
static inline QProcessEnvironmentPrivate::Value prepareValue(const QString &value)
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index b2a69ef905..2d4c55670d 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -85,7 +85,15 @@ class QProcessEnvironmentPrivate: public QSharedData
{
public:
#ifdef Q_OS_WIN
- typedef QString Key;
+ class Key : public QString
+ {
+ public:
+ Key() {}
+ explicit Key(const QString &other) : QString(other) {}
+ Key(const Key &other) : QString(other) {}
+ bool operator==(const Key &other) const { return !compare(other, Qt::CaseInsensitive); }
+ };
+
typedef QString Value;
#else
typedef QByteArray Key;
@@ -100,6 +108,10 @@ public:
QStringList keys() const;
void insert(const Hash &hash);
};
+#ifdef Q_OS_WIN
+Q_DECLARE_TYPEINFO(QProcessEnvironmentPrivate::Key, Q_MOVABLE_TYPE);
+inline uint qHash(const QProcessEnvironmentPrivate::Key &key) { return qHash(key.toCaseFolded()); }
+#endif
class QProcessPrivate : public QIODevicePrivate
{
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 74d8926546..82043a5c06 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -285,17 +285,19 @@ static QByteArray qt_create_environment(const QProcessEnvironmentPrivate::Hash &
QProcessEnvironmentPrivate::Hash copy = environment;
// add PATH if necessary (for DLL loading)
- if (!copy.contains(QLatin1String("PATH"))) {
+ QProcessEnvironmentPrivate::Key pathKey(QLatin1String("PATH"));
+ if (!copy.contains(pathKey)) {
QByteArray path = qgetenv("PATH");
if (!path.isEmpty())
- copy.insert(QLatin1String("PATH"), QString::fromLocal8Bit(path));
+ copy.insert(pathKey, QString::fromLocal8Bit(path));
}
// add systemroot if needed
- if (!copy.contains(QLatin1String("SYSTEMROOT"))) {
- QByteArray systemRoot = qgetenv("SYSTEMROOT");
+ QProcessEnvironmentPrivate::Key rootKey(QLatin1String("SystemRoot"));
+ if (!copy.contains(rootKey)) {
+ QByteArray systemRoot = qgetenv("SystemRoot");
if (!systemRoot.isEmpty())
- copy.insert(QLatin1String("SYSTEMROOT"), QString::fromLocal8Bit(systemRoot));
+ copy.insert(rootKey, QString::fromLocal8Bit(systemRoot));
}
int pos = 0;