| 334 | static const size_t NOT_FOUND = static_cast<size_t>(-1); |
| 335 | |
| 336 | std::string Executable::MakeOptionsName(const std::string& name) const { |
| 337 | const std::string key = name; |
| 338 | const std::string base_name = ExtractDuplicateNumber(key) != NOT_FOUND ? ExtractDuplicateBaseName(key) : key; |
| 339 | |
| 340 | std::size_t max_duplicate = 0; |
| 341 | for (std::size_t i = 0, n = this->options_list.size(); i < n; ++i) { |
| 342 | const std::string& search_name = this->options_list[i].label; |
| 343 | |
| 344 | if (search_name.compare(0, base_name.length(), base_name) != 0) { |
| 345 | continue; |
| 346 | } |
| 347 | |
| 348 | const std::size_t found_number = ExtractDuplicateNumber(search_name); |
| 349 | max_duplicate = std::max<std::size_t>(max_duplicate, found_number != NOT_FOUND ? found_number : 1); |
| 350 | } |
| 351 | |
| 352 | return base_name + (max_duplicate > 0 ? format(" (%d)", max_duplicate + 1).c_str() : ""); |
| 353 | } |
nothing calls this directly
no test coverage detected