list command: error on too many arguments

SORT, REVERSE, and REMOVE_DUPLICATES can only operate on exactly one argument.
Until now all other arguments were silently ignored. Give an error instead.
This commit is contained in:
Rolf Eike Beer 2012-08-15 22:12:12 +02:00
parent addefc2ae3
commit 52d9c38e72
1 changed files with 18 additions and 0 deletions

View File

@ -429,6 +429,12 @@ bool cmListCommand
this->SetError("sub-command REVERSE requires a list as an argument."); this->SetError("sub-command REVERSE requires a list as an argument.");
return false; return false;
} }
else if(args.size() > 2)
{
this->SetError(
"sub-command REVERSE only takes one argument.");
return false;
}
const std::string& listName = args[1]; const std::string& listName = args[1];
// expand the variable // expand the variable
@ -463,6 +469,12 @@ bool cmListCommand
"sub-command REMOVE_DUPLICATES requires a list as an argument."); "sub-command REMOVE_DUPLICATES requires a list as an argument.");
return false; return false;
} }
else if(args.size() > 2)
{
this->SetError(
"sub-command REMOVE_DUPLICATES only takes one argument.");
return false;
}
const std::string& listName = args[1]; const std::string& listName = args[1];
// expand the variable // expand the variable
@ -506,6 +518,12 @@ bool cmListCommand
this->SetError("sub-command SORT requires a list as an argument."); this->SetError("sub-command SORT requires a list as an argument.");
return false; return false;
} }
else if(args.size() > 2)
{
this->SetError(
"sub-command SORT only takes one argument.");
return false;
}
const std::string& listName = args[1]; const std::string& listName = args[1];
// expand the variable // expand the variable