diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-07-10 01:24:06 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-07-10 01:24:06 +0200 |
commit | d39ffe440fe502181bffb20da5b5afd9674f5b77 (patch) | |
tree | bda9da97e15222ce9c8dd12f8f9ef612fe869db1 | |
parent | c839649551dd47edfebdfbfdf7be0923bf1ea8d1 (diff) | |
download | xK-d39ffe440fe502181bffb20da5b5afd9674f5b77.tar.gz xK-d39ffe440fe502181bffb20da5b5afd9674f5b77.tar.xz xK-d39ffe440fe502181bffb20da5b5afd9674f5b77.zip |
degesch: fix display of empty objects in /set
-rw-r--r-- | common.c | 34 |
1 files changed, 21 insertions, 13 deletions
@@ -1274,6 +1274,26 @@ config_item_write_string (struct str *output, const struct str *s) } static void +config_item_write_object + (struct config_writer *self, struct config_item_ *value) +{ + char indent[self->indent + 1]; + memset (indent, '\t', self->indent); + indent[self->indent] = 0; + + str_append_c (self->output, '{'); + if (value->value.object.len) + { + self->indent++; + str_append_c (self->output, '\n'); + config_item_write_object_innards (self, value); + self->indent--; + str_append (self->output, indent); + } + str_append_c (self->output, '}'); +} + +static void config_item_write_value (struct config_writer *self, struct config_item_ *value) { switch (value->type) @@ -1292,20 +1312,8 @@ config_item_write_value (struct config_writer *self, struct config_item_ *value) config_item_write_string (self->output, &value->value.string); break; case CONFIG_ITEM_OBJECT: - { - char indent[self->indent + 1]; - memset (indent, '\t', self->indent); - indent[self->indent] = 0; - - str_append (self->output, "{\n"); - - self->indent++; - config_item_write_object_innards (self, value); - self->indent--; - - str_append_printf (self->output, "%s}", indent); + config_item_write_object (self, value); break; - } default: hard_assert (!"invalid item type"); } |