Browse Source

better error checking on If statements

Ken Martin 23 years ago
parent
commit
d7a1063b20
2 changed files with 7 additions and 11 deletions
  1. 2 9
      Source/cmEndIfCommand.cxx
  2. 5 2
      Source/cmIfCommand.cxx

+ 2 - 9
Source/cmEndIfCommand.cxx

@@ -19,14 +19,7 @@
 
 bool cmEndIfCommand::InitialPass(std::vector<std::string> const& args)
 {
-  if(args.size() < 1 )
-    {
-    this->SetError("called with incorrect number of arguments");
-    return false;
-    }
-  // remove any function blockers for this define
-  m_Makefile->RemoveFunctionBlocker("ENDIF",args);
-  
-  return true;
+  this->SetError("An ENDIF command was found outside of a proper IF ENDIF structure. Or its arguments did not match the opening IF command.");
+  return false;
 }
 

+ 5 - 2
Source/cmIfCommand.cxx

@@ -19,7 +19,7 @@
 
 bool cmIfFunctionBlocker::
 IsFunctionBlocked(const char *name, const std::vector<std::string> &args, 
-                  cmMakefile &)
+                  cmMakefile &mf)
 {
   if (!strcmp(name,"ELSE") || !strcmp(name,"ENDIF"))
     {
@@ -32,7 +32,10 @@ IsFunctionBlocked(const char *name, const std::vector<std::string> &args,
         m_IsBlocking = !m_IsBlocking;
         return true;
         }
-      return false;
+      // otherwise it must be an ENDIF statement, in that case remove the
+      // function blocker
+      mf.RemoveFunctionBlocker("ENDIF",args);
+      return true;
       }
     else if(args.empty())
       {