From 5b0f73a15a7b49461123a969bbebceff4284df9c Mon Sep 17 00:00:00 2001 From: Daniel Franke Date: Fri, 18 May 2018 21:59:46 +0200 Subject: math: Use 64-bit integer type for computation --- Source/cmExprParserHelper.cxx | 3 ++- Source/cmExprParserHelper.h | 10 ++++++---- Source/cmMathCommand.cxx | 7 ++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Source/cmExprParserHelper.cxx b/Source/cmExprParserHelper.cxx index fe7159a8db..c68ebc0b05 100644 --- a/Source/cmExprParserHelper.cxx +++ b/Source/cmExprParserHelper.cxx @@ -13,6 +13,7 @@ cmExprParserHelper::cmExprParserHelper() { this->FileLine = -1; this->FileName = nullptr; + this->Result = 0; } cmExprParserHelper::~cmExprParserHelper() @@ -85,7 +86,7 @@ void cmExprParserHelper::Error(const char* str) this->ErrorString = ostr.str(); } -void cmExprParserHelper::SetResult(int value) +void cmExprParserHelper::SetResult(KWIML_INT_int64_t value) { this->Result = value; } diff --git a/Source/cmExprParserHelper.h b/Source/cmExprParserHelper.h index dcdaca967d..c3cb53b0a7 100644 --- a/Source/cmExprParserHelper.h +++ b/Source/cmExprParserHelper.h @@ -5,6 +5,8 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cm_kwiml.h" + #include #include @@ -13,7 +15,7 @@ class cmExprParserHelper public: struct ParserType { - int Number; + KWIML_INT_int64_t Number; }; cmExprParserHelper(); @@ -24,9 +26,9 @@ public: int LexInput(char* buf, int maxlen); void Error(const char* str); - void SetResult(int value); + void SetResult(KWIML_INT_int64_t value); - int GetResult() { return this->Result; } + KWIML_INT_int64_t GetResult() { return this->Result; } const char* GetError() { return this->ErrorString.c_str(); } @@ -41,7 +43,7 @@ private: void CleanupParser(); - int Result; + KWIML_INT_int64_t Result; const char* FileName; long FileLine; std::string ErrorString; diff --git a/Source/cmMathCommand.cxx b/Source/cmMathCommand.cxx index c1cd1b6c2a..f0945b2aaf 100644 --- a/Source/cmMathCommand.cxx +++ b/Source/cmMathCommand.cxx @@ -2,10 +2,11 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmMathCommand.h" -#include - #include "cmExprParserHelper.h" #include "cmMakefile.h" +#include "cm_kwiml.h" + +#include class cmExecutionStatus; @@ -44,7 +45,7 @@ bool cmMathCommand::HandleExprCommand(std::vector const& args) } char buffer[1024]; - sprintf(buffer, "%d", helper.GetResult()); + sprintf(buffer, "%" KWIML_INT_PRId64, helper.GetResult()); this->Makefile->AddDefinition(outputVariable, buffer); return true; -- cgit v1.2.1