|
|
@@ -19,6 +19,7 @@
|
|
|
#include <cmsys/String.h>
|
|
|
|
|
|
#include <assert.h>
|
|
|
+#include <errno.h>
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
#if !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x510
|
|
|
@@ -196,6 +197,92 @@ static const struct StrEqualNode : public cmGeneratorExpressionNode
|
|
|
}
|
|
|
} strEqualNode;
|
|
|
|
|
|
+//----------------------------------------------------------------------------
|
|
|
+static const struct EqualNode : public cmGeneratorExpressionNode
|
|
|
+{
|
|
|
+ EqualNode() {}
|
|
|
+
|
|
|
+ virtual int NumExpectedParameters() const { return 2; }
|
|
|
+
|
|
|
+ std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
+ cmGeneratorExpressionContext *context,
|
|
|
+ const GeneratorExpressionContent *content,
|
|
|
+ cmGeneratorExpressionDAGChecker *) const
|
|
|
+ {
|
|
|
+ char *pEnd;
|
|
|
+
|
|
|
+ int base = 0;
|
|
|
+ bool flipSign = false;
|
|
|
+
|
|
|
+ const char *lhs = parameters[0].c_str();
|
|
|
+ if (cmHasLiteralPrefix(lhs, "0b"))
|
|
|
+ {
|
|
|
+ base = 2;
|
|
|
+ lhs += 2;
|
|
|
+ }
|
|
|
+ if (cmHasLiteralPrefix(lhs, "-0b"))
|
|
|
+ {
|
|
|
+ base = 2;
|
|
|
+ lhs += 3;
|
|
|
+ flipSign = true;
|
|
|
+ }
|
|
|
+ if (cmHasLiteralPrefix(lhs, "+0b"))
|
|
|
+ {
|
|
|
+ base = 2;
|
|
|
+ lhs += 3;
|
|
|
+ }
|
|
|
+
|
|
|
+ long lnum = strtol(lhs, &pEnd, base);
|
|
|
+ if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE)
|
|
|
+ {
|
|
|
+ reportError(context, content->GetOriginalExpression(),
|
|
|
+ "$<EQUAL> parameter " + parameters[0] + " is not a valid integer.");
|
|
|
+ return std::string();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (flipSign)
|
|
|
+ {
|
|
|
+ lnum = -lnum;
|
|
|
+ }
|
|
|
+
|
|
|
+ base = 0;
|
|
|
+ flipSign = false;
|
|
|
+
|
|
|
+ const char *rhs = parameters[1].c_str();
|
|
|
+ if (cmHasLiteralPrefix(rhs, "0b"))
|
|
|
+ {
|
|
|
+ base = 2;
|
|
|
+ rhs += 2;
|
|
|
+ }
|
|
|
+ if (cmHasLiteralPrefix(rhs, "-0b"))
|
|
|
+ {
|
|
|
+ base = 2;
|
|
|
+ rhs += 3;
|
|
|
+ flipSign = true;
|
|
|
+ }
|
|
|
+ if (cmHasLiteralPrefix(rhs, "+0b"))
|
|
|
+ {
|
|
|
+ base = 2;
|
|
|
+ rhs += 3;
|
|
|
+ }
|
|
|
+
|
|
|
+ long rnum = strtol(rhs, &pEnd, base);
|
|
|
+ if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE)
|
|
|
+ {
|
|
|
+ reportError(context, content->GetOriginalExpression(),
|
|
|
+ "$<EQUAL> parameter " + parameters[1] + " is not a valid integer.");
|
|
|
+ return std::string();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (flipSign)
|
|
|
+ {
|
|
|
+ rnum = -rnum;
|
|
|
+ }
|
|
|
+
|
|
|
+ return lnum == rnum ? "1" : "0";
|
|
|
+ }
|
|
|
+} equalNode;
|
|
|
+
|
|
|
//----------------------------------------------------------------------------
|
|
|
static const struct LowerCaseNode : public cmGeneratorExpressionNode
|
|
|
{
|
|
|
@@ -1492,6 +1579,8 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
|
|
|
return &targetSoNameFileDirNode;
|
|
|
else if (identifier == "STREQUAL")
|
|
|
return &strEqualNode;
|
|
|
+ else if (identifier == "EQUAL")
|
|
|
+ return &equalNode;
|
|
|
else if (identifier == "LOWER_CASE")
|
|
|
return &lowerCaseNode;
|
|
|
else if (identifier == "UPPER_CASE")
|