diff options
Diffstat (limited to 'Source/cmSetCommand.cxx')
-rw-r--r-- | Source/cmSetCommand.cxx | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 820e7f6..985aac8 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmSetCommand.h" -#include <string.h> - #include "cmAlgorithms.h" #include "cmMakefile.h" #include "cmState.h" @@ -22,19 +20,15 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, } // watch for ENV signatures - const char* variable = args[0].c_str(); // VAR is always first - if (cmHasLiteralPrefix(variable, "ENV{") && strlen(variable) > 5) { + auto const& variable = args[0]; // VAR is always first + if (cmHasLiteralPrefix(variable, "ENV{") && variable.size() > 5) { // what is the variable name - char* varName = new char[strlen(variable)]; - strncpy(varName, variable + 4, strlen(variable) - 5); - varName[strlen(variable) - 5] = '\0'; - std::string putEnvArg = varName; - putEnvArg += "="; + auto const& varName = variable.substr(4, variable.size() - 5); + std::string putEnvArg = varName + "="; // what is the current value if any std::string currValue; const bool currValueSet = cmSystemTools::GetEnv(varName, currValue); - delete[] varName; // will it be set to something, then set it if (args.size() > 1 && !args[1].empty()) { @@ -61,7 +55,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, // SET (VAR PARENT_SCOPE) // Removes the definition of VAR // in the parent scope. if (args.size() == 2 && args[args.size() - 1] == "PARENT_SCOPE") { - this->Makefile->RaiseScope(variable, CM_NULLPTR); + this->Makefile->RaiseScope(variable, nullptr); return true; } @@ -75,8 +69,8 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, bool force = false; // optional bool parentScope = false; cmStateEnums::CacheEntryType type = - cmStateEnums::STRING; // required if cache - const char* docstring = CM_NULLPTR; // required if cache + cmStateEnums::STRING; // required if cache + const char* docstring = nullptr; // required if cache unsigned int ignoreLastArgs = 0; // look for PARENT_SCOPE argument |