diff options
| author | Joerg Bornemann <joerg.bornemann@digia.com> | 2013-04-09 17:21:47 +0200 |
|---|---|---|
| committer | Christian Kandeler <christian.kandeler@digia.com> | 2013-04-10 13:00:10 +0200 |
| commit | f8ca9b0c9da3f9d4d28d08149bee00d0822b4ce7 (patch) | |
| tree | de7c4e30f9a593bc3597b3e93391c2502e6b22e2 | |
| parent | 9002d1c7c01e4d7dd9908d10eedc6922ddbc4c27 (diff) | |
| download | qbs-f8ca9b0c9da3f9d4d28d08149bee00d0822b4ce7.tar.gz | |
setup-qt: clean up configVariable function
Fix the regexp to not match BAR, FOOBAR and BLABAR when asking for BAR.
Fix the return value to what is everywhere expected.
Change-Id: I9d7a0d6843bc003e836250bedefcd1ae3aedd917
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
| -rw-r--r-- | src/app/qbs-setup-qt/setupqt.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/app/qbs-setup-qt/setupqt.cpp b/src/app/qbs-setup-qt/setupqt.cpp index 9476808d5..388ddefa4 100644 --- a/src/app/qbs-setup-qt/setupqt.cpp +++ b/src/app/qbs-setup-qt/setupqt.cpp @@ -122,24 +122,25 @@ static QByteArray readFileContent(const QString &filePath) return QByteArray(); } -static QByteArray configVariable(const QByteArray &configContent, const QByteArray &key) +static QString configVariable(const QByteArray &configContent, const QString &key) { - QRegExp regularExpression(QString(".*%1\\s*\\+{0,1}=(.*)").arg(QString::fromLatin1(key)), Qt::CaseSensitive); + QRegExp regexp(QLatin1String("\\s*") + key + QLatin1String("\\s*\\+{0,1}=(.*)"), + Qt::CaseSensitive); QList<QByteArray> configContentLines = configContent.split('\n'); bool success = false; foreach (const QByteArray &configContentLine, configContentLines) { - success = regularExpression.exactMatch(configContentLine); + success = regexp.exactMatch(configContentLine); if (success) break; } if (success) - return regularExpression.capturedTexts()[1].simplified().toLatin1(); + return regexp.capturedTexts()[1].simplified(); - return QByteArray(); + return QString(); } static Version extractVersion(const QString &versionString) @@ -184,7 +185,8 @@ QtEnviroment SetupQt::fetchEnviroment(const QString &qmakePath) qtEnvironment.qtPatchVersion = configVariable(qconfigContent, "QT_PATCH_VERSION").toInt(); qtEnvironment.qtNameSpace = configVariable(qconfigContent, "QT_NAMESPACE"); qtEnvironment.qtLibInfix = configVariable(qconfigContent, "QT_LIBINFIX"); - qtEnvironment.configItems = QString(configVariable(qconfigContent, "CONFIG")).split(QLatin1Char(' '), QString::SkipEmptyParts); + qtEnvironment.configItems = configVariable(qconfigContent, QLatin1String("CONFIG")).split( + QLatin1Char(' '), QString::SkipEmptyParts); // read mkspec if (qtVersion.majorVersion >= 5) { |
