summaryrefslogtreecommitdiffstats
path: root/Source/cmListCommand.cxx
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-08-15 14:26:50 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-08-15 14:26:50 (GMT)
commit2f23ecdb8aa5bc1a86158df551f5649c439c7c52 (patch)
treede39decb56efe7120c4e65d4012d829e95de3f66 /Source/cmListCommand.cxx
parent58b0e317847994fdce6371605161ddac70a02eb3 (diff)
downloadCMake-2f23ecdb8aa5bc1a86158df551f5649c439c7c52.zip
CMake-2f23ecdb8aa5bc1a86158df551f5649c439c7c52.tar.gz
CMake-2f23ecdb8aa5bc1a86158df551f5649c439c7c52.tar.bz2
ENH: change LIST(CONTAINS ...) TO LIST(FIND ...), which returns the index
and which is more useful, because then you can also access the item behind the one you were looking, useful for writing macros with optional keywords with parameters Alex
Diffstat (limited to 'Source/cmListCommand.cxx')
-rw-r--r--Source/cmListCommand.cxx18
1 files changed, 11 insertions, 7 deletions
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index f0df03b..c00f6eb 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -42,9 +42,9 @@ bool cmListCommand::InitialPass(std::vector<std::string> const& args)
{
return this->HandleAppendCommand(args);
}
- if(subCommand == "CONTAINS")
+ if(subCommand == "FIND")
{
- return this->HandleContainsCommand(args);
+ return this->HandleFindCommand(args);
}
if(subCommand == "INSERT")
{
@@ -204,11 +204,11 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
}
//----------------------------------------------------------------------------
-bool cmListCommand::HandleContainsCommand(std::vector<std::string> const& args)
+bool cmListCommand::HandleFindCommand(std::vector<std::string> const& args)
{
if(args.size() != 4)
{
- this->SetError("sub-command CONTAINS requires three arguments.");
+ this->SetError("sub-command FIND requires three arguments.");
return false;
}
@@ -218,21 +218,25 @@ bool cmListCommand::HandleContainsCommand(std::vector<std::string> const& args)
std::vector<std::string> varArgsExpanded;
if ( !this->GetList(varArgsExpanded, listName.c_str()) )
{
- this->Makefile->AddDefinition(variableName.c_str(), "FALSE");
+ this->Makefile->AddDefinition(variableName.c_str(), "-1");
return true;
}
std::vector<std::string>::iterator it;
+ unsigned int index = 0;
for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it )
{
if ( *it == args[2] )
{
- this->Makefile->AddDefinition(variableName.c_str(), "TRUE");
+ char indexString[32];
+ sprintf(indexString, "%d", index);
+ this->Makefile->AddDefinition(variableName.c_str(), indexString);
return true;
}
+ index++;
}
- this->Makefile->AddDefinition(variableName.c_str(), "FALSE");
+ this->Makefile->AddDefinition(variableName.c_str(), "-1");
return true;
}