diff options
author | Brad King <brad.king@kitware.com> | 2018-10-17 17:27:49 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-10-17 17:27:56 (GMT) |
commit | 78681bf001f4f29cf2f452327587669078a39461 (patch) | |
tree | 2f3385af26bcfa5c3cf4f4494c44d9492135e1bb /Source | |
parent | f21d811c7c4c9b61c6c81414b3e8803db392183c (diff) | |
parent | 121a036f73665a18ccadeaf50b00cc623d8ed9df (diff) | |
download | CMake-78681bf001f4f29cf2f452327587669078a39461.zip CMake-78681bf001f4f29cf2f452327587669078a39461.tar.gz CMake-78681bf001f4f29cf2f452327587669078a39461.tar.bz2 |
Merge topic 'better-empty-list-behavior'
121a036f73 cmListCommand: handle empty lists for list(REMOVE_AT)
acfe53c588 cmListCommand: make list(ACTION not_a_list) succeed when idempotent
bf572ac952 cmListCommand: check list(FILTER) operation before the list
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2478
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmListCommand.cxx | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index d7de2fa..b2acb90 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -346,8 +346,7 @@ bool cmListCommand::HandleRemoveItemCommand( // expand the variable std::vector<std::string> varArgsExpanded; if (!this->GetList(varArgsExpanded, listName)) { - this->SetError("sub-command REMOVE_ITEM requires list to be present."); - return false; + return true; } std::vector<std::string> remove(args.begin() + 2, args.end()); @@ -376,8 +375,7 @@ bool cmListCommand::HandleReverseCommand(std::vector<std::string> const& args) // expand the variable std::vector<std::string> varArgsExpanded; if (!this->GetList(varArgsExpanded, listName)) { - this->SetError("sub-command REVERSE requires list to be present."); - return false; + return true; } std::string value = cmJoin(cmReverseRange(varArgsExpanded), ";"); @@ -399,9 +397,7 @@ bool cmListCommand::HandleRemoveDuplicatesCommand( // expand the variable std::vector<std::string> varArgsExpanded; if (!this->GetList(varArgsExpanded, listName)) { - this->SetError( - "sub-command REMOVE_DUPLICATES requires list to be present."); - return false; + return true; } std::vector<std::string>::const_iterator argsEnd = @@ -1152,8 +1148,7 @@ bool cmListCommand::HandleSortCommand(std::vector<std::string> const& args) // expand the variable std::vector<std::string> varArgsExpanded; if (!this->GetList(varArgsExpanded, listName)) { - this->SetError("sub-command SORT requires list to be present."); - return false; + return true; } if ((sortCompare == cmStringSorter::Compare::STRING) && @@ -1230,13 +1225,17 @@ bool cmListCommand::HandleRemoveAtCommand(std::vector<std::string> const& args) const std::string& listName = args[1]; // expand the variable std::vector<std::string> varArgsExpanded; - if (!this->GetList(varArgsExpanded, listName)) { - this->SetError("sub-command REMOVE_AT requires list to be present."); - return false; - } - // FIXME: Add policy to make non-existing lists an error like empty lists. - if (varArgsExpanded.empty()) { - this->SetError("REMOVE_AT given empty list"); + if (!this->GetList(varArgsExpanded, listName) || varArgsExpanded.empty()) { + std::ostringstream str; + str << "index: "; + for (size_t i = 1; i < args.size(); ++i) { + str << args[i]; + if (i != args.size() - 1) { + str << ", "; + } + } + str << " out of range (0, 0)"; + this->SetError(str.str()); return false; } @@ -1289,14 +1288,6 @@ bool cmListCommand::HandleFilterCommand(std::vector<std::string> const& args) return false; } - const std::string& listName = args[1]; - // expand the variable - std::vector<std::string> varArgsExpanded; - if (!this->GetList(varArgsExpanded, listName)) { - this->SetError("sub-command FILTER requires list to be present."); - return false; - } - const std::string& op = args[2]; bool includeMatches; if (op == "INCLUDE") { @@ -1308,6 +1299,13 @@ bool cmListCommand::HandleFilterCommand(std::vector<std::string> const& args) return false; } + const std::string& listName = args[1]; + // expand the variable + std::vector<std::string> varArgsExpanded; + if (!this->GetList(varArgsExpanded, listName)) { + return true; + } + const std::string& mode = args[3]; if (mode == "REGEX") { if (args.size() != 5) { |