msvcrt: ungetc must create a buffer, even if _IONBF has been set with setvbuf.

This commit is contained in:
Eric Pouech 2011-04-24 11:01:59 +02:00 committed by Alexandre Julliard
parent dc9904a338
commit a42bf0134c
2 changed files with 1 additions and 12 deletions

View File

@ -3622,7 +3622,7 @@ int CDECL MSVCRT_ungetc(int c, MSVCRT_FILE * file)
{
if (c == MSVCRT_EOF)
return MSVCRT_EOF;
if(file->_bufsiz == 0 && !(file->_flag & MSVCRT__IONBF)) {
if(file->_bufsiz == 0) {
msvcrt_alloc_buffer(file);
file->_ptr++;
}

View File

@ -140,23 +140,12 @@ static void test_fileops( void )
ok(feof(file), "feof after ungetc(EOF) did not return EOF for bufmode=%x\n", bufmodes[bufmode]);
ok((c = fgetc(file)) == EOF, "getc did not return EOF for bufmode=%x\n", bufmodes[bufmode]);
c = outbuffer[sizeof(outbuffer) - 1];
if (bufmodes[bufmode] == _IONBF) todo_wine {
ok(ungetc(c, file) == c, "ungetc did not return its input for bufmode=%x\n", bufmodes[bufmode]);
ok(!feof(file), "feof after ungetc returned EOF for bufmode=%x\n", bufmodes[bufmode]);
ok((c = fgetc(file)) != EOF, "getc after ungetc returned EOF for bufmode=%x\n", bufmodes[bufmode]);
ok(c == outbuffer[sizeof(outbuffer) - 1],
"getc did not return ungetc'd data for bufmode=%x\n", bufmodes[bufmode]);
ok(!feof(file), "feof after getc returned EOF prematurely for bufmode=%x\n", bufmodes[bufmode]);
}
else
{
ok(ungetc(c, file) == c, "ungetc did not return its input for bufmode=%x\n", bufmodes[bufmode]);
ok(!feof(file), "feof after ungetc returned EOF for bufmode=%x\n", bufmodes[bufmode]);
ok((c = fgetc(file)) != EOF, "getc after ungetc returned EOF for bufmode=%x\n", bufmodes[bufmode]);
ok(c == outbuffer[sizeof(outbuffer) - 1],
"getc did not return ungetc'd data for bufmode=%x\n", bufmodes[bufmode]);
ok(!feof(file), "feof after getc returned EOF prematurely for bufmode=%x\n", bufmodes[bufmode]);
}
ok((c = fgetc(file)) == EOF, "getc did not return EOF for bufmode=%x\n", bufmodes[bufmode]);
ok(feof(file), "feof after getc did not return EOF for bufmode=%x\n", bufmodes[bufmode]);