Commit 92ac665d authored by Uwe Bonnes's avatar Uwe Bonnes Committed by Alexandre Julliard

msvcrt: Check for EOF before correcting CR/LF.

parent 1d0db2b1
......@@ -1757,6 +1757,9 @@ static int read_i(int fd, void *buf, unsigned int count)
char *bufstart = buf;
HANDLE hand = msvcrt_fdtoh(fd);
if (count == 0)
return 0;
if (MSVCRT_fdesc[fd].wxflag & WX_READEOF) {
MSVCRT_fdesc[fd].wxflag |= WX_ATEOF;
TRACE("already at EOF, returning 0\n");
......@@ -1773,7 +1776,12 @@ static int read_i(int fd, void *buf, unsigned int count)
*/
if (ReadFile(hand, bufstart, count, &num_read, NULL))
{
if (MSVCRT_fdesc[fd].wxflag & WX_TEXT)
if (count != 0 && num_read == 0)
{
MSVCRT_fdesc[fd].wxflag |= (WX_ATEOF|WX_READEOF);
TRACE(":EOF %s\n",debugstr_an(buf,num_read));
}
else if (MSVCRT_fdesc[fd].wxflag & WX_TEXT)
{
DWORD i, j;
if (bufstart[num_read-1] == '\r')
......@@ -1802,11 +1810,6 @@ static int read_i(int fd, void *buf, unsigned int count)
}
num_read = j;
}
if (count != 0 && num_read == 0)
{
MSVCRT_fdesc[fd].wxflag |= (WX_ATEOF|WX_READEOF);
TRACE(":EOF %s\n",debugstr_an(buf,num_read));
}
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment