qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qjson: Drop trailing space for pretty formatting
@ 2014-11-21  9:29 Max Reitz
  2014-11-21 12:36 ` Kevin Wolf
  2014-11-21 16:07 ` Eric Blake
  0 siblings, 2 replies; 3+ messages in thread
From: Max Reitz @ 2014-11-21  9:29 UTC (permalink / raw)
  To: qemu-devel; +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 <mreitz@redhat.com>
---
 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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qjson: Drop trailing space for pretty formatting
  2014-11-21  9:29 [Qemu-devel] [PATCH] qjson: Drop trailing space for pretty formatting Max Reitz
@ 2014-11-21 12:36 ` Kevin Wolf
  2014-11-21 16:07 ` Eric Blake
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2014-11-21 12:36 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-devel, Luiz Capitulino

Am 21.11.2014 um 10:29 hat Max Reitz geschrieben:
> 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 <mreitz@redhat.com>

Luiz, any objections?

/me waits a bit... 3... 2... 1...

No? Great, thanks, applied to block-next.

(More seriously, I have a patch with a qemu-iotests case depending on
the output, so I'm merging this before my patch. If there is a problem,
there's still some time until block-next ends up in master, so I can
always drop it or replace it with a v2.)

Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qjson: Drop trailing space for pretty formatting
  2014-11-21  9:29 [Qemu-devel] [PATCH] qjson: Drop trailing space for pretty formatting Max Reitz
  2014-11-21 12:36 ` Kevin Wolf
@ 2014-11-21 16:07 ` Eric Blake
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2014-11-21 16:07 UTC (permalink / raw)
  To: Max Reitz, qemu-devel; +Cc: Kevin Wolf, Luiz Capitulino

[-- Attachment #1: Type: text/plain, Size: 592 bytes --]

On 11/21/2014 02:29 AM, Max Reitz wrote:
> 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 <mreitz@redhat.com>
> ---
>  qobject/qjson.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-21 16:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-21  9:29 [Qemu-devel] [PATCH] qjson: Drop trailing space for pretty formatting Max Reitz
2014-11-21 12:36 ` Kevin Wolf
2014-11-21 16:07 ` Eric Blake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).