Browse Source

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.
Brad King 17 years ago
parent
commit
5f57efb417
3 changed files with 9 additions and 3 deletions
  1. 6 1
      Source/cmCommand.h
  2. 2 1
      Source/cmMakefile.cxx
  3. 1 1
      Source/cmMakefile.h

+ 6 - 1
Source/cmCommand.h

@@ -64,7 +64,12 @@ public:
                                  cmExecutionStatus &status)
                                  cmExecutionStatus &status)
     {
     {
     std::vector<std::string> expandedArguments;
     std::vector<std::string> 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);
     return this->InitialPass(expandedArguments,status);
     }
     }
 
 

+ 2 - 1
Source/cmMakefile.cxx

@@ -2364,7 +2364,7 @@ bool cmMakefile::IsFunctionBlocked(const cmListFileFunction& lff,
   return false;
   return false;
 }
 }
 
 
-void cmMakefile::ExpandArguments(
+bool cmMakefile::ExpandArguments(
   std::vector<cmListFileArgument> const& inArgs,
   std::vector<cmListFileArgument> const& inArgs,
   std::vector<std::string>& outArgs)
   std::vector<std::string>& outArgs)
 {
 {
@@ -2390,6 +2390,7 @@ void cmMakefile::ExpandArguments(
       cmSystemTools::ExpandListArgument(value, outArgs);
       cmSystemTools::ExpandListArgument(value, outArgs);
       }
       }
     }
     }
+  return !cmSystemTools::GetFatalErrorOccured();
 }
 }
 
 
 void cmMakefile::RemoveFunctionBlocker(const cmListFileFunction& lff)
 void cmMakefile::RemoveFunctionBlocker(const cmListFileFunction& lff)

+ 1 - 1
Source/cmMakefile.h

@@ -702,7 +702,7 @@ public:
    * Expand the given list file arguments into the full set after
    * Expand the given list file arguments into the full set after
    * variable replacement and list expansion.
    * variable replacement and list expansion.
    */
    */
-  void ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
+  bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
                        std::vector<std::string>& outArgs);
                        std::vector<std::string>& outArgs);
   /**
   /**
    * Get the instance
    * Get the instance