summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 30e228e)
raw | patch | inline | side by side (parent: 30e228e)
author | Sebastian Harl <sh@tokkee.org> | |
Mon, 28 Sep 2015 20:07:08 +0000 (22:07 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Mon, 28 Sep 2015 20:07:08 +0000 (22:07 +0200) |
Rewinding the formatter state has to happen any time we see a parent object of
the current object. This happens every time the current context isn't HOST
(hosts don't have any parents) or the new object is an ATTRIBUTE (which are
always children of whatever other object type).
This broke in 3603db13105aefac4d6ceb356bcfd118a92fa654.
the current object. This happens every time the current context isn't HOST
(hosts don't have any parents) or the new object is an ATTRIBUTE (which are
always children of whatever other object type).
This broke in 3603db13105aefac4d6ceb356bcfd118a92fa654.
src/core/store_json.c | patch | blob | history |
diff --git a/src/core/store_json.c b/src/core/store_json.c
index c8e35fe73584632fb60bd524835862d0da00a9ce..a2c117b1f10d07308e7db9afd698c32933342e49 100644 (file)
--- a/src/core/store_json.c
+++ b/src/core/store_json.c
return 0;
}
- if ((f->current >= 1) && (obj->type != SDB_ATTRIBUTE)) {
- /* new entry of a previous type or a new type on the same level;
+ if ((f->context[f->current] != SDB_HOST)
+ && (obj->type != SDB_ATTRIBUTE)) {
+ /* new entry of the same type or a parent object;
* rewind to the right state */
while ((f->current > 0)
- && (f->context[f->current] == obj->type)) {
+ && (f->context[f->current] != obj->type)) {
sdb_strbuf_append(f->buf, "}]");
--f->current;
}