aboutsummaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-07-10 01:24:06 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-07-10 01:24:06 +0200
commitd39ffe440fe502181bffb20da5b5afd9674f5b77 (patch)
treebda9da97e15222ce9c8dd12f8f9ef612fe869db1 /common.c
parentc839649551dd47edfebdfbfdf7be0923bf1ea8d1 (diff)
downloadxK-d39ffe440fe502181bffb20da5b5afd9674f5b77.tar.gz
xK-d39ffe440fe502181bffb20da5b5afd9674f5b77.tar.xz
xK-d39ffe440fe502181bffb20da5b5afd9674f5b77.zip
degesch: fix display of empty objects in /set
Diffstat (limited to 'common.c')
-rw-r--r--common.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/common.c b/common.c
index 62efb6f..2020032 100644
--- a/common.c
+++ b/common.c
@@ -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");
}