|
|
@@ -104,19 +104,8 @@ bool cmListCommand::GetList(std::vector<std::string>& list,
|
|
|
}
|
|
|
// expand the variable into a list
|
|
|
cmSystemTools::ExpandListArgument(listString, list, true);
|
|
|
- // check the list for empty values
|
|
|
- bool hasEmpty = false;
|
|
|
- for(std::vector<std::string>::iterator i = list.begin();
|
|
|
- i != list.end(); ++i)
|
|
|
- {
|
|
|
- if(i->empty())
|
|
|
- {
|
|
|
- hasEmpty = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
// if no empty elements then just return
|
|
|
- if(!hasEmpty)
|
|
|
+ if (std::find(list.begin(), list.end(), std::string()) == list.end())
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
@@ -284,18 +273,14 @@ bool cmListCommand::HandleFindCommand(std::vector<std::string> const& args)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- std::vector<std::string>::iterator it;
|
|
|
- unsigned int index = 0;
|
|
|
- for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it )
|
|
|
+ std::vector<std::string>::iterator it =
|
|
|
+ std::find(varArgsExpanded.begin(), varArgsExpanded.end(), args[2]);
|
|
|
+ if (it != varArgsExpanded.end())
|
|
|
{
|
|
|
- if ( *it == args[2] )
|
|
|
- {
|
|
|
- char indexString[32];
|
|
|
- sprintf(indexString, "%d", index);
|
|
|
- this->Makefile->AddDefinition(variableName, indexString);
|
|
|
- return true;
|
|
|
- }
|
|
|
- index++;
|
|
|
+ std::ostringstream indexStream;
|
|
|
+ indexStream << std::distance(varArgsExpanded.begin(), it);
|
|
|
+ this->Makefile->AddDefinition(variableName, indexStream.str().c_str());
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
this->Makefile->AddDefinition(variableName, "-1");
|
|
|
@@ -370,25 +355,16 @@ bool cmListCommand
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- size_t cc;
|
|
|
- for ( cc = 2; cc < args.size(); ++ cc )
|
|
|
- {
|
|
|
- size_t kk = 0;
|
|
|
- while ( kk < varArgsExpanded.size() )
|
|
|
- {
|
|
|
- if ( varArgsExpanded[kk] == args[cc] )
|
|
|
- {
|
|
|
- varArgsExpanded.erase(varArgsExpanded.begin()+kk);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- kk ++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ std::vector<std::string> remove(args.begin() + 2, args.end());
|
|
|
+ std::sort(remove.begin(), remove.end());
|
|
|
+ std::vector<std::string>::const_iterator remEnd =
|
|
|
+ std::unique(remove.begin(), remove.end());
|
|
|
+ std::vector<std::string>::const_iterator remBegin = remove.begin();
|
|
|
|
|
|
-
|
|
|
- std::string value = cmJoin(varArgsExpanded, ";");
|
|
|
+ std::vector<std::string>::const_iterator argsEnd =
|
|
|
+ cmRemoveMatching(varArgsExpanded, cmRange(remBegin, remEnd));
|
|
|
+ std::vector<std::string>::const_iterator argsBegin = varArgsExpanded.begin();
|
|
|
+ std::string value = cmJoin(cmRange(argsBegin, argsEnd), ";");
|
|
|
this->Makefile->AddDefinition(listName, value.c_str());
|
|
|
return true;
|
|
|
}
|
|
|
@@ -414,15 +390,8 @@ bool cmListCommand
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- std::string value;
|
|
|
- std::vector<std::string>::reverse_iterator it;
|
|
|
- const char* sep = "";
|
|
|
- for ( it = varArgsExpanded.rbegin(); it != varArgsExpanded.rend(); ++ it )
|
|
|
- {
|
|
|
- value += sep;
|
|
|
- value += it->c_str();
|
|
|
- sep = ";";
|
|
|
- }
|
|
|
+ std::reverse(varArgsExpanded.begin(), varArgsExpanded.end());
|
|
|
+ std::string value = cmJoin(varArgsExpanded, ";");
|
|
|
|
|
|
this->Makefile->AddDefinition(listName, value.c_str());
|
|
|
return true;
|
|
|
@@ -450,24 +419,11 @@ bool cmListCommand
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- std::string value;
|
|
|
-
|
|
|
-
|
|
|
- std::set<std::string> unique;
|
|
|
- std::vector<std::string>::iterator it;
|
|
|
- const char* sep = "";
|
|
|
- for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it )
|
|
|
- {
|
|
|
- if (unique.find(*it) != unique.end())
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- unique.insert(*it);
|
|
|
- value += sep;
|
|
|
- value += it->c_str();
|
|
|
- sep = ";";
|
|
|
- }
|
|
|
-
|
|
|
+ std::vector<std::string>::const_iterator argsEnd =
|
|
|
+ cmRemoveDuplicates(varArgsExpanded);
|
|
|
+ std::vector<std::string>::const_iterator argsBegin =
|
|
|
+ varArgsExpanded.begin();
|
|
|
+ std::string value = cmJoin(cmRange(argsBegin, argsEnd), ";");
|
|
|
|
|
|
this->Makefile->AddDefinition(listName, value.c_str());
|
|
|
return true;
|
|
|
@@ -549,27 +505,15 @@ bool cmListCommand::HandleRemoveAtCommand(
|
|
|
removed.push_back(static_cast<size_t>(item));
|
|
|
}
|
|
|
|
|
|
- std::string value;
|
|
|
- const char* sep = "";
|
|
|
- for ( cc = 0; cc < varArgsExpanded.size(); ++ cc )
|
|
|
- {
|
|
|
- size_t kk;
|
|
|
- bool found = false;
|
|
|
- for ( kk = 0; kk < removed.size(); ++ kk )
|
|
|
- {
|
|
|
- if ( cc == removed[kk] )
|
|
|
- {
|
|
|
- found = true;
|
|
|
- }
|
|
|
- }
|
|
|
+ std::sort(removed.begin(), removed.end());
|
|
|
+ std::vector<size_t>::const_iterator remEnd =
|
|
|
+ std::unique(removed.begin(), removed.end());
|
|
|
+ std::vector<size_t>::const_iterator remBegin = removed.begin();
|
|
|
|
|
|
- if ( !found )
|
|
|
- {
|
|
|
- value += sep;
|
|
|
- value += varArgsExpanded[cc];
|
|
|
- sep = ";";
|
|
|
- }
|
|
|
- }
|
|
|
+ std::vector<std::string>::const_iterator argsEnd =
|
|
|
+ cmRemoveIndices(varArgsExpanded, cmRange(remBegin, remEnd));
|
|
|
+ std::vector<std::string>::const_iterator argsBegin = varArgsExpanded.begin();
|
|
|
+ std::string value = cmJoin(cmRange(argsBegin, argsEnd), ";");
|
|
|
|
|
|
this->Makefile->AddDefinition(listName, value.c_str());
|
|
|
return true;
|