From: Richard W.M. Jones Date: Wed, 22 Jun 2011 09:36:44 +0000 (+0100) Subject: trace: Print empty list correctly. X-Git-Tag: 1.10.5~11 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=16e022871c606e5ce4c6f5db985d9e5b7818ee57;p=libguestfs.git 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) --- diff --git a/generator/generator_c.ml b/generator/generator_c.ml index 4405d63..071b83c 100644 --- a/generator/generator_c.ml +++ b/generator/generator_c.ml @@ -921,12 +921,14 @@ trace_send_line (guestfs_h *g) | RBufferOut _ -> pr "%s guestfs___print_BufferOut (trace_fp, %s, *size_r);\n" indent rv | RStringList _ | RHashtable _ -> - pr "%s fputs (\"[\\\"\", trace_fp);\n" indent; + pr "%s fputs (\"[\", trace_fp);\n" indent; pr "%s for (i = 0; %s[i]; ++i) {\n" indent rv; - pr "%s if (i > 0) fputs (\"\\\", \\\"\", trace_fp);\n" indent; + pr "%s if (i > 0) fputs (\", \", trace_fp);\n" indent; + pr "%s fputs (\"\\\"\", trace_fp);\n" indent; pr "%s fputs (%s[i], trace_fp);\n" indent rv; + pr "%s fputs (\"\\\"\", trace_fp);\n" indent; pr "%s }\n" indent; - pr "%s fputs (\"\\\"]\", trace_fp);\n" indent; + pr "%s fputs (\"]\", trace_fp);\n" indent; | RStruct (_, typ) -> (* XXX There is code generated for guestfish for printing * these structures. We need to make it generally available