diff --git a/src/shared/proparser/proitems.cpp b/src/shared/proparser/proitems.cpp index ebf448516a7..5ea3405fd32 100644 --- a/src/shared/proparser/proitems.cpp +++ b/src/shared/proparser/proitems.cpp @@ -379,6 +379,20 @@ void ProStringList::removeAll(const char *str) remove(i); } +void ProStringList::removeEach(const ProStringList &value) +{ + foreach (const ProString &str, value) + if (!str.isEmpty()) + removeAll(str); +} + +void ProStringList::removeEmpty() +{ + for (int i = size(); --i >= 0;) + if (at(i).isEmpty()) + remove(i); +} + void ProStringList::removeDuplicates() { int n = size(); @@ -398,6 +412,13 @@ void ProStringList::removeDuplicates() erase(begin() + j, end()); } +void ProStringList::insertUnique(const ProStringList &value) +{ + foreach (const ProString &str, value) + if (!str.isEmpty() && !contains(str)) + append(str); +} + ProStringList::ProStringList(const QStringList &list) { reserve(list.size()); diff --git a/src/shared/proparser/proitems.h b/src/shared/proparser/proitems.h index f1ef1dd8e34..c18f976b229 100644 --- a/src/shared/proparser/proitems.h +++ b/src/shared/proparser/proitems.h @@ -236,9 +236,13 @@ public: QString join(const QString &sep) const; QString join(QChar sep) const; + void insertUnique(const ProStringList &value); + void removeAll(const ProString &str); void removeAll(const char *str); + void removeEach(const ProStringList &value); void removeAt(int idx) { remove(idx); } + void removeEmpty(); void removeDuplicates(); bool contains(const ProString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; diff --git a/src/shared/proparser/qmakebuiltins.cpp b/src/shared/proparser/qmakebuiltins.cpp index 86263b51b78..5d048e96717 100644 --- a/src/shared/proparser/qmakebuiltins.cpp +++ b/src/shared/proparser/qmakebuiltins.cpp @@ -1688,7 +1688,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( if (mode == CacheAdd) newval += diffval; else - removeEach(&newval, diffval); + newval.removeEach(diffval); } if (oldval != newval) { if (target != TargetStash || !m_stashfile.isEmpty()) { diff --git a/src/shared/proparser/qmakeevaluator.cpp b/src/shared/proparser/qmakeevaluator.cpp index 7cb0e49619b..20bdd310ac4 100644 --- a/src/shared/proparser/qmakeevaluator.cpp +++ b/src/shared/proparser/qmakeevaluator.cpp @@ -347,34 +347,6 @@ ProStringList QMakeEvaluator::split_value_list(const QString &vals, const ProFil return ret; } -static void zipEmpty(ProStringList *value) -{ - for (int i = value->size(); --i >= 0;) - if (value->at(i).isEmpty()) - value->remove(i); -} - -static void insertUnique(ProStringList *varlist, const ProStringList &value) -{ - foreach (const ProString &str, value) - if (!str.isEmpty() && !varlist->contains(str)) - varlist->append(str); -} - -static void removeAll(ProStringList *varlist, const ProString &value) -{ - for (int i = varlist->size(); --i >= 0; ) - if (varlist->at(i) == value) - varlist->remove(i); -} - -void QMakeEvaluator::removeEach(ProStringList *varlist, const ProStringList &value) -{ - foreach (const ProString &str, value) - if (!str.isEmpty()) - removeAll(varlist, str); -} - static void replaceInList(ProStringList *varlist, const QRegExp ®exp, const QString &replace, bool global, QString &tmp) { @@ -918,24 +890,24 @@ void QMakeEvaluator::visitProVariable( switch (tok) { default: // whatever - cannot happen case TokAssign: // = - zipEmpty(&varVal); + varVal.removeEmpty(); // FIXME: add check+warning about accidental value removal. // This may be a bit too noisy, though. m_valuemapStack.top()[varName] = varVal; debugMsg(2, "assigning"); break; case TokAppendUnique: // *= - insertUnique(&valuesRef(varName), varVal); + valuesRef(varName).insertUnique(varVal); debugMsg(2, "appending unique"); break; case TokAppend: // += - zipEmpty(&varVal); + varVal.removeEmpty(); valuesRef(varName) += varVal; debugMsg(2, "appending"); break; case TokRemove: // -= if (!m_cumulative) { - removeEach(&valuesRef(varName), varVal); + valuesRef(varName).removeEach(varVal); } else { // We are stingy with our values. } diff --git a/src/shared/proparser/qmakeevaluator.h b/src/shared/proparser/qmakeevaluator.h index 5ed1458f87d..002204b8cf3 100644 --- a/src/shared/proparser/qmakeevaluator.h +++ b/src/shared/proparser/qmakeevaluator.h @@ -240,8 +240,6 @@ public: #endif QByteArray getCommandOutput(const QString &args) const; - static void removeEach(ProStringList *varlist, const ProStringList &value); - QMakeEvaluator *m_caller; #ifdef PROEVALUATOR_CUMULATIVE bool m_cumulative;