1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-17 07:11:52 +08:00

math: Use 64-bit integer type for computation

This commit is contained in:
Daniel Franke
2018-05-18 21:59:46 +02:00
committed by Brad King
parent 963b8d9f6c
commit 5b0f73a15a
3 changed files with 12 additions and 8 deletions

View File

@@ -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;
}

View File

@@ -5,6 +5,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include "cm_kwiml.h"
#include <string>
#include <vector>
@@ -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;

View File

@@ -2,10 +2,11 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMathCommand.h"
#include <stdio.h>
#include "cmExprParserHelper.h"
#include "cmMakefile.h"
#include "cm_kwiml.h"
#include <stdio.h>
class cmExecutionStatus;
@@ -44,7 +45,7 @@ bool cmMathCommand::HandleExprCommand(std::vector<std::string> const& args)
}
char buffer[1024];
sprintf(buffer, "%d", helper.GetResult());
sprintf(buffer, "%" KWIML_INT_PRId64, helper.GetResult());
this->Makefile->AddDefinition(outputVariable, buffer);
return true;