From d39ffe440fe502181bffb20da5b5afd9674f5b77 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Fri, 10 Jul 2015 01:24:06 +0200
Subject: degesch: fix display of empty objects in /set
---
common.c | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/common.c b/common.c
index 62efb6f..2020032 100644
--- a/common.c
+++ b/common.c
@@ -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");
}
--
cgit v1.2.3-70-g09d2