diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index d7e628b567..9dc1b54fdc 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -1786,8 +1786,16 @@ static int read_i(int fd, void *buf, unsigned int count) DWORD i, j; if (bufstart[num_read-1] == '\r') { - MSVCRT_fdesc[fd].wxflag |= WX_READCR; - num_read--; + if(count == 1) + { + MSVCRT_fdesc[fd].wxflag &= ~WX_READCR; + ReadFile(hand, bufstart, 1, &num_read, NULL); + } + else + { + MSVCRT_fdesc[fd].wxflag |= WX_READCR; + num_read--; + } } else MSVCRT_fdesc[fd].wxflag &= ~WX_READCR; diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index 18247adf28..5afdfcbabe 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -880,7 +880,23 @@ static void test_file_write_read( void ) "problems with _O_BINARY _write / _O_TEXT _read\n"); _close(tempfd); - ret =_chmod (tempf, _S_IREAD | _S_IWRITE); + /* test _read with single bytes. CR should be skipped and LF pulled in */ + tempfd = _open(tempf,_O_RDONLY|_O_TEXT); /* open in TEXT mode */ + for (i=0; i