blobmsg_json: do not emit any whitespace when formatting without indentation

This commit is contained in:
Jo-Philipp Wich 2013-11-27 18:40:15 +00:00
parent f100acef37
commit f6827c7c93

View file

@ -129,14 +129,11 @@ static bool blobmsg_puts(struct strbuf *s, const char *c, int len)
static void add_separator(struct strbuf *s) static void add_separator(struct strbuf *s)
{ {
static char indent_chars[17] = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; static char indent_chars[17] = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
static const char indent_space = ' ';
int indent; int indent;
char *start; char *start;
if (!s->indent) { if (!s->indent)
blobmsg_puts(s, &indent_space, 1);
return; return;
}
indent = s->indent_level; indent = s->indent_level;
if (indent > 16) if (indent > 16)
@ -219,7 +216,7 @@ static void blobmsg_format_element(struct strbuf *s, struct blob_attr *attr, boo
if (!array && blobmsg_name(attr)[0]) { if (!array && blobmsg_name(attr)[0]) {
blobmsg_format_string(s, blobmsg_name(attr)); blobmsg_format_string(s, blobmsg_name(attr));
blobmsg_puts(s, ": ", 2); blobmsg_puts(s, ": ", s->indent ? 2 : 1);
} }
if (head) { if (head) {
data = blob_data(attr); data = blob_data(attr);