Commit 9fe1e9f4 authored by Samir Halilcevic's avatar Samir Halilcevic

Fix iterator advance

parent 40ed1153
...@@ -105,8 +105,8 @@ private: ...@@ -105,8 +105,8 @@ private:
}; };
/// Finds `config_option` string with a matching long name in the argument list /// Finds `config_option` string with a matching long name in the argument list
/// [`first`, `last`). Returns an `iterator` to the matching location and a /// [`first`, `last`). Returns an `iterator` to the matching location and a
/// `string_view` of the option value if the entry is found, or a `iterator` /// `string_view` of the option value if the entry is found, or a `iterator`
/// to `last` with an empty `string_view` otherwise. /// to `last` with an empty `string_view` otherwise.
std::pair<std::vector<std::string>::const_iterator, std::string_view> std::pair<std::vector<std::string>::const_iterator, std::string_view>
find_by_long_name(const config_option& x, find_by_long_name(const config_option& x,
......
...@@ -133,7 +133,7 @@ std::string_view config_option::buf_slice(size_t from, ...@@ -133,7 +133,7 @@ std::string_view config_option::buf_slice(size_t from,
return {buf_.get() + from, to - from}; return {buf_.get() + from, to - from};
} }
// TODO: consider using `config_option_set` and deprecating this // TODO: consider using `config_option_set` and deprecating this
std::pair<std::vector<std::string>::const_iterator, std::string_view> std::pair<std::vector<std::string>::const_iterator, std::string_view>
find_by_long_name(const config_option& x, find_by_long_name(const config_option& x,
std::vector<std::string>::const_iterator first, std::vector<std::string>::const_iterator first,
...@@ -156,10 +156,9 @@ find_by_long_name(const config_option& x, ...@@ -156,10 +156,9 @@ find_by_long_name(const config_option& x,
// Remove leading '=' and return the value. // Remove leading '=' and return the value.
str.remove_prefix(1); str.remove_prefix(1);
return {first, str}; return {first, str};
} else if (str.empty() && (first + 1) != last) { } else if (auto val = first + 1; str.empty() && val != last) {
// Get the next argument the value // Get the next argument the value
++first; return {first, std::string_view{*val}};
return {first, std::string_view{*first}};
} else { } else {
continue; continue;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment