Convert loops populating maybe-empty content into the common pattern.
This commit is contained in:
parent
7ee56f0399
commit
7b8725bf84
|
@ -254,14 +254,18 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
|
||||||
// expand the variable
|
// expand the variable
|
||||||
std::string listString;
|
std::string listString;
|
||||||
this->GetListString(listString, listName);
|
this->GetListString(listString, listName);
|
||||||
|
|
||||||
|
if(!listString.empty() && !args.empty())
|
||||||
|
{
|
||||||
|
listString += ";";
|
||||||
|
}
|
||||||
|
const char* sep = "";
|
||||||
size_t cc;
|
size_t cc;
|
||||||
for ( cc = 2; cc < args.size(); ++ cc )
|
for ( cc = 2; cc < args.size(); ++ cc )
|
||||||
{
|
{
|
||||||
if(!listString.empty())
|
listString += sep;
|
||||||
{
|
|
||||||
listString += ";";
|
|
||||||
}
|
|
||||||
listString += args[cc];
|
listString += args[cc];
|
||||||
|
sep = ";";
|
||||||
}
|
}
|
||||||
|
|
||||||
this->Makefile->AddDefinition(listName, listString.c_str());
|
this->Makefile->AddDefinition(listName, listString.c_str());
|
||||||
|
|
|
@ -3011,13 +3011,17 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
|
||||||
// trailing slash in the input then the last iteration of the loop
|
// trailing slash in the input then the last iteration of the loop
|
||||||
// will add a slash followed by an empty string which will preserve
|
// will add a slash followed by an empty string which will preserve
|
||||||
// the trailing slash in the output.
|
// the trailing slash in the output.
|
||||||
|
|
||||||
|
if(!relative.empty() && !remote.empty())
|
||||||
|
{
|
||||||
|
relative += "/";
|
||||||
|
}
|
||||||
|
const char* sep = "";
|
||||||
for(unsigned int i=common; i < remote.size(); ++i)
|
for(unsigned int i=common; i < remote.size(); ++i)
|
||||||
{
|
{
|
||||||
if(!relative.empty())
|
relative += sep;
|
||||||
{
|
|
||||||
relative += "/";
|
|
||||||
}
|
|
||||||
relative += remote[i];
|
relative += remote[i];
|
||||||
|
sep = "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally return the path.
|
// Finally return the path.
|
||||||
|
|
|
@ -166,15 +166,17 @@ bool cmMacroHelperCommand::InvokeInitialPass
|
||||||
{
|
{
|
||||||
if (expandedArgs.size() > this->Args.size() - 1)
|
if (expandedArgs.size() > this->Args.size() - 1)
|
||||||
{
|
{
|
||||||
|
if (!argnDef.empty() && !expandedArgs.empty())
|
||||||
|
{
|
||||||
|
argnDef += ";";
|
||||||
|
}
|
||||||
std::vector<std::string>::const_iterator eit
|
std::vector<std::string>::const_iterator eit
|
||||||
= expandedArgs.begin() + (this->Args.size() - 1);
|
= expandedArgs.begin() + (this->Args.size() - 1);
|
||||||
|
const char* sep = "";
|
||||||
for( ; eit != expandedArgs.end(); ++eit)
|
for( ; eit != expandedArgs.end(); ++eit)
|
||||||
{
|
{
|
||||||
if (!argnDef.empty())
|
argnDef += sep + *eit;
|
||||||
{
|
sep = ";";
|
||||||
argnDef += ";";
|
|
||||||
}
|
|
||||||
argnDef += *eit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
argnDefInitialized = true;
|
argnDefInitialized = true;
|
||||||
|
@ -191,14 +193,17 @@ bool cmMacroHelperCommand::InvokeInitialPass
|
||||||
// repleace ARGV, compute it only once
|
// repleace ARGV, compute it only once
|
||||||
if (!argvDefInitialized)
|
if (!argvDefInitialized)
|
||||||
{
|
{
|
||||||
|
if (!argvDef.empty() && !expandedArgs.empty())
|
||||||
|
{
|
||||||
|
argvDef += ";";
|
||||||
|
}
|
||||||
|
const char* sep = "";
|
||||||
std::vector<std::string>::const_iterator eit;
|
std::vector<std::string>::const_iterator eit;
|
||||||
for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit)
|
for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit)
|
||||||
{
|
{
|
||||||
if (!argvDef.empty())
|
argvDef += sep;
|
||||||
{
|
|
||||||
argvDef += ";";
|
|
||||||
}
|
|
||||||
argvDef += *eit;
|
argvDef += *eit;
|
||||||
|
sep = ";";
|
||||||
}
|
}
|
||||||
argvDefInitialized = true;
|
argvDefInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue