Ken Martin 24 éve
szülő
commit
2fb2207c10

+ 1 - 1
Source/cmElseCommand.cxx

@@ -51,7 +51,7 @@ bool cmElseCommand::Invoke(std::vector<std::string>& args)
 
   // check to see if the argument is defined first
   const char *def = m_Makefile->GetDefinition(args[0].c_str());
-  if(cmSystemTools::IsOn(def))
+  if(!cmSystemTools::IsOff(def))
     {
     // add block
     cmIfFunctionBlocker *f = new cmIfFunctionBlocker();

+ 1 - 4
Source/cmFindFileCommand.cxx

@@ -63,17 +63,14 @@ bool cmFindFileCommand::Invoke(std::vector<std::string>& args)
   helpString += args[1] + " file be found";
   const char* cacheValue
     = cmCacheManager::GetInstance()->GetCacheValue(define);
-  if(cacheValue)
+  if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
     {
-    if(strcmp(cacheValue, "NOTFOUND") != 0)
-      {
       m_Makefile->AddDefinition(define, cacheValue);
       // update help string if changed
       cmCacheManager::GetInstance()->AddCacheEntry(define,
                                                    cacheValue,
                                                    helpString.c_str(),
                                                    cmCacheManager::FILEPATH);
-      }
     return true;
     }
   // if it is not in the cache, then search the system path

+ 1 - 4
Source/cmFindLibraryCommand.cxx

@@ -55,16 +55,13 @@ bool cmFindLibraryCommand::Invoke(std::vector<std::string>& args)
   helpString += args[1] + " library be found";
   const char* cacheValue
     = cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str());
-  if(cacheValue)
+  if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
     { 
-    if(strcmp(cacheValue, "NOTFOUND") != 0)
-      {
       m_Makefile->AddDefinition(args[0].c_str(), cacheValue);
       cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
                                                    cacheValue,
                                                    helpString.c_str(),
                                                    cmCacheManager::PATH);
-      }
     return true;
     }
 

+ 1 - 4
Source/cmFindPathCommand.cxx

@@ -56,16 +56,13 @@ bool cmFindPathCommand::Invoke(std::vector<std::string>& args)
   helpString += args[1] + " can be found";
   const char* cacheValue
     = cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str());
-  if(cacheValue)
+  if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
     { 
-    if(strcmp(cacheValue, "NOTFOUND") != 0)
-      {
       m_Makefile->AddDefinition(args[0].c_str(), cacheValue);
       cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
                                                    cacheValue,
                                                    helpString.c_str(),
                                                    cmCacheManager::PATH);
-      }
     return true;
     }
 

+ 1 - 1
Source/cmIfCommand.cxx

@@ -73,7 +73,7 @@ bool cmIfCommand::Invoke(std::vector<std::string>& args)
 
   // check to see if the argument is defined first
   const char *def = m_Makefile->GetDefinition(args[0].c_str());
-  if(cmSystemTools::IsOn(def))
+  if(!cmSystemTools::IsOff(def))
     {
     // do nothing
     }

+ 17 - 0
Source/cmSystemTools.cxx

@@ -544,3 +544,20 @@ bool cmSystemTools::IsOn(const char* val)
     }
   return (v == "ON" || v == "1" || v == "YES" || v == "TRUE" || v == "Y");
 }
+
+bool cmSystemTools::IsOff(const char* val)
+{
+  if (!val)
+    {
+    return true;
+    }
+  std::basic_string<char> v = val;
+  
+  for(std::basic_string<char>::iterator c = v.begin();
+      c != v.end(); c++)
+    {
+    *c = toupper(*c);
+    }
+  return (v == "OFF" || v == "0" || v == "NO" || v == "FALSE" || 
+	  v == "N" || v == "NOTFOUND");
+}

+ 13 - 1
Source/cmSystemTools.h

@@ -151,9 +151,21 @@ public:
   ///! Remove a file.
   static void RemoveFile(const char* source);
   
-  ///! does a string indicate a true or on value ?
+  /** 
+   * does a string indicate a true or on value ? This is not the same
+   * as ifdef. 
+   */ 
   static bool IsOn(const char* val);
   
+  /** 
+   * does a string indicate a false or off value ? Note that this is
+   * not the same as !IsOn(...) because there are a number of
+   * ambiguous values such as "/usr/local/bin" a path will result in
+   * IsON and IsOff both returning false. Note that the special path
+   * NOTFOUND will cause IsOff to return true. 
+   */
+   static bool IsOff(const char* val);
+
   static long int ModifiedTime(const char* filename);
 
 private: