diff options
Diffstat (limited to 'Source/cmListCommand.cxx')
-rw-r--r-- | Source/cmListCommand.cxx | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index dd0cfa9..ae13fdf 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -284,18 +284,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"); |