Commit c6a16069 authored by Grazvydas Ignotas's avatar Grazvydas Ignotas Committed by Alexandre Julliard

msvcrt: Clear _cnt on buffer flush.

parent 61d49a8a
...@@ -595,7 +595,7 @@ static int msvcrt_flush_buffer(MSVCRT_FILE* file) ...@@ -595,7 +595,7 @@ static int msvcrt_flush_buffer(MSVCRT_FILE* file)
return MSVCRT_EOF; return MSVCRT_EOF;
} }
file->_ptr=file->_base; file->_ptr=file->_base;
file->_cnt=file->_bufsiz; file->_cnt=0;
} }
return 0; return 0;
} }
...@@ -3659,14 +3659,15 @@ int CDECL MSVCRT__flsbuf(int c, MSVCRT_FILE* file) ...@@ -3659,14 +3659,15 @@ int CDECL MSVCRT__flsbuf(int c, MSVCRT_FILE* file)
if(file->_bufsiz) { if(file->_bufsiz) {
int res = 0; int res = 0;
if(file->_cnt <= 0) if(file->_cnt <= 0) {
res = msvcrt_flush_buffer(file); res = msvcrt_flush_buffer(file);
if(!res) { if(res)
*file->_ptr++ = c; return res;
file->_cnt--; file->_cnt=file->_bufsiz;
} }
*file->_ptr++ = c;
return res ? res : c&0xff; file->_cnt--;
return c&0xff;
} else { } else {
unsigned char cc=c; unsigned char cc=c;
int len; int len;
......
...@@ -2239,7 +2239,7 @@ static void test_write_flush_size(FILE *file, int bufsize) ...@@ -2239,7 +2239,7 @@ static void test_write_flush_size(FILE *file, int bufsize)
*/ */
lseek(fd, 1, SEEK_SET); lseek(fd, 1, SEEK_SET);
fflush(file); fflush(file);
todo_wine ok(file->_cnt == 0, "_cnt should be 0 after fflush, but is %d\n", file->_cnt); ok(file->_cnt == 0, "_cnt should be 0 after fflush, but is %d\n", file->_cnt);
fseek(file, 0, SEEK_SET); fseek(file, 0, SEEK_SET);
ok(fread(inbuffer, 1, bufsize, file) == bufsize, "read failed\n"); ok(fread(inbuffer, 1, bufsize, file) == bufsize, "read failed\n");
if (size == bufsize) if (size == bufsize)
......
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