Clean up parse_error_offset_source_start

Use range-based for loops and relax the requirement that we have an
error list.
This commit is contained in:
ridiculousfish 2020-12-21 20:39:41 -08:00
parent 04d7d89020
commit 10362a70df

View file

@ -134,14 +134,11 @@ wcstring parse_error_t::describe(const wcstring &src, bool is_interactive) const
}
void parse_error_offset_source_start(parse_error_list_t *errors, size_t amt) {
assert(errors != nullptr);
if (amt > 0) {
size_t i, max = errors->size();
for (i = 0; i < max; i++) {
parse_error_t *error = &errors->at(i);
if (amt > 0 && errors != nullptr) {
for (parse_error_t &error : *errors) {
// Preserve the special meaning of -1 as 'unknown'.
if (error->source_start != SOURCE_LOCATION_UNKNOWN) {
error->source_start += amt;
if (error.source_start != SOURCE_LOCATION_UNKNOWN) {
error.source_start += amt;
}
}
}