summaryrefslogtreecommitdiffstats
path: root/Source/cmCommandArgumentParserHelper.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmCommandArgumentParserHelper.cxx')
-rw-r--r--Source/cmCommandArgumentParserHelper.cxx28
1 files changed, 14 insertions, 14 deletions
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index dbeeb07..64b67c9 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;
}
@@ -79,7 +79,7 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
{
if (this->EscapeQuotes)
{
- return this->AddString(cmSystemTools::EscapeQuotes(ptr).c_str());
+ return this->AddString(cmSystemTools::EscapeQuotes(ptr));
}
else
{
@@ -94,7 +94,7 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
{
if(this->EscapeQuotes)
{
- return this->AddString(cmSystemTools::EscapeQuotes(c).c_str());
+ return this->AddString(cmSystemTools::EscapeQuotes(c));
}
else
{
@@ -120,7 +120,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
{
cmOStringStream ostr;
ostr << this->FileLine;
- return this->AddString(ostr.str().c_str());
+ return this->AddString(ostr.str());
}
const char* value = this->Makefile->GetDefinition(var);
if(!value && !this->RemoveEmpty)
@@ -137,23 +137,23 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
this->Makefile->GetHomeOutputDirectory()))
{
cmOStringStream msg;
- cmListFileBacktrace bt;
+ cmListFileBacktrace bt(this->Makefile->GetLocalGenerator());
cmListFileContext lfc;
lfc.FilePath = this->FileName;
lfc.Line = this->FileLine;
bt.push_back(lfc);
msg << "uninitialized variable \'" << var << "\'";
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
- msg.str().c_str(), bt);
+ msg.str(), bt);
}
}
return 0;
}
if (this->EscapeQuotes && value)
{
- return this->AddString(cmSystemTools::EscapeQuotes(value).c_str());
+ return this->AddString(cmSystemTools::EscapeQuotes(value));
}
- 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)
@@ -181,7 +181,7 @@ char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
std::string ref = "@";
ref += var;
ref += "@";
- return this->AddString(ref.c_str());
+ return this->AddString(ref);
}
char* cmCommandArgumentParserHelper::CombineUnions(char* in1, char* in2)
@@ -293,7 +293,7 @@ int cmCommandArgumentParserHelper::ParseString(const char* str, int verb)
if ( Verbose )
{
std::cerr << "Expanding [" << str << "] produced: ["
- << this->Result.c_str() << "]" << std::endl;
+ << this->Result << "]" << std::endl;
}
return 1;
}