BUG: STRLESS and STRGREATER need to treat non-existent definitions as strings.

This commit is contained in:
Brad King 2002-10-02 17:22:56 -04:00
parent f549a2bac8
commit 6c2944b6fe
2 changed files with 25 additions and 21 deletions

View File

@ -200,11 +200,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, bool &isValid,
if (args.size() == 3 && (args[1] == "MATCHES"))
{
def = makefile->GetDefinition(args[0].c_str());
if (!def)
{
def = args[0].c_str();
}
def = cmIfCommand::GetVariableOrString(args[0].c_str(), makefile);
cmRegularExpression regEntry(args[2].c_str());
// check for black line or comment
@ -217,8 +213,8 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, bool &isValid,
if (args.size() == 3 && (args[1] == "LESS"))
{
def = makefile->GetDefinition(args[0].c_str());
def2 = makefile->GetDefinition(args[2].c_str());
def = cmIfCommand::GetVariableOrString(args[0].c_str(), makefile);
def2 = cmIfCommand::GetVariableOrString(args[2].c_str(), makefile);
if (!def)
{
def = args[0].c_str();
@ -236,16 +232,8 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, bool &isValid,
if (args.size() == 3 && (args[1] == "GREATER"))
{
def = makefile->GetDefinition(args[0].c_str());
def2 = makefile->GetDefinition(args[2].c_str());
if (!def)
{
def = args[0].c_str();
}
if (!def2)
{
def2 = args[2].c_str();
}
def = cmIfCommand::GetVariableOrString(args[0].c_str(), makefile);
def2 = cmIfCommand::GetVariableOrString(args[2].c_str(), makefile);
if(atof(def) <= atof(def2))
{
isTrue = false;
@ -255,8 +243,8 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, bool &isValid,
if (args.size() == 3 && (args[1] == "STRLESS"))
{
def = makefile->GetDefinition(args[0].c_str());
def2 = makefile->GetDefinition(args[2].c_str());
def = cmIfCommand::GetVariableOrString(args[0].c_str(), makefile);
def2 = cmIfCommand::GetVariableOrString(args[2].c_str(), makefile);
if(strcmp(def,def2) >= 0)
{
isTrue = false;
@ -266,8 +254,8 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, bool &isValid,
if (args.size() == 3 && (args[1] == "STRGREATER"))
{
def = makefile->GetDefinition(args[0].c_str());
def2 = makefile->GetDefinition(args[2].c_str());
def = cmIfCommand::GetVariableOrString(args[0].c_str(), makefile);
def2 = cmIfCommand::GetVariableOrString(args[2].c_str(), makefile);
if(strcmp(def,def2) <= 0)
{
isTrue = false;
@ -277,3 +265,14 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, bool &isValid,
return isTrue;
}
const char* cmIfCommand::GetVariableOrString(const char* str,
const cmMakefile* mf)
{
const char* def = mf->GetDefinition(str);
if(!def)
{
def = str;
}
return def;
}

View File

@ -105,6 +105,11 @@ public:
static bool IsTrue(const std::vector<std::string> &args,
bool &isValid, const cmMakefile *mf);
// Get a definition from the makefile. If it doesn't exist,
// return the original string.
static const char* GetVariableOrString(const char* str,
const cmMakefile* mf);
cmTypeMacro(cmIfCommand, cmCommand);
};