summaryrefslogtreecommitdiffstats
path: root/Source/cmCommandArgumentParserHelper.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2014-02-04 02:16:12 (GMT)
committerBrad King <brad.king@kitware.com>2014-03-08 18:05:30 (GMT)
commitb26c70cc9a59de5b8ece8b00b67d571aaf6ee8f0 (patch)
tree3990d8f7bd5ea1db0a2dc0b09eb1d1c489ab6c8d /Source/cmCommandArgumentParserHelper.cxx
parent9f48d3bac22118fc1dddbf1eec6da4cb24c585c4 (diff)
downloadCMake-b26c70cc9a59de5b8ece8b00b67d571aaf6ee8f0.zip
CMake-b26c70cc9a59de5b8ece8b00b67d571aaf6ee8f0.tar.gz
CMake-b26c70cc9a59de5b8ece8b00b67d571aaf6ee8f0.tar.bz2
stringapi: Use strings for AddString methods
It gets turned into a string anyways, so pass them in.
Diffstat (limited to 'Source/cmCommandArgumentParserHelper.cxx')
-rw-r--r--Source/cmCommandArgumentParserHelper.cxx12
1 files changed, 6 insertions, 6 deletions
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index dbeeb07..6284cb7 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -49,14 +49,14 @@ void cmCommandArgumentParserHelper::SetLineFile(long line, const char* file)
this->FileName = file;
}
-char* cmCommandArgumentParserHelper::AddString(const char* str)
+char* cmCommandArgumentParserHelper::AddString(const std::string& str)
{
- if ( !str || !*str )
+ if ( str.empty() )
{
return this->EmptyVariable;
}
- char* stVal = new char[strlen(str)+1];
- strcpy(stVal, str);
+ char* stVal = new char[str.size()+1];
+ strcpy(stVal, str.c_str());
this->Variables.push_back(stVal);
return stVal;
}
@@ -153,7 +153,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
{
return this->AddString(cmSystemTools::EscapeQuotes(value).c_str());
}
- return this->AddString(value);
+ return this->AddString(value ? value : "");
}
char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
@@ -166,7 +166,7 @@ char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
// then return an empty string
if(!ret && this->RemoveEmpty)
{
- return this->AddString(ret);
+ return this->AddString("");
}
// if the ret was not 0, then return it
if(ret)