summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-03-10 06:29:25 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-03-10 06:29:25 -0800
commit3c5f110cc29f8d3fbf2069c68d25ccebee46679e (patch)
treec9d31727b2379aafaab2b44198137b580f0b7f60
parenta6551d3c4b832ef4b724e6039c615dfd56d76b7e (diff)
downloadtxr-3c5f110cc29f8d3fbf2069c68d25ccebee46679e.tar.gz
txr-3c5f110cc29f8d3fbf2069c68d25ccebee46679e.tar.bz2
txr-3c5f110cc29f8d3fbf2069c68d25ccebee46679e.zip
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.
-rw-r--r--stream.c7
1 files changed, 7 insertions, 0 deletions
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;
}