summaryrefslogtreecommitdiffstats
path: root/Source/cmIfCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2002-10-02 21:22:56 (GMT)
committerBrad King <brad.king@kitware.com>2002-10-02 21:22:56 (GMT)
commit6c2944b6fe8ae264bcb107cb11512ed36d90a586 (patch)
treeb74531db3c5f3847b42cc5c32055a0d9e7ffe241 /Source/cmIfCommand.cxx
parentf549a2bac88e000fc7ef4bfc45477449255c9d9d (diff)
downloadCMake-6c2944b6fe8ae264bcb107cb11512ed36d90a586.zip
CMake-6c2944b6fe8ae264bcb107cb11512ed36d90a586.tar.gz
CMake-6c2944b6fe8ae264bcb107cb11512ed36d90a586.tar.bz2
BUG: STRLESS and STRGREATER need to treat non-existent definitions as strings.
Diffstat (limited to 'Source/cmIfCommand.cxx')
-rw-r--r--Source/cmIfCommand.cxx41
1 files changed, 20 insertions, 21 deletions
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index ffcd901..7baba12 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -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;
+}