summaryrefslogtreecommitdiff
path: root/Source/cmMathCommand.cxx
diff options
context:
space:
mode:
authorMyungJoo Ham <myungjoo.ham@samsung.com>2017-10-11 15:16:57 +0900
committerMyungJoo Ham <myungjoo.ham@samsung.com>2017-10-11 15:16:57 +0900
commit915c76ded744c0f5f151402b9fa69f3fd8452573 (patch)
treeca6a387466543248890f346847acaa8343989b22 /Source/cmMathCommand.cxx
parent317dbdb79761ef65e45c7358cfc7571c6afa54ad (diff)
downloadcmake-915c76ded744c0f5f151402b9fa69f3fd8452573.tar.gz
cmake-915c76ded744c0f5f151402b9fa69f3fd8452573.tar.bz2
cmake-915c76ded744c0f5f151402b9fa69f3fd8452573.zip
Imported Upstream version 3.9.4upstream/3.9.4
Diffstat (limited to 'Source/cmMathCommand.cxx')
-rw-r--r--Source/cmMathCommand.cxx56
1 files changed, 23 insertions, 33 deletions
diff --git a/Source/cmMathCommand.cxx b/Source/cmMathCommand.cxx
index 9fc42659a..c1cd1b6c2 100644
--- a/Source/cmMathCommand.cxx
+++ b/Source/cmMathCommand.cxx
@@ -1,61 +1,51 @@
-/*============================================================================
- CMake - Cross Platform Makefile Generator
- Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-
- Distributed under the OSI-approved BSD License (the "License");
- see accompanying file Copyright.txt for details.
-
- This software is distributed WITHOUT ANY WARRANTY; without even the
- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the License for more information.
-============================================================================*/
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMathCommand.h"
+#include <stdio.h>
+
#include "cmExprParserHelper.h"
+#include "cmMakefile.h"
+
+class cmExecutionStatus;
-//----------------------------------------------------------------------------
-bool cmMathCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmMathCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if ( args.size() < 1 )
- {
+ if (args.empty()) {
this->SetError("must be called with at least one argument.");
return false;
- }
- const std::string &subCommand = args[0];
- if(subCommand == "EXPR")
- {
+ }
+ const std::string& subCommand = args[0];
+ if (subCommand == "EXPR") {
return this->HandleExprCommand(args);
- }
- std::string e = "does not recognize sub-command "+subCommand;
- this->SetError(e.c_str());
+ }
+ std::string e = "does not recognize sub-command " + subCommand;
+ this->SetError(e);
return false;
}
-//----------------------------------------------------------------------------
bool cmMathCommand::HandleExprCommand(std::vector<std::string> const& args)
{
- if ( args.size() != 3 )
- {
+ if (args.size() != 3) {
this->SetError("EXPR called with incorrect arguments.");
return false;
- }
+ }
const std::string& outputVariable = args[1];
const std::string& expression = args[2];
cmExprParserHelper helper;
- if ( !helper.ParseString(expression.c_str(), 0) )
- {
- std::string e = "cannot parse the expression: \""+expression+"\": ";
+ if (!helper.ParseString(expression.c_str(), 0)) {
+ std::string e = "cannot parse the expression: \"" + expression + "\": ";
e += helper.GetError();
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
- }
+ }
char buffer[1024];
sprintf(buffer, "%d", helper.GetResult());
- this->Makefile->AddDefinition(outputVariable.c_str(), buffer);
+ this->Makefile->AddDefinition(outputVariable, buffer);
return true;
}