From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XygAR-0007Yz-PA for qemu-devel@nongnu.org; Wed, 10 Dec 2014 07:15:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XygAL-0006MD-Gx for qemu-devel@nongnu.org; Wed, 10 Dec 2014 07:14:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XygAL-0006Lq-A9 for qemu-devel@nongnu.org; Wed, 10 Dec 2014 07:14:49 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBACEQGl032430 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 10 Dec 2014 07:14:48 -0500 From: Kevin Wolf Date: Wed, 10 Dec 2014 11:33:31 +0100 Message-Id: <1418207679-32260-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1418207679-32260-1-git-send-email-kwolf@redhat.com> References: <1418207679-32260-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 05/73] 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: kwolf@redhat.com From: Max Reitz 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 Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- 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.8.3.1