From dfd1aa563dedd71483e00135859ab234ad499ac6 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 22 Jun 2011 10:36:44 +0100 Subject: [PATCH] trace: Print empty list correctly. Empty lists returned by RStringList and RHashtable functions were incorrectly printed as [""]. Fix this so they are printed as [] instead. Cherry picked from commit 56b94f5f6aa7981533ad867cc908c6e9cca2ba42. --- generator/generator_c.ml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/generator/generator_c.ml b/generator/generator_c.ml index fd341da..64ddf9b 100644 --- a/generator/generator_c.ml +++ b/generator/generator_c.ml @@ -833,12 +833,14 @@ check_state (guestfs_h *g, const char *caller) | RBufferOut _ -> pr "%s guestfs___print_BufferOut (stderr, %s, *size_r);\n" indent rv | RStringList _ | RHashtable _ -> - pr "%s fputs (\"[\\\"\", stderr);\n" indent; + pr "%s fputs (\"[\", stderr);\n" indent; pr "%s for (i = 0; %s[i]; ++i) {\n" indent rv; - pr "%s if (i > 0) fputs (\"\\\", \\\"\", stderr);\n" indent; + pr "%s if (i > 0) fputs (\", \", stderr);\n" indent; + pr "%s fputs (\"\\\"\", stderr);\n" indent; pr "%s fputs (%s[i], stderr);\n" indent rv; + pr "%s fputs (\"\\\"\", stderr);\n" indent; pr "%s }\n" indent; - pr "%s fputs (\"\\\"]\", stderr);\n" indent; + pr "%s fputs (\"]\", stderr);\n" indent; | RStruct (_, typ) -> (* XXX There is code generated for guestfish for printing * these structures. We need to make it generally available -- 1.8.3.1