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

msvcrt: Implement bufsiz block flushing behavior.

parent c6a16069
...@@ -3720,6 +3720,18 @@ MSVCRT_size_t CDECL MSVCRT_fwrite(const void *ptr, MSVCRT_size_t size, MSVCRT_si ...@@ -3720,6 +3720,18 @@ MSVCRT_size_t CDECL MSVCRT_fwrite(const void *ptr, MSVCRT_size_t size, MSVCRT_si
} }
written += wrcnt; written += wrcnt;
wrcnt = 0; wrcnt = 0;
} else if(file->_bufsiz && wrcnt >= file->_bufsiz) {
MSVCRT_size_t pcnt=(wrcnt / file->_bufsiz) * file->_bufsiz;
if(msvcrt_flush_buffer(file) == MSVCRT_EOF)
break;
if(MSVCRT__write(file->_file, ptr, pcnt) <= 0) {
file->_flag |= MSVCRT__IOERR;
break;
}
written += pcnt;
wrcnt -= pcnt;
ptr = (const char*)ptr + pcnt;
} else { } else {
if(MSVCRT__flsbuf(*(const char*)ptr, file) == MSVCRT_EOF) if(MSVCRT__flsbuf(*(const char*)ptr, file) == MSVCRT_EOF)
break; break;
......
...@@ -2243,7 +2243,7 @@ static void test_write_flush_size(FILE *file, int bufsize) ...@@ -2243,7 +2243,7 @@ static void test_write_flush_size(FILE *file, int bufsize)
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)
todo_wine ok(memcmp(outbuffer, inbuffer, bufsize) == 0, "missing flush by %d byte write\n", size); ok(memcmp(outbuffer, inbuffer, bufsize) == 0, "missing flush by %d byte write\n", size);
else else
ok(memcmp(outbuffer, inbuffer, bufsize) != 0, "unexpected flush by %d byte write\n", size); ok(memcmp(outbuffer, inbuffer, bufsize) != 0, "unexpected flush by %d byte write\n", size);
} }
......
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