[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCH] Add command trace functionality



Richard W.M. Jones wrote:
> Here's an updated patch incorporating Jim's and Matt's changes.

Looks good.  Thanks.

...
> +    pr "    printf (\"%%s\", \"%s\");\n" shortname;
> +    List.iter (
> +      function
> +      | String n			(* strings *)
> +      | Device n
> +      | Pathname n
> +      | Dev_or_Path n
> +      | FileIn n
> +      | FileOut n ->
> +	  (* guestfish doesn't support string escaping, so neither do we *)
> +	  pr "    printf (\" \\\"%%s\\\"\", %s);\n" n
> +      | OptString n ->			(* string option *)
> +	  pr "    if (%s) printf (\" \\\"%%s\\\"\", %s);\n" n n;
> +	  pr "    else printf (\" null\");\n"
> +      | StringList n
> +      | DeviceList n ->			(* string list *)
> +	  pr "    putchar ('\"');\n";
> +	  pr "    for (i = 0; %s[i]; ++i) {\n" n;
> +	  pr "      if (i > 0) putchar (' ');\n";
> +	  pr "      fputs (%s[i], stdout);\n" n;
> +	  pr "    }\n";
> +	  pr "    putchar ('\"');\n";
> +      | Bool n ->			(* boolean *)
> +	  pr "    fputs (%s ? \" true\" : \" false\", stdout);\n" n
> +      | Int n ->			(* int *)
> +	  pr "    printf (\" %%d\", %s);\n" n
> +    ) (snd style);
> +    pr "    printf (\"\\n\");\n";

Doesn't really matter, but here's one more:

       pr "    putchar ('\\n');\n";

> +    pr "  }\n";
> +    pr "\n";
> +  in


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]