diff options
author | Ken Martin <ken.martin@kitware.com> | 2006-05-18 17:50:01 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2006-05-18 17:50:01 (GMT) |
commit | 29a03db7ce5150c30610d4a9b0e7c6d38f923f35 (patch) | |
tree | 283a237abcb57f0a2af8b3a4f8f4c0019f190188 /Source/cmWhileCommand.cxx | |
parent | 095e975c812c7962fa865f04444ac489f1ee8643 (diff) | |
download | CMake-29a03db7ce5150c30610d4a9b0e7c6d38f923f35.zip CMake-29a03db7ce5150c30610d4a9b0e7c6d38f923f35.tar.gz CMake-29a03db7ce5150c30610d4a9b0e7c6d38f923f35.tar.bz2 |
ENH: allow loose loop constructs
Diffstat (limited to 'Source/cmWhileCommand.cxx')
-rw-r--r-- | Source/cmWhileCommand.cxx | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 3c785d7..f99a2da 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -28,30 +28,44 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf) } // at end of for each execute recorded commands - if (cmSystemTools::LowerCase(lff.Name) == "endwhile") + if (cmSystemTools::LowerCase(lff.Name) == "while") { - char* errorString = 0; + // record the number of while commands past this one + this->Depth++; + } + else if (cmSystemTools::LowerCase(lff.Name) == "endwhile") + { + // if this is the endwhile for this while loop then execute + if (!this->Depth) + { + char* errorString = 0; - std::vector<std::string> expandedArguments; - mf.ExpandArguments(this->Args, expandedArguments); - bool isTrue = - cmIfCommand::IsTrue(expandedArguments,&errorString,&mf); - - this->Executing = true; - while (isTrue) - { - // Invoke all the functions that were collected in the block. - for(unsigned int c = 0; c < this->Functions.size(); ++c) - { - mf.ExecuteCommand(this->Functions[c]); - } - expandedArguments.clear(); + std::vector<std::string> expandedArguments; mf.ExpandArguments(this->Args, expandedArguments); - isTrue = + bool isTrue = cmIfCommand::IsTrue(expandedArguments,&errorString,&mf); + + this->Executing = true; + while (isTrue) + { + // Invoke all the functions that were collected in the block. + for(unsigned int c = 0; c < this->Functions.size(); ++c) + { + mf.ExecuteCommand(this->Functions[c]); + } + expandedArguments.clear(); + mf.ExpandArguments(this->Args, expandedArguments); + isTrue = + cmIfCommand::IsTrue(expandedArguments,&errorString,&mf); + } + mf.RemoveFunctionBlocker(lff); + return true; + } + else + { + // decrement for each nested while that ends + this->Depth--; } - mf.RemoveFunctionBlocker(lff); - return true; } // record the command @@ -62,11 +76,12 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf) } bool cmWhileFunctionBlocker:: -ShouldRemove(const cmListFileFunction& lff, cmMakefile& ) +ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) { if(cmSystemTools::LowerCase(lff.Name) == "endwhile") { - if (lff.Arguments == this->Args) + if (lff.Arguments == this->Args + || mf.IsOn("CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS")) { return true; } |