summaryrefslogtreecommitdiffstats
path: root/Source/cmListCommand.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2018-10-11 21:26:44 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2018-10-16 18:31:39 (GMT)
commit121a036f73665a18ccadeaf50b00cc623d8ed9df (patch)
treef361e2403c53546425781713b7bdeb57e5ba9389 /Source/cmListCommand.cxx
parentacfe53c58817c662b935fbe0f0443de298371731 (diff)
downloadCMake-121a036f73665a18ccadeaf50b00cc623d8ed9df.zip
CMake-121a036f73665a18ccadeaf50b00cc623d8ed9df.tar.gz
CMake-121a036f73665a18ccadeaf50b00cc623d8ed9df.tar.bz2
cmListCommand: handle empty lists for list(REMOVE_AT)
Treat an empty list as a list with no valid bounds and return an error message indicating that any given indices are out-of-bounds.
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 b46eb6d..b2acb90 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -1225,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;
}