Browse Source

ENH: fix a warning and a nice fix to the IF command

Ken Martin 19 years ago
parent
commit
372ce05a07
3 changed files with 21 additions and 6 deletions
  1. 18 4
      Source/cmIfCommand.cxx
  2. 2 1
      Source/cmIfCommand.h
  3. 1 1
      Source/cmSetPropertiesCommand.cxx

+ 18 - 4
Source/cmIfCommand.cxx

@@ -22,12 +22,26 @@
 bool cmIfFunctionBlocker::
 IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf)
 {
-  // always let if statements through
-  if (!cmSystemTools::Strucmp(lff.Name.c_str(),"if"))
+  // if we are blocking then all we need to do is keep track of 
+  // scope depth of nested if statements
+  if (this->IsBlocking)
     {
-    return false;
+    if (!cmSystemTools::Strucmp(lff.Name.c_str(),"if"))
+      {
+      this->ScopeDepth++;
+      return true;
+      }
     }
-  
+
+  if (this->IsBlocking && this->ScopeDepth)
+    {
+    if (!cmSystemTools::Strucmp(lff.Name.c_str(),"endif"))
+      {
+      this->ScopeDepth--;
+      }
+    return true;
+    }
+      
   // watch for our ELSE or ENDIF
   if (!cmSystemTools::Strucmp(lff.Name.c_str(),"else") ||
       !cmSystemTools::Strucmp(lff.Name.c_str(),"elseif") ||

+ 2 - 1
Source/cmIfCommand.h

@@ -28,7 +28,7 @@
 class cmIfFunctionBlocker : public cmFunctionBlocker
 {
 public:
-  cmIfFunctionBlocker() {this->HasRun = false;}
+  cmIfFunctionBlocker() {this->HasRun = false; this->ScopeDepth = 0;}
   virtual ~cmIfFunctionBlocker() {}
   virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
                                  cmMakefile &mf);
@@ -39,6 +39,7 @@ public:
   std::vector<cmListFileArgument> Args;
   bool IsBlocking;
   bool HasRun;
+  unsigned int ScopeDepth;
 };
 
 /** \class cmIfCommand

+ 1 - 1
Source/cmSetPropertiesCommand.cxx

@@ -167,8 +167,8 @@ bool cmSetPropertiesCommand::InitialPass(
       if (!ret)
         {
         this->SetError(errors.c_str());
+        return ret;
         }
-      return ret;
       }
       break;
     }