cmListCommand: Use std::find algorithm for FIND subcommand.
Use a ostringstream to account for the input being a variable of type size_t as a result of using std::distance. There is no single format string which portably accepts a size_t.
This commit is contained in:
parent
be3d4b665f
commit
1cecd3a531
|
@ -284,19 +284,15 @@ bool cmListCommand::HandleFindCommand(std::vector<std::string> const& args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string>::iterator it;
|
std::vector<std::string>::iterator it =
|
||||||
unsigned int index = 0;
|
std::find(varArgsExpanded.begin(), varArgsExpanded.end(), args[2]);
|
||||||
for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it )
|
if (it != varArgsExpanded.end())
|
||||||
{
|
{
|
||||||
if ( *it == args[2] )
|
std::ostringstream indexStream;
|
||||||
{
|
indexStream << std::distance(varArgsExpanded.begin(), it);
|
||||||
char indexString[32];
|
this->Makefile->AddDefinition(variableName, indexStream.str().c_str());
|
||||||
sprintf(indexString, "%d", index);
|
|
||||||
this->Makefile->AddDefinition(variableName, indexString);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->Makefile->AddDefinition(variableName, "-1");
|
this->Makefile->AddDefinition(variableName, "-1");
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue