make qmake abort when $$prompt() gets EOF

otherwise, infinite loops can result, as amply demonstrated by the new
configure (which duly replicated the old configures' behavior ...).

QMakeEvaluator::evaluateBuiltinExpand() now returns a VisitReturn like
all other evaluate*() functions. the string list return value is now an
out parameter; i used a reference instead of a pointer to avoid
adjusting 56 usages of it.

Task-number: QTBUG-13964
Change-Id: I51ca7df8d694c6ffe9d9899cba414b1b46f5ce95
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Oswald Buddenhagen 2016-11-25 20:41:20 +01:00
parent c0842aceaf
commit 80e63223f8
4 changed files with 16 additions and 10 deletions

View File

@ -560,11 +560,9 @@ void QMakeEvaluator::populateDeps(
} }
} }
ProStringList QMakeEvaluator::evaluateBuiltinExpand( QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
int func_t, const ProKey &func, const ProStringList &args) int func_t, const ProKey &func, const ProStringList &args, ProStringList &ret)
{ {
ProStringList ret;
traceMsg("calling built-in $$%s(%s)", dbgKey(func), dbgSepStrList(args)); traceMsg("calling built-in $$%s(%s)", dbgKey(func), dbgSepStrList(args));
switch (func_t) { switch (func_t) {
@ -1110,6 +1108,11 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
if (qfile.open(stdin, QIODevice::ReadOnly)) { if (qfile.open(stdin, QIODevice::ReadOnly)) {
QTextStream t(&qfile); QTextStream t(&qfile);
const QString &line = t.readLine(); const QString &line = t.readLine();
if (t.atEnd()) {
fputs("\n", stderr);
evalError(fL1S("Unexpected EOF."));
return ReturnError;
}
ret = split_value_list(QStringRef(&line)); ret = split_value_list(QStringRef(&line));
} }
} }
@ -1279,7 +1282,7 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
break; break;
} }
return ret; return ReturnTrue;
} }
QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(

View File

@ -1774,8 +1774,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateExpandFunction(
ProStringList args; ProStringList args;
if (expandVariableReferences(tokPtr, 5, &args, true) == ReturnError) if (expandVariableReferences(tokPtr, 5, &args, true) == ReturnError)
return ReturnError; return ReturnError;
*ret = evaluateBuiltinExpand(func_t, func, args); return evaluateBuiltinExpand(func_t, func, args, *ret);
return ReturnTrue;
} }
QHash<ProKey, ProFunctionDef>::ConstIterator it = QHash<ProKey, ProFunctionDef>::ConstIterator it =

View File

@ -212,7 +212,7 @@ public:
VisitReturn evaluateExpandFunction(const ProKey &function, const ushort *&tokPtr, ProStringList *ret); VisitReturn evaluateExpandFunction(const ProKey &function, const ushort *&tokPtr, ProStringList *ret);
VisitReturn evaluateConditionalFunction(const ProKey &function, const ushort *&tokPtr); VisitReturn evaluateConditionalFunction(const ProKey &function, const ushort *&tokPtr);
ProStringList evaluateBuiltinExpand(int func_t, const ProKey &function, const ProStringList &args); VisitReturn evaluateBuiltinExpand(int func_t, const ProKey &function, const ProStringList &args, ProStringList &ret);
VisitReturn evaluateBuiltinConditional(int func_t, const ProKey &function, const ProStringList &args); VisitReturn evaluateBuiltinConditional(int func_t, const ProKey &function, const ProStringList &args);
VisitReturn evaluateConditional(const QStringRef &cond, const QString &where, int line = -1); VisitReturn evaluateConditional(const QStringRef &cond, const QString &where, int line = -1);

View File

@ -99,8 +99,12 @@ QStringList QMakeProject::expand(const ProKey &func, const QList<ProStringList>
{ {
m_current.clear(); m_current.clear();
if (int func_t = statics.expands.value(func)) if (int func_t = statics.expands.value(func)) {
return evaluateBuiltinExpand(func_t, func, prepareBuiltinArgs(args)).toQStringList(); ProStringList ret;
if (evaluateBuiltinExpand(func_t, func, prepareBuiltinArgs(args), ret) == ReturnError)
exit(3);
return ret.toQStringList();
}
QHash<ProKey, ProFunctionDef>::ConstIterator it = QHash<ProKey, ProFunctionDef>::ConstIterator it =
m_functionDefs.replaceFunctions.constFind(func); m_functionDefs.replaceFunctions.constFind(func);