summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-01-14 20:31:46 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-02-11 21:57:55 (GMT)
commit8910224950a2b723e0d4fd7c21a326af7fb2e050 (patch)
tree09eb05962917fc5f205db31ae06b8c105813617e
parent7b8725bf8472ebf4781ddd60ef8fcca9c3ad98dd (diff)
downloadCMake-8910224950a2b723e0d4fd7c21a326af7fb2e050.zip
CMake-8910224950a2b723e0d4fd7c21a326af7fb2e050.tar.gz
CMake-8910224950a2b723e0d4fd7c21a326af7fb2e050.tar.bz2
Replace common loop pattern with cmJoin
-rw-r--r--Source/cmFindPackageCommand.cxx19
-rw-r--r--Source/cmFunctionCommand.cxx8
-rw-r--r--Source/cmGetCMakePropertyCommand.cxx20
-rw-r--r--Source/cmMacroCommand.cxx9
-rw-r--r--Source/cmMakefile.cxx30
-rw-r--r--Source/cmOptionCommand.cxx6
6 files changed, 11 insertions, 81 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 7746980..fd9b236 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -1064,26 +1064,11 @@ void cmFindPackageCommand::AppendToFoundProperty(bool found)
}
- std::string tmp;
- const char* sep ="";
- for(size_t i=0; i<foundContents.size(); i++)
- {
- tmp += sep;
- tmp += foundContents[i];
- sep = ";";
- }
-
+ std::string tmp = cmJoin(foundContents, ";");
this->Makefile->GetCMakeInstance()->SetProperty("PACKAGES_FOUND",
tmp.c_str());
- tmp = "";
- sep = "";
- for(size_t i=0; i<notFoundContents.size(); i++)
- {
- tmp += sep;
- tmp += notFoundContents[i];
- sep = ";";
- }
+ tmp = cmJoin(notFoundContents, ";");
this->Makefile->GetCMakeInstance()->SetProperty("PACKAGES_NOT_FOUND",
tmp.c_str());
}
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index c33048c..b44e228 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -193,12 +193,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
if (!this->Depth)
{
std::string name = this->Args[0];
- std::vector<std::string>::size_type cc;
- name += "(";
- for ( cc = 0; cc < this->Args.size(); cc ++ )
- {
- name += " " + this->Args[cc];
- }
+ name += "( ";
+ name += cmJoin(this->Args, " ");
name += " )";
// create a new command and add it to cmake
diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx
index c0e4683..84c00ba 100644
--- a/Source/cmGetCMakePropertyCommand.cxx
+++ b/Source/cmGetCMakePropertyCommand.cxx
@@ -34,15 +34,7 @@ bool cmGetCMakePropertyCommand
std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly);
if (!vars.empty())
{
- output = "";
- const char* sep = "";
- std::vector<std::string>::size_type cc;
- for ( cc = 0; cc < vars.size(); ++cc )
- {
- output += sep;
- output += vars[cc];
- sep = ";";
- }
+ output = cmJoin(vars, ";");
}
}
else if ( args[1] == "MACROS" )
@@ -54,15 +46,7 @@ bool cmGetCMakePropertyCommand
const std::set<std::string>* components
= this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
->GetInstallComponents();
- std::set<std::string>::const_iterator compIt;
- output = "";
- const char* sep = "";
- for (compIt = components->begin(); compIt != components->end(); ++compIt)
- {
- output += sep;
- output += *compIt;
- sep = ";";
- }
+ output = cmJoin(*components, ";");
}
else
{
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 81aaf3e..676e082 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -197,14 +197,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
{
argvDef += ";";
}
- const char* sep = "";
- std::vector<std::string>::const_iterator eit;
- for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit)
- {
- argvDef += sep;
- argvDef += *eit;
- sep = ";";
- }
+ argvDef += cmJoin(expandedArgs, ";");
argvDefInitialized = true;
}
cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str());
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index aca4413..ac5fec9 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4202,15 +4202,7 @@ const char *cmMakefile::GetProperty(const std::string& prop,
}
else if (prop == "LISTFILE_STACK")
{
- const char* sep = "";
- for (std::deque<std::string>::const_iterator
- i = this->ListFileStack.begin();
- i != this->ListFileStack.end(); ++i)
- {
- output += sep;
- output += *i;
- sep = ";";
- }
+ output = cmJoin(this->ListFileStack, ";");
return output.c_str();
}
else if (prop == "VARIABLES" || prop == "CACHE_VARIABLES")
@@ -4220,14 +4212,7 @@ const char *cmMakefile::GetProperty(const std::string& prop,
{
cacheonly = 1;
}
- std::vector<std::string> vars = this->GetDefinitions(cacheonly);
- const char* sep = "";
- for (unsigned int cc = 0; cc < vars.size(); cc ++ )
- {
- output += sep;
- output += vars[cc];
- sep = ";";
- }
+ output = cmJoin(this->GetDefinitions(cacheonly), ";");
return output.c_str();
}
else if (prop == "MACROS")
@@ -4242,16 +4227,7 @@ const char *cmMakefile::GetProperty(const std::string& prop,
}
else if (prop == "LINK_DIRECTORIES")
{
- const char* sep = "";
- for (std::vector<std::string>::const_iterator
- it = this->GetLinkDirectories().begin();
- it != this->GetLinkDirectories().end();
- ++ it )
- {
- output += sep;
- output += *it;
- sep = ";";
- }
+ output = cmJoin(this->GetLinkDirectories(), ";");
return output.c_str();
}
else if (prop == "INCLUDE_DIRECTORIES")
diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx
index e505440..60728ea 100644
--- a/Source/cmOptionCommand.cxx
+++ b/Source/cmOptionCommand.cxx
@@ -34,11 +34,7 @@ bool cmOptionCommand
if(argError)
{
std::string m = "called with incorrect number of arguments: ";
- for(size_t i =0; i < args.size(); ++i)
- {
- m += args[i];
- m += " ";
- }
+ m += cmJoin(args, " ");
this->SetError(m);
return false;
}