From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45470) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrkXZ-0008On-GQ for qemu-devel@nongnu.org; Fri, 21 Nov 2014 04:30:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XrkXT-0004hS-9e for qemu-devel@nongnu.org; Fri, 21 Nov 2014 04:30:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33661) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrkXT-0004ge-2u for qemu-devel@nongnu.org; Fri, 21 Nov 2014 04:30:03 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAL9U1ss002693 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 21 Nov 2014 04:30:02 -0500 From: Max Reitz Date: Fri, 21 Nov 2014 10:29:59 +0100 Message-Id: <1416562199-13731-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH] qjson: Drop trailing space for pretty formatting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Max Reitz , Luiz Capitulino For the pretty formatting, the functions converting QDicts and QLists to JSON should not print a space after the comma separating objects, because a newline will emitted immediately afterwards, making the whitespace superfluous. Signed-off-by: Max Reitz --- qobject/qjson.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/qobject/qjson.c b/qobject/qjson.c index 6cf2511..12c576d 100644 --- a/qobject/qjson.c +++ b/qobject/qjson.c @@ -86,8 +86,9 @@ static void to_json_dict_iter(const char *key, QObject *obj, void *opaque) QString *qkey; int j; - if (s->count) - qstring_append(s->str, ", "); + if (s->count) { + qstring_append(s->str, s->pretty ? "," : ", "); + } if (s->pretty) { qstring_append(s->str, "\n"); @@ -109,8 +110,9 @@ static void to_json_list_iter(QObject *obj, void *opaque) ToJsonIterState *s = opaque; int j; - if (s->count) - qstring_append(s->str, ", "); + if (s->count) { + qstring_append(s->str, s->pretty ? "," : ", "); + } if (s->pretty) { qstring_append(s->str, "\n"); -- 1.9.3