better IF ELSE handling
This commit is contained in:
parent
67547494db
commit
6deb5bbe70
|
@ -19,28 +19,6 @@
|
|||
|
||||
bool cmElseCommand::InitialPass(std::vector<std::string> const& args)
|
||||
{
|
||||
bool isValid;
|
||||
bool isTrue = cmIfCommand::IsTrue(args,isValid,m_Makefile);
|
||||
|
||||
if (!isValid)
|
||||
{
|
||||
this->SetError("An ELSE command had incorrect arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
// first remove any function blockers for the IF
|
||||
m_Makefile->RemoveFunctionBlocker("ELSE",args);
|
||||
|
||||
// if is true create a blocker for the else
|
||||
cmIfFunctionBlocker *f = new cmIfFunctionBlocker();
|
||||
f->m_IsBlocking = isTrue;
|
||||
for(std::vector<std::string>::const_iterator j = args.begin();
|
||||
j != args.end(); ++j)
|
||||
{
|
||||
f->m_Args.push_back(*j);
|
||||
}
|
||||
m_Makefile->AddFunctionBlocker(f);
|
||||
|
||||
return true;
|
||||
this->SetError("An ELSE command was found outside of a proper IF ENDIF structure. Or its arguments did not match the opening IF command.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,13 @@ IsFunctionBlocked(const char *name, const std::vector<std::string> &args,
|
|||
{
|
||||
if (args == m_Args)
|
||||
{
|
||||
// if it was an else statement then we should change state
|
||||
// and block this Else Command
|
||||
if (!strcmp(name,"ELSE"))
|
||||
{
|
||||
m_IsBlocking = !m_IsBlocking;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if(args.empty())
|
||||
|
|
|
@ -1242,7 +1242,6 @@ bool cmMakefile::IsFunctionBlocked(const char *name,
|
|||
}
|
||||
|
||||
// loop over all function blockers to see if any block this command
|
||||
std::list<cmFunctionBlocker *>::iterator pos;
|
||||
std::vector<std::string> expandedArguments;
|
||||
for(std::vector<std::string>::const_iterator i = args.begin();
|
||||
i != args.end(); ++i)
|
||||
|
@ -1255,8 +1254,10 @@ bool cmMakefile::IsFunctionBlocked(const char *name,
|
|||
expandedArguments.push_back(tmps);
|
||||
}
|
||||
}
|
||||
for (pos = m_FunctionBlockers.begin();
|
||||
pos != m_FunctionBlockers.end(); ++pos)
|
||||
// evaluate in reverse, this is critical for balanced IF statements etc
|
||||
std::list<cmFunctionBlocker *>::reverse_iterator pos;
|
||||
for (pos = m_FunctionBlockers.rbegin();
|
||||
pos != m_FunctionBlockers.rend(); ++pos)
|
||||
{
|
||||
if ((*pos)->NeedExpandedVariables())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue