From 5f57efb417bc02a0aab7be2667a3712ca8af3c64 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 24 Sep 2008 08:51:33 -0400 Subject: [PATCH] BUG: Skip a command if its arguments fail to parse If the arguments to a command fail to parse correctly due to a syntax error, the command should not be invoked. This avoids problems created by processing of commands with bad arguments. Even though the build system will not be generated, the command may affect files on disk that persist across CMake runs. --- Source/cmCommand.h | 7 ++++++- Source/cmMakefile.cxx | 3 ++- Source/cmMakefile.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/cmCommand.h b/Source/cmCommand.h index 96699ac1c..ed00b7867 100644 --- a/Source/cmCommand.h +++ b/Source/cmCommand.h @@ -64,7 +64,12 @@ public: cmExecutionStatus &status) { std::vector expandedArguments; - this->Makefile->ExpandArguments(args, expandedArguments); + if(!this->Makefile->ExpandArguments(args, expandedArguments)) + { + // There was an error expanding arguments. It was already + // reported, so we can skip this command without error. + return true; + } return this->InitialPass(expandedArguments,status); } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8456d58dd..8f102df38 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2364,7 +2364,7 @@ bool cmMakefile::IsFunctionBlocked(const cmListFileFunction& lff, return false; } -void cmMakefile::ExpandArguments( +bool cmMakefile::ExpandArguments( std::vector const& inArgs, std::vector& outArgs) { @@ -2390,6 +2390,7 @@ void cmMakefile::ExpandArguments( cmSystemTools::ExpandListArgument(value, outArgs); } } + return !cmSystemTools::GetFatalErrorOccured(); } void cmMakefile::RemoveFunctionBlocker(const cmListFileFunction& lff) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index f78a1ddb0..c2dbfb14b 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -702,7 +702,7 @@ public: * Expand the given list file arguments into the full set after * variable replacement and list expansion. */ - void ExpandArguments(std::vector const& inArgs, + bool ExpandArguments(std::vector const& inArgs, std::vector& outArgs); /** * Get the instance