diff options
author | Ken Martin <ken.martin@kitware.com> | 2004-06-14 16:02:12 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2004-06-14 16:02:12 (GMT) |
commit | a18fbc3b37e9ee8648fd701c5eb76bc467a4478a (patch) | |
tree | e2ca2b593cd10e2edd08319f3b6a1bec61b0cb2a | |
parent | cd875fe7816fdfb71c5970754f54f927a8c68321 (diff) | |
download | CMake-a18fbc3b37e9ee8648fd701c5eb76bc467a4478a.zip CMake-a18fbc3b37e9ee8648fd701c5eb76bc467a4478a.tar.gz CMake-a18fbc3b37e9ee8648fd701c5eb76bc467a4478a.tar.bz2 |
added strequal
-rw-r--r-- | Source/cmIfCommand.cxx | 40 | ||||
-rw-r--r-- | Source/cmIfCommand.h | 10 |
2 files changed, 27 insertions, 23 deletions
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index a2ffd21..d9d4446 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -133,7 +133,7 @@ bool cmIfCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args) // order of operations, // EXISTS COMMAND DEFINED -// MATCHES LESS GREATER EQUAL STRLESS STRGREATER +// MATCHES LESS GREATER EQUAL STRLESS STRGREATER STREQUAL // AND OR // // 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() && - (*(argP1) == "STRLESS" || *(argP1) == "STRGREATER")) + (*(argP1) == "STRLESS" || + *(argP1) == "STREQUAL" || + *(argP1) == "STRGREATER")) { def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile); def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile); + int val = strcmp(def,def2); + int result; if (*(argP1) == "STRLESS") { - if(strcmp(def,def2) < 0) - { - *arg = "1"; - } - else - { - *arg = "0"; - } + result = (val < 0); + } + else if (*(argP1) == "STRGREATER") + { + result = (val > 0); + } + else // strequal + { + result = (val == 0); + } + if(result) + { + *arg = "1"; } else { - if(strcmp(def,def2) > 0) - { - *arg = "1"; - } - else - { - *arg = "0"; - } - } + *arg = "0"; + } newArgs.erase(argP2); newArgs.erase(argP1); argP1 = arg; diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h index 8293a1e..4dcf884 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -115,9 +115,9 @@ public: "the same expression must be given to IF, ELSE, and ENDIF. Long " "exressions can be used and the order or precidence is that the " "EXISTS, COMMAND, and DEFINED operators will be evaluated first. " - "Then any EQUAL, LESS, GREATER, STRLESS, STRGREATER, MATCHES will be " - "evaluated. Then NOT operators and finally AND, OR operators will be " - "evaluated. Possible expressions are:\n" + "Then any EQUAL, LESS, GREATER, STRLESS, STRGREATER, STREQUAL, MATCHES " + "will be evaluated. Then NOT operators and finally AND, OR operators " + "will be evaluated. Possible expressions are:\n" " IF(variable)\n" "True if the variable's value is not empty, 0, FALSE, OFF, or NOTFOUND.\n" " IF(NOT variable)\n" @@ -149,8 +149,10 @@ public: " IF(string STRLESS string)\n" " IF(variable 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 " - "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" "True if the given variable is defined. It does not matter if the " "variable is true or false just if it has been set."; |