diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2004-08-03 12:13:54 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2004-08-03 12:13:54 (GMT) |
commit | f3e58aeb7d6d63c6c0a21a8f0ba58226bdfb602a (patch) | |
tree | e48ed004b75a4f7d652474e6b9862872c609bc50 /Source/cmIfCommand.cxx | |
parent | 1f203c286824b4d87278fea6982c35097b080d4b (diff) | |
download | CMake-f3e58aeb7d6d63c6c0a21a8f0ba58226bdfb602a.zip CMake-f3e58aeb7d6d63c6c0a21a8f0ba58226bdfb602a.tar.gz CMake-f3e58aeb7d6d63c6c0a21a8f0ba58226bdfb602a.tar.bz2 |
BUG: When regular expression failes to compile, produce error: Fixes part of Bug #1025 - CMake silently ignores regular expression failure
Diffstat (limited to 'Source/cmIfCommand.cxx')
-rw-r--r-- | Source/cmIfCommand.cxx | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index d9d4446..763bcf5 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -101,15 +101,15 @@ ScopeEnded(cmMakefile &mf) bool cmIfCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args) { - bool isValid; + char* errorString = 0; std::vector<std::string> expandedArguments; m_Makefile->ExpandArguments(args, expandedArguments); - bool isTrue = cmIfCommand::IsTrue(expandedArguments,isValid,m_Makefile); + bool isTrue = cmIfCommand::IsTrue(expandedArguments,&errorString,m_Makefile); - if (!isValid) + if (errorString) { - std::string err = "An IF command had incorrect arguments: "; + std::string err = "had incorrect arguments: "; unsigned int i; for(i =0; i < args.size(); ++i) { @@ -118,6 +118,9 @@ bool cmIfCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args) err += (args[i].Quoted?"\"":""); err += " "; } + err += "("; + err += errorString; + err += ")."; this->SetError(err.c_str()); return false; } @@ -146,17 +149,17 @@ bool cmIfCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args) bool cmIfCommand::IsTrue(const std::vector<std::string> &args, - bool &isValid, const cmMakefile *makefile) + char **errorString, const cmMakefile *makefile) { // check for the different signatures - isValid = false; + *errorString = "Unknown arguments specified"; const char *def; const char *def2; // handle empty invocation if (args.size() < 1) { - isValid = true; + *errorString = 0; return false; } @@ -171,7 +174,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, args[0] == "CMAKE_MINOR_VERSION" && args[1] == "MATCHES") { - isValid = true; + *errorString = 0; return true; } @@ -279,7 +282,16 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, *(argP1) == "MATCHES") { def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile); - cmsys::RegularExpression regEntry((argP2)->c_str()); + const char* rex = (argP2)->c_str(); + cmsys::RegularExpression regEntry; + if ( !regEntry.compile(rex) ) + { + cmOStringStream error; + error << "Regular expression \"" << rex << "\" cannot compile"; + *errorString = new char[error.str().size() + 1]; + strcpy(*errorString, error.str().c_str()); + return false; + } if (regEntry.find(def)) { *arg = "1"; @@ -499,7 +511,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, // now at the end there should only be one argument left if (newArgs.size() == 1) { - isValid = true; + *errorString = 0; if (*newArgs.begin() == "0") { return false; |