summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-01-17 16:36:19 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-02-11 21:57:53 (GMT)
commit7b8725bf8472ebf4781ddd60ef8fcca9c3ad98dd (patch)
treec7f440ea9c81f49b066c9dd196ce705d288558d4
parent7ee56f03999e8605cc2cbe85a3a7b7159e639e5d (diff)
downloadCMake-7b8725bf8472ebf4781ddd60ef8fcca9c3ad98dd.zip
CMake-7b8725bf8472ebf4781ddd60ef8fcca9c3ad98dd.tar.gz
CMake-7b8725bf8472ebf4781ddd60ef8fcca9c3ad98dd.tar.bz2
Convert loops populating maybe-empty content into the common pattern.
-rw-r--r--Source/cmListCommand.cxx12
-rw-r--r--Source/cmLocalGenerator.cxx12
-rw-r--r--Source/cmMacroCommand.cxx23
3 files changed, 30 insertions, 17 deletions
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index 107dca9..8d1657d 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -254,14 +254,18 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
// expand the variable
std::string listString;
this->GetListString(listString, listName);
+
+ if(!listString.empty() && !args.empty())
+ {
+ listString += ";";
+ }
+ const char* sep = "";
size_t cc;
for ( cc = 2; cc < args.size(); ++ cc )
{
- if(!listString.empty())
- {
- listString += ";";
- }
+ listString += sep;
listString += args[cc];
+ sep = ";";
}
this->Makefile->AddDefinition(listName, listString.c_str());
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 7afe05f..05d8ab5 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -3011,13 +3011,17 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
// trailing slash in the input then the last iteration of the loop
// will add a slash followed by an empty string which will preserve
// the trailing slash in the output.
+
+ if(!relative.empty() && !remote.empty())
+ {
+ relative += "/";
+ }
+ const char* sep = "";
for(unsigned int i=common; i < remote.size(); ++i)
{
- if(!relative.empty())
- {
- relative += "/";
- }
+ relative += sep;
relative += remote[i];
+ sep = "/";
}
// Finally return the path.
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 657e750..81aaf3e 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -166,15 +166,17 @@ bool cmMacroHelperCommand::InvokeInitialPass
{
if (expandedArgs.size() > this->Args.size() - 1)
{
+ if (!argnDef.empty() && !expandedArgs.empty())
+ {
+ argnDef += ";";
+ }
std::vector<std::string>::const_iterator eit
= expandedArgs.begin() + (this->Args.size() - 1);
+ const char* sep = "";
for( ; eit != expandedArgs.end(); ++eit)
{
- if (!argnDef.empty())
- {
- argnDef += ";";
- }
- argnDef += *eit;
+ argnDef += sep + *eit;
+ sep = ";";
}
}
argnDefInitialized = true;
@@ -191,14 +193,17 @@ bool cmMacroHelperCommand::InvokeInitialPass
// repleace ARGV, compute it only once
if (!argvDefInitialized)
{
+ if (!argvDef.empty() && !expandedArgs.empty())
+ {
+ argvDef += ";";
+ }
+ const char* sep = "";
std::vector<std::string>::const_iterator eit;
for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit)
{
- if (!argvDef.empty())
- {
- argvDef += ";";
- }
+ argvDef += sep;
argvDef += *eit;
+ sep = ";";
}
argvDefInitialized = true;
}