summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmElseCommand.cxx26
-rw-r--r--Source/cmIfCommand.cxx7
-rw-r--r--Source/cmMakefile.cxx7
3 files changed, 13 insertions, 27 deletions
diff --git a/Source/cmElseCommand.cxx b/Source/cmElseCommand.cxx
index 2e309dd..661616c 100644
--- a/Source/cmElseCommand.cxx
+++ b/Source/cmElseCommand.cxx
@@ -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;
}
-
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index 55252da..0e20272 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -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())
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 75dd641..dc187ef 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -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())
{