From a42bf0134c74cd1971750812b0df18b6e8ffacdf Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Sun, 24 Apr 2011 11:01:59 +0200 Subject: [PATCH] msvcrt: ungetc must create a buffer, even if _IONBF has been set with setvbuf. --- dlls/msvcrt/file.c | 2 +- dlls/msvcrt/tests/file.c | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index c1a77856095..e34c11f0a15 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -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++; } diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index 5aaaaf71a73..0231f72ae1b 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -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]);