[Libguestfs] [PATCH nbdkit v2 2/4] server: debug: Don't emit ANSI colour codes on Windows

Laszlo Ersek lersek at redhat.com
Tue May 9 12:25:05 UTC 2023


On 5/9/23 11:51, Richard W.M. Jones wrote:
> At least under Wine they are not recognized and you just see literal
> "[0m" etc appearing in the output.
> 
> Updates: commit 5a011e02375912f2ad88de1ebc6d609e29d38f71
> ---
>  server/debug.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/server/debug.c b/server/debug.c
> index 1b5ddaafe..2231d40a0 100644
> --- a/server/debug.c
> +++ b/server/debug.c
> @@ -70,7 +70,9 @@ static void
>  debug_common (bool in_server, const char *fs, va_list args)
>  {
>    int err = errno;
> +#ifndef WIN32
>    int tty;
> +#endif
>    CLEANUP_FREE char *str = NULL;
>    size_t len = 0;
>    FILE *fp;
> @@ -88,15 +90,19 @@ debug_common (bool in_server, const char *fs, va_list args)
>      return;
>    }
>  
> +#ifndef WIN32
>    tty = isatty (fileno (stderr));
>    if (!in_server && tty) ansi_force_colour (ANSI_FG_BOLD_BLACK, fp);
> +#endif
>  
>    prologue (fp);
>  
>    errno = err;
>    vfprintf (fp, fs, args);
>  
> +#ifndef WIN32
>    if (!in_server && tty) ansi_force_restore (fp);
> +#endif
>    fprintf (fp, "\n");
>    close_memstream (fp);
>  

Reviewed-by: Laszlo Ersek <lersek at redhat.com>



More information about the Libguestfs mailing list