From fdd62c8f6391d793e1e6a33277ff4da4ecbf2363 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Tue, 19 Jan 2016 18:28:45 +0100 Subject: [PATCH] input.c: bug in MS VS 2015: if in text mode, _read returns 0 instead of 1 after reading '\n' (end of line) --- src/frontend/parser/input.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/frontend/parser/input.c b/src/frontend/parser/input.c index 1af5553bf..4f6ad964f 100644 --- a/src/frontend/parser/input.c +++ b/src/frontend/parser/input.c @@ -41,6 +41,13 @@ inchar(FILE *fp) i = read(fileno(fp), &c, 1); while (i == -1 && errno == EINTR); +#if _MSC_VER == 1900 + /* There is a bug in MS VS2015, in that _read returns 0 instead of 1 + if '\n' is read from stdin in text mode */ + if (i == 0 && c == '\n') + i = 1; +#endif + if (i == 0 || c == '\004') return EOF;