some fixes for If commands
This commit is contained in:
parent
30ad61805b
commit
6e5af0e6cc
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue