output: do not skip over first range in mustach output

Off by one that is caused by must_next_range() advancing pointer, and moving
over the first range.  Fix by setting indexes one step backwards, that is
not excellent but better than copying skip_ok stuff to must_enter().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2017-11-11 08:20:10 +00:00
parent 50fc4ebe9d
commit d5ae2a80c0
No known key found for this signature in database
GPG key ID: A9553245FDE9B739
2 changed files with 32 additions and 1 deletions

View file

@ -231,9 +231,10 @@ static int must_enter(void *closure, const char *name)
if (!strcmp(name, "subnets")) {
itf.put = must_put_range;
itf.next = must_next_range;
e->current = num_ranges;
e->current = num_ranges + 1;
e->range_p = ranges;
/* must_next_range() will skip_ok when needed */
e->range_p--;
return must_next_range(closure);
}
if (!strcmp(name, "shared-networks")) {

View file

@ -1,4 +1,19 @@
Subnets:
location: example1
range: 10.0.0.1 - 10.0.0.20
first_ip: 10.0.0.1
last_ip: 10.0.0.20
used: 11
touched: 0
defined: 20
free: 9
percent: 55
touch_count: 11
touch_percent: 55
backup_count: 1
backup_percent: 5
status: 0
location: example1
range: 10.1.0.1 - 10.1.0.20
first_ip: 10.1.0.1
@ -101,6 +116,21 @@ Summary:
--- skip ok ---
Subnets:
location: example1
range: 10.0.0.1 - 10.0.0.20
first_ip: 10.0.0.1
last_ip: 10.0.0.20
used: 11
touched: 0
defined: 20
free: 9
percent: 55
touch_count: 11
touch_percent: 55
backup_count: 1
backup_percent: 5
status: 1
location: example1
range: 10.1.0.1 - 10.1.0.20
first_ip: 10.1.0.1