ENH: fix a warning and a nice fix to the IF command

This commit is contained in:
Ken Martin 2006-12-12 10:07:20 -05:00
parent 97eceffa23
commit 372ce05a07
3 changed files with 21 additions and 6 deletions

View File

@ -22,12 +22,26 @@
bool cmIfFunctionBlocker::
IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf)
{
// always let if statements through
if (!cmSystemTools::Strucmp(lff.Name.c_str(),"if"))
// if we are blocking then all we need to do is keep track of
// scope depth of nested if statements
if (this->IsBlocking)
{
return false;
if (!cmSystemTools::Strucmp(lff.Name.c_str(),"if"))
{
this->ScopeDepth++;
return true;
}
}
if (this->IsBlocking && this->ScopeDepth)
{
if (!cmSystemTools::Strucmp(lff.Name.c_str(),"endif"))
{
this->ScopeDepth--;
}
return true;
}
// watch for our ELSE or ENDIF
if (!cmSystemTools::Strucmp(lff.Name.c_str(),"else") ||
!cmSystemTools::Strucmp(lff.Name.c_str(),"elseif") ||

View File

@ -28,7 +28,7 @@
class cmIfFunctionBlocker : public cmFunctionBlocker
{
public:
cmIfFunctionBlocker() {this->HasRun = false;}
cmIfFunctionBlocker() {this->HasRun = false; this->ScopeDepth = 0;}
virtual ~cmIfFunctionBlocker() {}
virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
cmMakefile &mf);
@ -39,6 +39,7 @@ public:
std::vector<cmListFileArgument> Args;
bool IsBlocking;
bool HasRun;
unsigned int ScopeDepth;
};
/** \class cmIfCommand

View File

@ -167,8 +167,8 @@ bool cmSetPropertiesCommand::InitialPass(
if (!ret)
{
this->SetError(errors.c_str());
return ret;
}
return ret;
}
break;
}