emacs-devel
[Top][All Lists]
Advanced

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

Re: `message' not outputting the newline "atomically"


From: Daniele Nicolodi
Subject: Re: `message' not outputting the newline "atomically"
Date: Mon, 24 Jun 2019 14:03:43 -0600
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.7.0

On 24-06-2019 13:48, Lars Ingebrigtsen wrote:
> So...  does this look OK?
> 
> diff --git a/src/xdisp.c b/src/xdisp.c
> index 5d70440f1c..0b45ca9e02 100644
> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -10705,10 +10705,22 @@ message_to_stderr (Lisp_Object m)
>        else
>       s = m;
>  
> -      fwrite (SDATA (s), SBYTES (s), 1, stderr);
> +      /* We want to write this out with a single fwrite call so that
> +      output doesn't interleave with other processes writing to
> +      stderr at the same time. */
> +      {
> +     int length = SBYTES (s);
> +     char *string = xmalloc (length + 1);
> +     
> +     memcpy (string, SSDATA (s), length);
> +     *(string + length) = '\n';

Isn't this more naturally spelled as below?

string[length] = '\n';

> +     fwrite (string, length + 1, 1, stderr);
> +     xfree (string);
> +      }
>      }
> -  if (!cursor_in_echo_area)
> +  else if (!cursor_in_echo_area)
>      fputc ('\n', stderr);
> +
>    fflush (stderr);

I think the fflush() here can be dropped, stderr is not buffered.

>  }

Cheers,
Dan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]