Use the cmJoin algorithm where possible.

This commit is contained in:
Stephen Kelly 2015-01-07 08:58:51 +01:00
parent 8dc8d756bc
commit 55a73e6b1f
14 changed files with 27 additions and 213 deletions

View File

@ -448,18 +448,7 @@ std::string cmComputeLinkInformation::GetRPathLinkString()
} }
// Construct the linker runtime search path. // Construct the linker runtime search path.
std::string rpath_link; return cmJoin(this->OrderDependentRPath->GetOrderedDirectories(), ":");
const char* sep = "";
std::vector<std::string> const& dirs =
this->OrderDependentRPath->GetOrderedDirectories();
for(std::vector<std::string>::const_iterator di = dirs.begin();
di != dirs.end(); ++di)
{
rpath_link += sep;
sep = ":";
rpath_link += *di;
}
return rpath_link;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -1999,18 +1988,7 @@ std::string cmComputeLinkInformation::GetRPathString(bool for_install)
this->GetRPath(runtimeDirs, for_install); this->GetRPath(runtimeDirs, for_install);
// Concatenate the paths. // Concatenate the paths.
std::string rpath; std::string rpath = cmJoin(runtimeDirs, this->GetRuntimeSep());
const char* sep = "";
for(std::vector<std::string>::const_iterator ri = runtimeDirs.begin();
ri != runtimeDirs.end(); ++ri)
{
// Separate from previous path.
rpath += sep;
sep = this->GetRuntimeSep().c_str();
// Add this path.
rpath += *ri;
}
// If the rpath will be replaced at install time, prepare space. // If the rpath will be replaced at install time, prepare space.
if(!for_install && this->RuntimeUseChrpath) if(!for_install && this->RuntimeUseChrpath)

View File

@ -803,18 +803,9 @@ static const struct JoinNode : public cmGeneratorExpressionNode
const GeneratorExpressionContent *, const GeneratorExpressionContent *,
cmGeneratorExpressionDAGChecker *) const cmGeneratorExpressionDAGChecker *) const
{ {
std::string result;
std::vector<std::string> list; std::vector<std::string> list;
cmSystemTools::ExpandListArgument(parameters.front(), list); cmSystemTools::ExpandListArgument(parameters.front(), list);
std::string sep; return cmJoin(list, parameters[1]);
for(std::vector<std::string>::const_iterator li = list.begin();
li != list.end(); ++li)
{
result += sep + *li;
sep = parameters[1];
}
return result;
} }
} joinNode; } joinNode;

View File

@ -777,18 +777,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
this->Makefile->GetLocalGenerator()->GetGlobalGenerator() this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
->GetExportSets()[exports.GetString()]->AddTargetExport(te); ->GetExportSets()[exports.GetString()]->AddTargetExport(te);
std::vector<std::string> dirs = includesArgs.GetIncludeDirs(); te->InterfaceIncludeDirectories =
if(!dirs.empty()) cmJoin(includesArgs.GetIncludeDirs(), ";");
{
const char *sep = "";
for (std::vector<std::string>::const_iterator it = dirs.begin();
it != dirs.end(); ++it)
{
te->InterfaceIncludeDirectories += sep;
te->InterfaceIncludeDirectories += *it;
sep = ";";
}
}
} }
} }

View File

@ -353,15 +353,7 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
cnt ++; cnt ++;
} }
std::string value; std::string value = cmJoin(varArgsExpanded, ";");
const char* sep = "";
for ( cc = 0; cc < varArgsExpanded.size(); cc ++ )
{
value += sep;
value += varArgsExpanded[cc];
sep = ";";
}
this->Makefile->AddDefinition(listName, value.c_str()); this->Makefile->AddDefinition(listName, value.c_str());
return true; return true;
} }
@ -402,15 +394,8 @@ bool cmListCommand
} }
} }
std::string value;
const char* sep = "";
for ( cc = 0; cc < varArgsExpanded.size(); cc ++ )
{
value += sep;
value += varArgsExpanded[cc];
sep = ";";
}
std::string value = cmJoin(varArgsExpanded, ";");
this->Makefile->AddDefinition(listName, value.c_str()); this->Makefile->AddDefinition(listName, value.c_str());
return true; return true;
} }
@ -518,16 +503,7 @@ bool cmListCommand
std::sort(varArgsExpanded.begin(), varArgsExpanded.end()); std::sort(varArgsExpanded.begin(), varArgsExpanded.end());
std::string value; std::string value = cmJoin(varArgsExpanded, ";");
std::vector<std::string>::iterator it;
const char* sep = "";
for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it )
{
value += sep;
value += it->c_str();
sep = ";";
}
this->Makefile->AddDefinition(listName, value.c_str()); this->Makefile->AddDefinition(listName, value.c_str());
return true; return true;
} }

