From 3c5f110cc29f8d3fbf2069c68d25ccebee46679e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 10 Mar 2016 06:29:25 -0800 Subject: Workaround for apparent putc bug in Cygwin. This fix is required for the stream socket test case to pass. Some interaction between a stdio stream in line buffering mode and the putc function causes a stream to lose data. If we use fputs instead to output a character, the issue goes away. * stream.c (se_putc): When compiling for Cygwin, construct a one-character-long string and use fputs, rather than putc. --- stream.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stream.c b/stream.c index d4b71dc7..a3d60863 100644 --- a/stream.c +++ b/stream.c @@ -454,7 +454,14 @@ static int se_putc(int ch, FILE *f) { int ret; sig_save_enable; +#ifdef __CYGWIN__ + { + char out[2] = { ch, 0 }; + ret = fputs(out, f) == EOF ? EOF : ch; + } +#else ret = putc(ch, f); +#endif sig_restore_enable; return ret; } -- cgit v1.2.3