added strequal
This commit is contained in:
parent
cd875fe781
commit
a18fbc3b37
|
@ -133,7 +133,7 @@ bool cmIfCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args)
|
||||||
|
|
||||||
// order of operations,
|
// order of operations,
|
||||||
// EXISTS COMMAND DEFINED
|
// EXISTS COMMAND DEFINED
|
||||||
// MATCHES LESS GREATER EQUAL STRLESS STRGREATER
|
// MATCHES LESS GREATER EQUAL STRLESS STRGREATER STREQUAL
|
||||||
// AND OR
|
// AND OR
|
||||||
//
|
//
|
||||||
// There is an issue on whether the arguments should be values of references,
|
// There is an issue on whether the arguments should be values of references,
|
||||||
|
@ -357,32 +357,34 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
|
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
|
||||||
(*(argP1) == "STRLESS" || *(argP1) == "STRGREATER"))
|
(*(argP1) == "STRLESS" ||
|
||||||
|
*(argP1) == "STREQUAL" ||
|
||||||
|
*(argP1) == "STRGREATER"))
|
||||||
{
|
{
|
||||||
def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
|
def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
|
||||||
def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile);
|
def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile);
|
||||||
|
int val = strcmp(def,def2);
|
||||||
|
int result;
|
||||||
if (*(argP1) == "STRLESS")
|
if (*(argP1) == "STRLESS")
|
||||||
{
|
{
|
||||||
if(strcmp(def,def2) < 0)
|
result = (val < 0);
|
||||||
{
|
}
|
||||||
*arg = "1";
|
else if (*(argP1) == "STRGREATER")
|
||||||
}
|
{
|
||||||
else
|
result = (val > 0);
|
||||||
{
|
}
|
||||||
*arg = "0";
|
else // strequal
|
||||||
}
|
{
|
||||||
|
result = (val == 0);
|
||||||
|
}
|
||||||
|
if(result)
|
||||||
|
{
|
||||||
|
*arg = "1";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(strcmp(def,def2) > 0)
|
*arg = "0";
|
||||||
{
|
}
|
||||||
*arg = "1";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*arg = "0";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newArgs.erase(argP2);
|
newArgs.erase(argP2);
|
||||||
newArgs.erase(argP1);
|
newArgs.erase(argP1);
|
||||||
argP1 = arg;
|
argP1 = arg;
|
||||||
|
|
|
@ -115,9 +115,9 @@ public:
|
||||||
"the same expression must be given to IF, ELSE, and ENDIF. Long "
|
"the same expression must be given to IF, ELSE, and ENDIF. Long "
|
||||||
"exressions can be used and the order or precidence is that the "
|
"exressions can be used and the order or precidence is that the "
|
||||||
"EXISTS, COMMAND, and DEFINED operators will be evaluated first. "
|
"EXISTS, COMMAND, and DEFINED operators will be evaluated first. "
|
||||||
"Then any EQUAL, LESS, GREATER, STRLESS, STRGREATER, MATCHES will be "
|
"Then any EQUAL, LESS, GREATER, STRLESS, STRGREATER, STREQUAL, MATCHES "
|
||||||
"evaluated. Then NOT operators and finally AND, OR operators will be "
|
"will be evaluated. Then NOT operators and finally AND, OR operators "
|
||||||
"evaluated. Possible expressions are:\n"
|
"will be evaluated. Possible expressions are:\n"
|
||||||
" IF(variable)\n"
|
" IF(variable)\n"
|
||||||
"True if the variable's value is not empty, 0, FALSE, OFF, or NOTFOUND.\n"
|
"True if the variable's value is not empty, 0, FALSE, OFF, or NOTFOUND.\n"
|
||||||
" IF(NOT variable)\n"
|
" IF(NOT variable)\n"
|
||||||
|
@ -149,8 +149,10 @@ public:
|
||||||
" IF(string STRLESS string)\n"
|
" IF(string STRLESS string)\n"
|
||||||
" IF(variable STRGREATER string)\n"
|
" IF(variable STRGREATER string)\n"
|
||||||
" IF(string STRGREATER string)\n"
|
" IF(string STRGREATER string)\n"
|
||||||
|
" IF(variable STREQUAL string)\n"
|
||||||
|
" IF(string STREQUAL string)\n"
|
||||||
"True if the given string or variable's value is lexicographically "
|
"True if the given string or variable's value is lexicographically "
|
||||||
"less (or greater) than the string on the right.\n"
|
"less (or greater, or equal) than the string on the right.\n"
|
||||||
" IF(DEFINED variable)\n"
|
" IF(DEFINED variable)\n"
|
||||||
"True if the given variable is defined. It does not matter if the "
|
"True if the given variable is defined. It does not matter if the "
|
||||||
"variable is true or false just if it has been set.";
|
"variable is true or false just if it has been set.";
|
||||||
|
|
Loading…
Reference in New Issue