summaryrefslogtreecommitdiffstats
path: root/Source/cmList.cxx
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2023-04-04 14:42:58 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2023-04-16 10:00:20 (GMT)
commit31675964e7ba37f1412aaa95af4199e9b62e8c08 (patch)
tree7d53c8bdc2dbed748efa86750fe88358a92f325c /Source/cmList.cxx
parente256e35daa79732a200883cef398fcd0f8227a3d (diff)
downloadCMake-31675964e7ba37f1412aaa95af4199e9b62e8c08.zip
CMake-31675964e7ba37f1412aaa95af4199e9b62e8c08.tar.gz
CMake-31675964e7ba37f1412aaa95af4199e9b62e8c08.tar.bz2
GenEx LIST: list operations
Fixes: #24550, #24547
Diffstat (limited to 'Source/cmList.cxx')
-rw-r--r--Source/cmList.cxx18
1 files changed, 10 insertions, 8 deletions
diff --git a/Source/cmList.cxx b/Source/cmList.cxx
index bf5a654..2064afb 100644
--- a/Source/cmList.cxx
+++ b/Source/cmList.cxx
@@ -835,18 +835,19 @@ cmList::size_type cmList::ComputeIndex(index_type pos, bool boundCheck) const
cmStrCat("index: ", pos, " out of range (0, 0)"));
}
+ auto index = pos;
if (!this->Values.empty()) {
auto length = this->Values.size();
- if (pos < 0) {
- pos = static_cast<index_type>(length) + pos;
+ if (index < 0) {
+ index = static_cast<index_type>(length) + index;
}
- if (pos < 0 || length <= static_cast<size_type>(pos)) {
+ if (index < 0 || length <= static_cast<size_type>(index)) {
throw std::out_of_range(cmStrCat("index: ", pos, " out of range (-",
this->Values.size(), ", ",
this->Values.size() - 1, ")"));
}
}
- return pos;
+ return index;
}
return pos < 0 ? this->Values.size() + pos : pos;
@@ -860,18 +861,19 @@ cmList::size_type cmList::ComputeInsertIndex(index_type pos,
cmStrCat("index: ", pos, " out of range (0, 0)"));
}
+ auto index = pos;
if (!this->Values.empty()) {
auto length = this->Values.size();
- if (pos < 0) {
- pos = static_cast<index_type>(length) + pos;
+ if (index < 0) {
+ index = static_cast<index_type>(length) + index;
}
- if (pos < 0 || length < static_cast<size_type>(pos)) {
+ if (index < 0 || length < static_cast<size_type>(index)) {
throw std::out_of_range(cmStrCat("index: ", pos, " out of range (-",
this->Values.size(), ", ",
this->Values.size(), ")"));
}
}
- return pos;
+ return index;
}
return pos < 0 ? this->Values.size() + pos : pos;