Thread (25 messages) flat view 25 messages, 7 authors, 2016-08-13

Re: [PATCH] winansi: support ESC [ K (erase in line)

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:46:22

Hi,

On Tue, 10 Mar 2009, Peter Harris wrote:
On Mon, Mar 9, 2009 at 8:41 PM, Johannes Schindelin wrote:
quoted
+int winansi_write(int fd, const void *buf, size_t len)
+{
+       if (isatty(fd)) {
+               init();
+               if (console)
+                       return ansi_emulate((const char *)buf, len,
+                                       fd == 2 ? stderr : stdout);
+       }
+       return write(fd, buf, len);
+}
Switching an unbuffered write to a buffered fwrite makes me a little 
nervous. In practice, all writes probably go through this function, so 
it doesn't matter. And if the write is going somewhere it matters, it 
likely fails isatty anyway. But I would still be less nervous with an 
fflush() after ansi_emulate.
That would make the code substantially more messy, though.

Besides, half of it is already there: when encountering an ANSI sequence, 
your code already fflush()es the fd before setting the new attributes.  
And stderr does not need the fflush() anyway.

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help