input.c: bug in MS VS 2015: if in text mode, _read returns 0 instead of 1 after reading '\n' (end of line)

This commit is contained in:
h_vogt 2016-01-19 18:28:45 +01:00 committed by rlar
parent 6f5c5b162d
commit 54d8ad9db3
1 changed files with 7 additions and 0 deletions

View File

@ -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;