From 2fb2207c1025f86cc5b62faf8c3a1ca15ea18152 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Mon, 30 Apr 2001 14:56:06 -0400 Subject: [PATCH] bug fixes --- Source/cmElseCommand.cxx | 2 +- Source/cmFindFileCommand.cxx | 5 +---- Source/cmFindLibraryCommand.cxx | 5 +---- Source/cmFindPathCommand.cxx | 5 +---- Source/cmIfCommand.cxx | 2 +- Source/cmSystemTools.cxx | 17 +++++++++++++++++ Source/cmSystemTools.h | 14 +++++++++++++- 7 files changed, 35 insertions(+), 15 deletions(-) diff --git a/Source/cmElseCommand.cxx b/Source/cmElseCommand.cxx index bebee884a..b90594560 100644 --- a/Source/cmElseCommand.cxx +++ b/Source/cmElseCommand.cxx @@ -51,7 +51,7 @@ bool cmElseCommand::Invoke(std::vector& 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(); diff --git a/Source/cmFindFileCommand.cxx b/Source/cmFindFileCommand.cxx index 21283562f..009f29157 100644 --- a/Source/cmFindFileCommand.cxx +++ b/Source/cmFindFileCommand.cxx @@ -63,17 +63,14 @@ bool cmFindFileCommand::Invoke(std::vector& 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 diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 0794101ba..6d2df8f49 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -55,16 +55,13 @@ bool cmFindLibraryCommand::Invoke(std::vector& 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; } diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 482123b12..01221bc9e 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -56,16 +56,13 @@ bool cmFindPathCommand::Invoke(std::vector& 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; } diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 462d64971..86803deae 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -73,7 +73,7 @@ bool cmIfCommand::Invoke(std::vector& 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 } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 2da843997..9211d8b1d 100644 --- a/Source/cmSystemTools.cxx +++ b/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 v = val; + + for(std::basic_string::iterator c = v.begin(); + c != v.end(); c++) + { + *c = toupper(*c); + } + return (v == "OFF" || v == "0" || v == "NO" || v == "FALSE" || + v == "N" || v == "NOTFOUND"); +} diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index e542947f5..2cc9c8ecf 100644 --- a/Source/cmSystemTools.h +++ b/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: