degesch: fix display of empty objects in /set

This commit is contained in:
Přemysl Eric Janouch 2015-07-10 01:24:06 +02:00
parent c839649551
commit d39ffe440f

View File

@ -1273,6 +1273,26 @@ config_item_write_string (struct str *output, const struct str *s)
str_append_c (output, '"');
}
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)
{
@ -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");
}