Skip to content

Commit

Permalink
Schema: Extra sanity check for [elseif] tags
Browse files Browse the repository at this point in the history
Probably not technically necessary as long as conditions are processed in order
However, I think it's nice to play it safe
  • Loading branch information
CelticMinstrel committed Oct 24, 2018
1 parent 644ff73 commit d369368
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/serialization/tag.cpp
Expand Up @@ -557,10 +557,12 @@ void class_tag::add_filter(const config& cond_cfg)
}
int i = 1;
for(auto elseif_cfg : cond_cfg.child_range("elseif")) {
config elseif_filter = elseif_cfg;
config elseif_filter = elseif_cfg, old_else_filter = else_filter;
elseif_filter.clear_children("then");
conditions_.emplace_back(elseif_cfg.child("then"), elseif_filter);
else_filter.add_child("not", elseif_filter);
// Ensure it won't match for any of the preceding cases, either
elseif_filter.append_children(old_else_filter);
conditions_.emplace_back(elseif_cfg.child("then"), elseif_filter);
const std::string name = formatter() << get_name() << "[elseif " << i++ << "]";
conditions_.back().set_name(name);
}
Expand Down

0 comments on commit d369368

Please sign in to comment.