BUG: STRLESS and STRGREATER need to treat non-existent definitions as strings.
This commit is contained in:
parent
f549a2bac8
commit
6c2944b6fe
@ -200,11 +200,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, bool &isValid,
|
|||||||
|
|
||||||
if (args.size() == 3 && (args[1] == "MATCHES"))
|
if (args.size() == 3 && (args[1] == "MATCHES"))
|
||||||
{
|
{
|
||||||
def = makefile->GetDefinition(args[0].c_str());
|
def = cmIfCommand::GetVariableOrString(args[0].c_str(), makefile);
|
||||||
if (!def)
|
|
||||||
{
|
|
||||||
def = args[0].c_str();
|
|
||||||
}
|
|
||||||
cmRegularExpression regEntry(args[2].c_str());
|
cmRegularExpression regEntry(args[2].c_str());
|
||||||
|
|
||||||
// check for black line or comment
|
// 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"))
|
if (args.size() == 3 && (args[1] == "LESS"))
|
||||||
{
|
{
|
||||||
def = makefile->GetDefinition(args[0].c_str());
|
def = cmIfCommand::GetVariableOrString(args[0].c_str(), makefile);
|
||||||
def2 = makefile->GetDefinition(args[2].c_str());
|
def2 = cmIfCommand::GetVariableOrString(args[2].c_str(), makefile);
|
||||||
if (!def)
|
if (!def)
|
||||||
{
|
{
|
||||||
def = args[0].c_str();
|
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"))
|
if (args.size() == 3 && (args[1] == "GREATER"))
|
||||||
{
|
{
|
||||||
def = makefile->GetDefinition(args[0].c_str());
|
def = cmIfCommand::GetVariableOrString(args[0].c_str(), makefile);
|
||||||
def2 = makefile->GetDefinition(args[2].c_str());
|
def2 = cmIfCommand::GetVariableOrString(args[2].c_str(), makefile);
|
||||||
if (!def)
|
|
||||||
{
|
|
||||||
def = args[0].c_str();
|
|
||||||
}
|
|
||||||
if (!def2)
|
|
||||||
{
|
|
||||||
def2 = args[2].c_str();
|
|
||||||
}
|
|
||||||
if(atof(def) <= atof(def2))
|
if(atof(def) <= atof(def2))
|
||||||
{
|
{
|
||||||
isTrue = false;
|
isTrue = false;
|
||||||
@ -255,8 +243,8 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, bool &isValid,
|
|||||||
|
|
||||||
if (args.size() == 3 && (args[1] == "STRLESS"))
|
if (args.size() == 3 && (args[1] == "STRLESS"))
|
||||||
{
|
{
|
||||||
def = makefile->GetDefinition(args[0].c_str());
|
def = cmIfCommand::GetVariableOrString(args[0].c_str(), makefile);
|
||||||
def2 = makefile->GetDefinition(args[2].c_str());
|
def2 = cmIfCommand::GetVariableOrString(args[2].c_str(), makefile);
|
||||||
if(strcmp(def,def2) >= 0)
|
if(strcmp(def,def2) >= 0)
|
||||||
{
|
{
|
||||||
isTrue = false;
|
isTrue = false;
|
||||||
@ -266,8 +254,8 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, bool &isValid,
|
|||||||
|
|
||||||
if (args.size() == 3 && (args[1] == "STRGREATER"))
|
if (args.size() == 3 && (args[1] == "STRGREATER"))
|
||||||
{
|
{
|
||||||
def = makefile->GetDefinition(args[0].c_str());
|
def = cmIfCommand::GetVariableOrString(args[0].c_str(), makefile);
|
||||||
def2 = makefile->GetDefinition(args[2].c_str());
|
def2 = cmIfCommand::GetVariableOrString(args[2].c_str(), makefile);
|
||||||
if(strcmp(def,def2) <= 0)
|
if(strcmp(def,def2) <= 0)
|
||||||
{
|
{
|
||||||
isTrue = false;
|
isTrue = false;
|
||||||
@ -277,3 +265,14 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, bool &isValid,
|
|||||||
|
|
||||||
return isTrue;
|
return isTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* cmIfCommand::GetVariableOrString(const char* str,
|
||||||
|
const cmMakefile* mf)
|
||||||
|
{
|
||||||
|
const char* def = mf->GetDefinition(str);
|
||||||
|
if(!def)
|
||||||
|
{
|
||||||
|
def = str;
|
||||||
|
}
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
@ -105,6 +105,11 @@ public:
|
|||||||
static bool IsTrue(const std::vector<std::string> &args,
|
static bool IsTrue(const std::vector<std::string> &args,
|
||||||
bool &isValid, const cmMakefile *mf);
|
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);
|
cmTypeMacro(cmIfCommand, cmCommand);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user