View File

@ -1791,22 +1791,12 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs,
return; return;
} }
std::string incString;
std::string sep;
for(std::vector<std::string>::const_iterator li = incs.begin();
li != incs.end(); ++li)
{
incString += sep + *li;
sep = ";";
}
std::vector<cmValueWithOrigin>::iterator position = std::vector<cmValueWithOrigin>::iterator position =
before ? this->IncludeDirectoriesEntries.begin() before ? this->IncludeDirectoriesEntries.begin()
: this->IncludeDirectoriesEntries.end(); : this->IncludeDirectoriesEntries.end();
cmListFileBacktrace lfbt = this->GetBacktrace(); cmListFileBacktrace lfbt = this->GetBacktrace();
cmValueWithOrigin entry(incString, lfbt); cmValueWithOrigin entry(cmJoin(incs, ";"), lfbt);
this->IncludeDirectoriesEntries.insert(position, entry); this->IncludeDirectoriesEntries.insert(position, entry);
// Property on each target: // Property on each target:

View File

@ -224,16 +224,7 @@ std::string cmQtAutoGenerators::ListQt5RccInputs(cmSourceFile* sf,
} }
} }
depends.insert(depends.end(), qrcEntries.begin(), qrcEntries.end()); depends.insert(depends.end(), qrcEntries.begin(), qrcEntries.end());
std::string entriesList; return cmJoin(qrcEntries, "@list_sep@");
const char* sep = "";
for(std::vector<std::string>::const_iterator it = qrcEntries.begin();
it != qrcEntries.end(); ++it)
{
entriesList += sep;
entriesList += *it;
sep = "@list_sep@";
}
return entriesList;
} }
std::string cmQtAutoGenerators::ListQt4RccInputs(cmSourceFile* sf, std::string cmQtAutoGenerators::ListQt4RccInputs(cmSourceFile* sf,
@ -512,29 +503,13 @@ static void GetCompileDefinitionsAndDirectories(cmTarget const* target,
// Get the include dirs for this target, without stripping the implicit // Get the include dirs for this target, without stripping the implicit
// include dirs off, see http://public.kitware.com/Bug/view.php?id=13667 // include dirs off, see http://public.kitware.com/Bug/view.php?id=13667
localGen->GetIncludeDirectories(includeDirs, gtgt, "CXX", config, false); localGen->GetIncludeDirectories(includeDirs, gtgt, "CXX", config, false);
const char* sep = "";
incs = ""; incs = cmJoin(includeDirs, ";");
for(std::vector<std::string>::const_iterator incDirIt = includeDirs.begin();
incDirIt != includeDirs.end();
++incDirIt)
{
incs += sep;
sep = ";";
incs += *incDirIt;
}
std::set<std::string> defines; std::set<std::string> defines;
localGen->AddCompileDefinitions(defines, target, config); localGen->AddCompileDefinitions(defines, target, config);
sep = ""; defs += cmJoin(defines, ";");
for(std::set<std::string>::const_iterator defIt = defines.begin();
defIt != defines.end();
++defIt)
{
defs += sep;
sep = ";";
defs += *defIt;
}
} }
void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
@ -879,16 +854,7 @@ static void GetUicOpts(cmTarget const* target, const std::string& config,
{ {
std::vector<std::string> opts; std::vector<std::string> opts;
target->GetAutoUicOptions(opts, config); target->GetAutoUicOptions(opts, config);
optString = cmJoin(opts, ";");
const char* sep = "";
for(std::vector<std::string>::const_iterator optIt = opts.begin();
optIt != opts.end();
++optIt)
{
optString += sep;
sep = ";";
optString += *optIt;
}
} }
void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,

View File

@ -417,14 +417,7 @@ void cmRST::ProcessDirectiveReplace()
{ {
// Record markup lines as replacement text. // Record markup lines as replacement text.
std::string& replacement = this->Replace[this->ReplaceName]; std::string& replacement = this->Replace[this->ReplaceName];
const char* sep = ""; replacement += cmJoin(this->MarkupLines, " ");
for(std::vector<std::string>::iterator i = this->MarkupLines.begin();
i != this->MarkupLines.end(); ++i)
{
replacement += sep;
replacement += *i;
sep = " ";
}
this->ReplaceName = ""; this->ReplaceName = "";
} }

View File

@ -828,18 +828,12 @@ bool cmSystemTools::RunSingleCommand(
std::string std::string
cmSystemTools::PrintSingleCommand(std::vector<std::string> const& command) cmSystemTools::PrintSingleCommand(std::vector<std::string> const& command)
{ {
std::string commandStr; if (command.empty())
const char* sep = "";
for(std::vector<std::string>::const_iterator i = command.begin();
i != command.end(); ++i)
{ {
commandStr += sep; return std::string();
commandStr += "\"";
commandStr += *i;
commandStr += "\"";
sep = " ";
} }
return commandStr;
return "\"" + cmJoin(command, "\" \"") + "\"";
} }
bool cmSystemTools::DoesFileExistWithExtensions( bool cmSystemTools::DoesFileExistWithExtensions(

View File

@ -923,16 +923,7 @@ void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::AddTracedSources(std::vector<std::string> const& srcs) void cmTarget::AddTracedSources(std::vector<std::string> const& srcs)
{ {
std::string srcFiles; std::string srcFiles = cmJoin(srcs, ";");
const char* sep = "";
for(std::vector<std::string>::const_iterator i = srcs.begin();
i != srcs.end(); ++i)
{
std::string filename = *i;
srcFiles += sep;
srcFiles += filename;
sep = ";";
}
if (!srcFiles.empty()) if (!srcFiles.empty())
{ {
this->Internal->SourceFilesMap.clear(); this->Internal->SourceFilesMap.clear();
@ -6088,24 +6079,8 @@ cmTargetInternals::ComputeLinkInterfaceLibraries(
} }
if (ifaceLibs != iface.Libraries) if (ifaceLibs != iface.Libraries)
{ {
std::string oldLibraries; std::string oldLibraries = cmJoin(impl->Libraries, ";");
std::string newLibraries; std::string newLibraries = cmJoin(ifaceLibs, ";");
const char *sep = "";
for(std::vector<cmLinkImplItem>::const_iterator it
= impl->Libraries.begin(); it != impl->Libraries.end(); ++it)
{
oldLibraries += sep;
oldLibraries += *it;
sep = ";";
}
sep = "";
for(std::vector<cmLinkItem>::const_iterator it
= ifaceLibs.begin(); it != ifaceLibs.end(); ++it)
{
newLibraries += sep;
newLibraries += *it;
sep = ";";
}
if(oldLibraries.empty()) if(oldLibraries.empty())
{ oldLibraries = "(empty)"; } { oldLibraries = "(empty)"; }
if(newLibraries.empty()) if(newLibraries.empty())

View File

@ -40,15 +40,7 @@ void cmTargetCompileFeaturesCommand
std::string cmTargetCompileFeaturesCommand std::string cmTargetCompileFeaturesCommand
::Join(const std::vector<std::string> &content) ::Join(const std::vector<std::string> &content)
{ {
std::string defs; return cmJoin(content, ";");
std::string sep;
for(std::vector<std::string>::const_iterator it = content.begin();
it != content.end(); ++it)
{
defs += sep + *it;
sep = ";";
}
return defs;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -39,15 +39,7 @@ void cmTargetCompileOptionsCommand
std::string cmTargetCompileOptionsCommand std::string cmTargetCompileOptionsCommand
::Join(const std::vector<std::string> &content) ::Join(const std::vector<std::string> &content)
{ {
std::string defs; return cmJoin(content, ";");
std::string sep;
for(std::vector<std::string>::const_iterator it = content.begin();
it != content.end(); ++it)
{
defs += sep + *it;
sep = ";";
}
return defs;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -91,15 +91,7 @@ void cmTargetIncludeDirectoriesCommand
if (system) if (system)
{ {
std::string joined; std::string joined = cmJoin(content, ";");
std::string sep;
for(std::vector<std::string>::const_iterator it = content.begin();
it != content.end(); ++it)
{
joined += sep;
sep = ";";
joined += *it;
}
tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
joined.c_str()); joined.c_str());
} }

View File

@ -44,15 +44,7 @@ void cmTargetSourcesCommand
std::string cmTargetSourcesCommand std::string cmTargetSourcesCommand
::Join(const std::vector<std::string> &content) ::Join(const std::vector<std::string> &content)
{ {
std::string srcs; return cmJoin(content, ";");
std::string sep;
for(std::vector<std::string>::const_iterator it = content.begin();
it != content.end(); ++it)
{
srcs += sep + *it;
sep = ";";
}
return srcs;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -2320,14 +2320,7 @@ const char *cmake::GetProperty(const std::string& prop,
{ {
std::vector<std::string> enLangs; std::vector<std::string> enLangs;
this->GlobalGenerator->GetEnabledLanguages(enLangs); this->GlobalGenerator->GetEnabledLanguages(enLangs);
const char* sep = ""; lang = cmJoin(enLangs, ";");
for(std::vector<std::string>::iterator i = enLangs.begin();
i != enLangs.end(); ++i)
{
lang += sep;
sep = ";";
lang += *i;
}
} }
this->SetProperty("ENABLED_LANGUAGES", lang.c_str()); this->SetProperty("ENABLED_LANGUAGES", lang.c_str());
} }