diff options
author | Petr Kmoch <petr.kmoch@gmail.com> | 2012-09-29 13:41:29 (GMT) |
---|---|---|
committer | Rolf Eike Beer <eike@sf-mail.de> | 2012-11-02 16:09:55 (GMT) |
commit | 07251a8ea5322f957adfcbb2fffb6c5ca121418c (patch) | |
tree | f2487f6f023d71afdf7596979e34a7ed24411722 /Source/cmListCommand.cxx | |
parent | 1b078c304db63eb6cd46fe0f22988f8241a389b2 (diff) | |
download | CMake-07251a8ea5322f957adfcbb2fffb6c5ca121418c.zip CMake-07251a8ea5322f957adfcbb2fffb6c5ca121418c.tar.gz CMake-07251a8ea5322f957adfcbb2fffb6c5ca121418c.tar.bz2 |
Consolidate list() argument count testing
Move test for list() argument count >= 2 to InitialPass().
Diffstat (limited to 'Source/cmListCommand.cxx')
-rw-r--r-- | Source/cmListCommand.cxx | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 7848424..df64695 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -15,13 +15,14 @@ #include <stdlib.h> // required for atoi #include <ctype.h> +#include <assert.h> //---------------------------------------------------------------------------- bool cmListCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { - if(args.size() < 1) + if(args.size() < 2) { - this->SetError("must be called with at least one argument."); + this->SetError("must be called with at least two arguments."); return false; } @@ -243,11 +244,7 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args) //---------------------------------------------------------------------------- bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args) { - if(args.size() < 2) - { - this->SetError("sub-command APPEND requires at least one argument."); - return false; - } + assert(args.size() >= 2); // Skip if nothing to append. if(args.size() < 3) @@ -424,12 +421,8 @@ bool cmListCommand bool cmListCommand ::HandleReverseCommand(std::vector<std::string> const& args) { - if(args.size() < 2) - { - this->SetError("sub-command REVERSE requires a list as an argument."); - return false; - } - else if(args.size() > 2) + assert(args.size() >= 2); + if(args.size() > 2) { this->SetError( "sub-command REVERSE only takes one argument."); @@ -463,13 +456,8 @@ bool cmListCommand bool cmListCommand ::HandleRemoveDuplicatesCommand(std::vector<std::string> const& args) { - if(args.size() < 2) - { - this->SetError( - "sub-command REMOVE_DUPLICATES requires a list as an argument."); - return false; - } - else if(args.size() > 2) + assert(args.size() >= 2); + if(args.size() > 2) { this->SetError( "sub-command REMOVE_DUPLICATES only takes one argument."); @@ -513,12 +501,8 @@ bool cmListCommand bool cmListCommand ::HandleSortCommand(std::vector<std::string> const& args) { - if(args.size() < 2) - { - this->SetError("sub-command SORT requires a list as an argument."); - return false; - } - else if(args.size() > 2) + assert(args.size() >= 2); + if(args.size() > 2) { this->SetError( "sub-command SORT only takes one argument."); |