summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmCacheManager.cxx3
-rw-r--r--Source/cmElseCommand.cxx3
-rw-r--r--Source/cmIfCommand.cxx3
-rw-r--r--Source/cmSystemTools.cxx17
-rw-r--r--Source/cmSystemTools.h2
5 files changed, 22 insertions, 6 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index bc2f0a7..2424526 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -190,8 +190,7 @@ bool cmCacheManager::IsOn(const char* key) const
return false;
}
const std::string &v = m_Cache.find(key)->second.m_Value;
- return (v == "ON" || v == "on" || v == "1" || v == "true" || v == "yev"
- || v == "TRUE" || v == "True" || v == "y" || v == "Y");
+ return cmSystemTools::IsOn(v.c_str());
}
diff --git a/Source/cmElseCommand.cxx b/Source/cmElseCommand.cxx
index ff396fc..51e9f25 100644
--- a/Source/cmElseCommand.cxx
+++ b/Source/cmElseCommand.cxx
@@ -26,8 +26,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(def && strcmp(def,"0") && strcmp(def,"false") && strcmp(def,"") &&
- strcmp(def,"NOTFOUND"))
+ if(cmSystemTools::IsOn(def))
{
// add block
cmIfFunctionBlocker *f = new cmIfFunctionBlocker();
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index 5dab24b..0701ee2 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -48,8 +48,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(def && strcmp(def,"0") && strcmp(def,"false") && strcmp(def,"") &&
- strcmp(def,"NOTFOUND"))
+ if(cmSystemTools::IsOn(def))
{
// do nothing
}
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 0087ca0..2a27d3f 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -18,6 +18,7 @@
#include "stdio.h"
#include <sys/stat.h>
#include "cmRegularExpression.h"
+#include <ctype.h>
#if defined(_MSC_VER) || defined(__BORLANDC__)
#include <windows.h>
@@ -502,3 +503,19 @@ void cmSystemTools::RemoveFile(const char* source)
{
unlink(source);
}
+
+bool cmSystemTools::IsOn(const char* val)
+{
+ if (!val)
+ {
+ return false;
+ }
+ std::basic_string<char> v = val;
+
+ for(std::basic_string<char>::iterator c = v.begin();
+ c != v.end(); c++)
+ {
+ *c = toupper(*c);
+ }
+ return (v == "ON" || v == "1" || v == "YES" || v == "TRUE" || v == "Y");
+}
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 04347fc..a13eb56 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -126,6 +126,8 @@ public:
///! Remove a file.
static void RemoveFile(const char* source);
+ ///! does a string indicate a true or on value ?
+ static bool IsOn(const char* val);
static long int ModifiedTime(const char* filename);