Add additional <= and >= comparison operators

This adds the LESS_EQUAL, GREATER_EQUAL, and associated STR and VERSION
equivalents to use the combined <= and >= functionality.
This commit is contained in:
Chuck Atkins
2016-08-05 14:11:46 -04:00
committed by Brad King
parent 93b705a396
commit 02d177c9cc
18 changed files with 703 additions and 89 deletions

View File

@@ -2380,10 +2380,10 @@ bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op,
if (lhs < rhs) {
// lhs < rhs, so true if operation is LESS
return op == cmSystemTools::OP_LESS;
return (op & cmSystemTools::OP_LESS) != 0;
} else if (lhs > rhs) {
// lhs > rhs, so true if operation is GREATER
return op == cmSystemTools::OP_GREATER;
return (op & cmSystemTools::OP_GREATER) != 0;
}
if (*endr == '.') {
@@ -2395,7 +2395,7 @@ bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op,
}
}
// lhs == rhs, so true if operation is EQUAL
return op == cmSystemTools::OP_EQUAL;
return (op & cmSystemTools::OP_EQUAL) != 0;
}
bool cmSystemTools::VersionCompareEqual(std::string const& lhs,
@@ -2412,6 +2412,13 @@ bool cmSystemTools::VersionCompareGreater(std::string const& lhs,
rhs.c_str());
}
bool cmSystemTools::VersionCompareGreaterEq(std::string const& lhs,
std::string const& rhs)
{
return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER_EQUAL,
lhs.c_str(), rhs.c_str());
}
bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg,
bool* removed)
{