summaryrefslogtreecommitdiffstats
path: root/Source/cmUnsetCommand.cxx
diff options
context:
space:
mode:
authorMatthias Maennich <matthias@maennich.net>2017-10-05 11:12:00 (GMT)
committerBrad King <brad.king@kitware.com>2017-10-10 17:28:39 (GMT)
commit5731f6d5b1986a7ee13e83ff73971a9f44e0229a (patch)
tree0049b2dbabb259bd4c6be5f697ac7760806b7a00 /Source/cmUnsetCommand.cxx
parentcb8f26f199e18be231f40f523bfe64375e749e35 (diff)
downloadCMake-5731f6d5b1986a7ee13e83ff73971a9f44e0229a.zip
CMake-5731f6d5b1986a7ee13e83ff73971a9f44e0229a.tar.gz
CMake-5731f6d5b1986a7ee13e83ff73971a9f44e0229a.tar.bz2
cm{Unset,Set}Command: use std::string to determine the env variable name
Diffstat (limited to 'Source/cmUnsetCommand.cxx')
-rw-r--r--Source/cmUnsetCommand.cxx13
1 files changed, 4 insertions, 9 deletions
diff --git a/Source/cmUnsetCommand.cxx b/Source/cmUnsetCommand.cxx
index 18bbdd7..cfaa1fd2 100644
--- a/Source/cmUnsetCommand.cxx
+++ b/Source/cmUnsetCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmUnsetCommand.h"
-#include <string.h>
-
#include "cmAlgorithms.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
@@ -19,19 +17,16 @@ bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args,
return false;
}
- const char* variable = args[0].c_str();
+ auto const& variable = args[0];
// unset(ENV{VAR})
- if (cmHasLiteralPrefix(variable, "ENV{") && strlen(variable) > 5) {
+ if (cmHasLiteralPrefix(variable, "ENV{") && variable.size() > 5) {
// what is the variable name
- char* envVarName = new char[strlen(variable)];
- strncpy(envVarName, variable + 4, strlen(variable) - 5);
- envVarName[strlen(variable) - 5] = '\0';
+ auto const& envVarName = variable.substr(4, variable.size() - 5);
#ifdef CMAKE_BUILD_WITH_CMAKE
- cmSystemTools::UnsetEnv(envVarName);
+ cmSystemTools::UnsetEnv(envVarName.c_str());
#endif
- delete[] envVarName;
return true;
}
// unset(VAR)