msvcrt: Fix lookahead buffer usage on pipes.
This commit is contained in:
parent
f42c631d6e
commit
089cc78182
|
@ -2570,10 +2570,18 @@ static int read_i(int fd, void *buf, unsigned int count)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fdinfo->wxflag & (WX_PIPE | WX_NOSEEK))
|
if (fdinfo->wxflag & (WX_PIPE | WX_NOSEEK))
|
||||||
|
{
|
||||||
|
if (lookahead[0]=='\n' && (!utf16 || !lookahead[1]))
|
||||||
|
{
|
||||||
|
bufstart[j++] = '\n';
|
||||||
|
if (utf16) bufstart[j++] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
fdinfo->lookahead[0] = lookahead[0];
|
fdinfo->lookahead[0] = lookahead[0];
|
||||||
fdinfo->lookahead[1] = lookahead[1];
|
fdinfo->lookahead[1] = lookahead[1];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
SetFilePointer(fdinfo->handle, -1-utf16, NULL, FILE_CURRENT);
|
SetFilePointer(fdinfo->handle, -1-utf16, NULL, FILE_CURRENT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2032,8 +2032,8 @@ static void test_pipes(const char* selfname)
|
||||||
ok(0, "pipe failed with errno %d\n", errno);
|
ok(0, "pipe failed with errno %d\n", errno);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
r = write(pipes[1], "\r\n\rab", 5);
|
r = write(pipes[1], "\r\n\rab\r\n", 7);
|
||||||
ok(r == 5, "write returned %d, errno = %d\n", r, errno);
|
ok(r == 7, "write returned %d, errno = %d\n", r, errno);
|
||||||
setmode(pipes[0], O_TEXT);
|
setmode(pipes[0], O_TEXT);
|
||||||
r = read(pipes[0], buf, 1);
|
r = read(pipes[0], buf, 1);
|
||||||
ok(r == 1, "read returned %d, expected 1\n", r);
|
ok(r == 1, "read returned %d, expected 1\n", r);
|
||||||
|
@ -2044,9 +2044,10 @@ static void test_pipes(const char* selfname)
|
||||||
r = read(pipes[0], buf, 1);
|
r = read(pipes[0], buf, 1);
|
||||||
ok(r == 1, "read returned %d, expected 1\n", r);
|
ok(r == 1, "read returned %d, expected 1\n", r);
|
||||||
ok(buf[0] == 'a', "buf[0] = %x, expected 'a'\n", buf[0]);
|
ok(buf[0] == 'a', "buf[0] = %x, expected 'a'\n", buf[0]);
|
||||||
r = read(pipes[0], buf, 1);
|
r = read(pipes[0], buf, 2);
|
||||||
ok(r == 1, "read returned %d, expected 1\n", r);
|
ok(r == 2, "read returned %d, expected 1\n", r);
|
||||||
ok(buf[0] == 'b', "buf[0] = %x, expected 'b'\n", buf[0]);
|
ok(buf[0] == 'b', "buf[0] = %x, expected 'b'\n", buf[0]);
|
||||||
|
ok(buf[1] == '\n', "buf[1] = %x, expected '\\n'\n", buf[1]);
|
||||||
|
|
||||||
if (p_fopen_s)
|
if (p_fopen_s)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue