BUG: fix bugs in new style list command that handles empty stuff
This commit is contained in:
parent
71bfea5ab7
commit
fd0e8b3a56
|
@ -212,13 +212,12 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args)
|
||||||
|
|
||||||
std::string value;
|
std::string value;
|
||||||
size_t cc;
|
size_t cc;
|
||||||
|
const char* sep = "";
|
||||||
for ( cc = 2; cc < args.size()-1; cc ++ )
|
for ( cc = 2; cc < args.size()-1; cc ++ )
|
||||||
{
|
{
|
||||||
int item = atoi(args[cc].c_str());
|
int item = atoi(args[cc].c_str());
|
||||||
if (value.size())
|
value += sep;
|
||||||
{
|
sep = ";";
|
||||||
value += ";";
|
|
||||||
}
|
|
||||||
size_t nitem = varArgsExpanded.size();
|
size_t nitem = varArgsExpanded.size();
|
||||||
if ( item < 0 )
|
if ( item < 0 )
|
||||||
{
|
{
|
||||||
|
@ -260,12 +259,11 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
|
||||||
std::string listString;
|
std::string listString;
|
||||||
this->GetListString(listString, listName.c_str());
|
this->GetListString(listString, listName.c_str());
|
||||||
size_t cc;
|
size_t cc;
|
||||||
|
const char* sep = "";
|
||||||
for ( cc = 2; cc < args.size(); ++ cc )
|
for ( cc = 2; cc < args.size(); ++ cc )
|
||||||
{
|
{
|
||||||
if ( listString.size() )
|
listString += sep;
|
||||||
{
|
sep = ";";
|
||||||
listString += ";";
|
|
||||||
}
|
|
||||||
listString += args[cc];
|
listString += args[cc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,13 +356,12 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string value;
|
std::string value;
|
||||||
|
const char* sep = "";
|
||||||
for ( cc = 0; cc < varArgsExpanded.size(); cc ++ )
|
for ( cc = 0; cc < varArgsExpanded.size(); cc ++ )
|
||||||
{
|
{
|
||||||
if (value.size())
|
value += sep;
|
||||||
{
|
|
||||||
value += ";";
|
|
||||||
}
|
|
||||||
value += varArgsExpanded[cc];
|
value += varArgsExpanded[cc];
|
||||||
|
sep = ";";
|
||||||
}
|
}
|
||||||
|
|
||||||
this->Makefile->AddDefinition(listName.c_str(), value.c_str());
|
this->Makefile->AddDefinition(listName.c_str(), value.c_str());
|
||||||
|
@ -408,13 +405,12 @@ bool cmListCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string value;
|
std::string value;
|
||||||
|
const char* sep = "";
|
||||||
for ( cc = 0; cc < varArgsExpanded.size(); cc ++ )
|
for ( cc = 0; cc < varArgsExpanded.size(); cc ++ )
|
||||||
{
|
{
|
||||||
if (value.size())
|
value += sep;
|
||||||
{
|
|
||||||
value += ";";
|
|
||||||
}
|
|
||||||
value += varArgsExpanded[cc];
|
value += varArgsExpanded[cc];
|
||||||
|
sep = ";";
|
||||||
}
|
}
|
||||||
|
|
||||||
this->Makefile->AddDefinition(listName.c_str(), value.c_str());
|
this->Makefile->AddDefinition(listName.c_str(), value.c_str());
|
||||||
|
@ -442,13 +438,12 @@ bool cmListCommand
|
||||||
|
|
||||||
std::string value;
|
std::string value;
|
||||||
std::vector<std::string>::reverse_iterator it;
|
std::vector<std::string>::reverse_iterator it;
|
||||||
|
const char* sep = "";
|
||||||
for ( it = varArgsExpanded.rbegin(); it != varArgsExpanded.rend(); ++ it )
|
for ( it = varArgsExpanded.rbegin(); it != varArgsExpanded.rend(); ++ it )
|
||||||
{
|
{
|
||||||
if (value.size())
|
value += sep;
|
||||||
{
|
|
||||||
value += ";";
|
|
||||||
}
|
|
||||||
value += it->c_str();
|
value += it->c_str();
|
||||||
|
sep = ";";
|
||||||
}
|
}
|
||||||
|
|
||||||
this->Makefile->AddDefinition(listName.c_str(), value.c_str());
|
this->Makefile->AddDefinition(listName.c_str(), value.c_str());
|
||||||
|
@ -478,26 +473,10 @@ bool cmListCommand
|
||||||
|
|
||||||
std::string value;
|
std::string value;
|
||||||
|
|
||||||
#if 0
|
|
||||||
// Fast version, but does not keep the ordering
|
|
||||||
|
|
||||||
std::set<std::string> unique(varArgsExpanded.begin(), varArgsExpanded.end());
|
|
||||||
std::set<std::string>::iterator it;
|
|
||||||
for ( it = unique.begin(); it != unique.end(); ++ it )
|
|
||||||
{
|
|
||||||
if (value.size())
|
|
||||||
{
|
|
||||||
value += ";";
|
|
||||||
}
|
|
||||||
value += it->c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// Slower version, keep the ordering
|
|
||||||
|
|
||||||
std::set<std::string> unique;
|
std::set<std::string> unique;
|
||||||
std::vector<std::string>::iterator it;
|
std::vector<std::string>::iterator it;
|
||||||
|
const char* sep = "";
|
||||||
for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it )
|
for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it )
|
||||||
{
|
{
|
||||||
if (unique.find(*it) != unique.end())
|
if (unique.find(*it) != unique.end())
|
||||||
|
@ -505,14 +484,10 @@ bool cmListCommand
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
unique.insert(*it);
|
unique.insert(*it);
|
||||||
|
value += sep;
|
||||||
if (value.size())
|
|
||||||
{
|
|
||||||
value += ";";
|
|
||||||
}
|
|
||||||
value += it->c_str();
|
value += it->c_str();
|
||||||
|
sep = ";";
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
this->Makefile->AddDefinition(listName.c_str(), value.c_str());
|
this->Makefile->AddDefinition(listName.c_str(), value.c_str());
|
||||||
|
@ -542,19 +517,12 @@ bool cmListCommand
|
||||||
|
|
||||||
std::string value;
|
std::string value;
|
||||||
std::vector<std::string>::iterator it;
|
std::vector<std::string>::iterator it;
|
||||||
|
const char* sep = "";
|
||||||
for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it )
|
for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it )
|
||||||
{
|
{
|
||||||
if(value.size() == 0 &&
|
value += sep;
|
||||||
this->Makefile->GetPolicyStatus(cmPolicies::CMP0007) ==
|
|
||||||
cmPolicies::NEW)
|
|
||||||
{
|
|
||||||
value += ";";
|
|
||||||
}
|
|
||||||
if (value.size())
|
|
||||||
{
|
|
||||||
value += ";";
|
|
||||||
}
|
|
||||||
value += it->c_str();
|
value += it->c_str();
|
||||||
|
sep = ";";
|
||||||
}
|
}
|
||||||
|
|
||||||
this->Makefile->AddDefinition(listName.c_str(), value.c_str());
|
this->Makefile->AddDefinition(listName.c_str(), value.c_str());
|
||||||
|
@ -604,6 +572,7 @@ bool cmListCommand::HandleRemoveAtCommand(
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string value;
|
std::string value;
|
||||||
|
const char* sep = "";
|
||||||
for ( cc = 0; cc < varArgsExpanded.size(); ++ cc )
|
for ( cc = 0; cc < varArgsExpanded.size(); ++ cc )
|
||||||
{
|
{
|
||||||
size_t kk;
|
size_t kk;
|
||||||
|
@ -618,11 +587,9 @@ bool cmListCommand::HandleRemoveAtCommand(
|
||||||
|
|
||||||
if ( !found )
|
if ( !found )
|
||||||
{
|
{
|
||||||
if (value.size())
|
value += sep;
|
||||||
{
|
|
||||||
value += ";";
|
|
||||||
}
|
|
||||||
value += varArgsExpanded[cc];
|
value += varArgsExpanded[cc];
|
||||||
|
sep = ";";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue