diff options
Diffstat (limited to 'qmake/library/qmakeglobals.cpp')
-rw-r--r-- | qmake/library/qmakeglobals.cpp | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/qmake/library/qmakeglobals.cpp b/qmake/library/qmakeglobals.cpp index 4f1a9d2a55..ff59bdb303 100644 --- a/qmake/library/qmakeglobals.cpp +++ b/qmake/library/qmakeglobals.cpp @@ -74,27 +74,8 @@ QT_BEGIN_NAMESPACE #define fL1S(s) QString::fromLatin1(s) -namespace { // MSVC doesn't seem to know the semantics of "static" ... - -static struct { - QRegExp reg_variableName; -} statics; - -} - -static void initStatics() -{ - if (!statics.reg_variableName.isEmpty()) - return; - - statics.reg_variableName.setPattern(QLatin1String("\\$\\(.*\\)")); - statics.reg_variableName.setMinimal(true); -} - QMakeGlobals::QMakeGlobals() { - initStatics(); - do_cache = true; #ifdef PROEVALUATOR_DEBUG @@ -202,11 +183,11 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments( void QMakeGlobals::commitCommandLineArguments(QMakeCmdLineParserState &state) { if (!state.preconfigs.isEmpty()) - state.precmds << (fL1S("CONFIG += ") + state.preconfigs.join(fL1S(" "))); - precmds = state.precmds.join(fL1S("\n")); + state.precmds << (fL1S("CONFIG += ") + state.preconfigs.join(QLatin1Char(' '))); + precmds = state.precmds.join(QLatin1Char('\n')); if (!state.postconfigs.isEmpty()) - state.postcmds << (fL1S("CONFIG += ") + state.postconfigs.join(fL1S(" "))); - postcmds = state.postcmds.join(fL1S("\n")); + state.postcmds << (fL1S("CONFIG += ") + state.postconfigs.join(QLatin1Char(' '))); + postcmds = state.postcmds.join(QLatin1Char('\n')); if (xqmakespec.isEmpty()) xqmakespec = qmakespec; @@ -297,11 +278,24 @@ QStringList QMakeGlobals::getPathListEnv(const QString &var) const QString QMakeGlobals::expandEnvVars(const QString &str) const { QString string = str; - int rep; - QRegExp reg_variableName = statics.reg_variableName; // Copy for thread safety - while ((rep = reg_variableName.indexIn(string)) != -1) - string.replace(rep, reg_variableName.matchedLength(), - getEnv(string.mid(rep + 2, reg_variableName.matchedLength() - 3))); + int startIndex = 0; + forever { + startIndex = string.indexOf(QLatin1Char('$'), startIndex); + if (startIndex < 0) + break; + if (string.length() < startIndex + 3) + break; + if (string.at(startIndex + 1) != QLatin1Char('(')) { + startIndex++; + continue; + } + int endIndex = string.indexOf(QLatin1Char(')'), startIndex + 2); + if (endIndex < 0) + break; + QString value = getEnv(string.mid(startIndex + 2, endIndex - startIndex - 2)); + string.replace(startIndex, endIndex - startIndex + 1, value); + startIndex += value.length(); + } return string; } |