Grazvydas Ignotas : msvcrt: Implement bufsiz block flushing behavior.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Jun 25 13:42:03 CDT 2014
Module: wine
Branch: master
Commit: ad968be779fff244574eda83d101ab8393513bf4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ad968be779fff244574eda83d101ab8393513bf4
Author: Grazvydas Ignotas <notasas at gmail.com>
Date: Wed Jun 18 13:55:53 2014 +0300
msvcrt: Implement bufsiz block flushing behavior.
---
dlls/msvcrt/file.c | 12 ++++++++++++
dlls/msvcrt/tests/file.c | 2 +-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 5a9edbe..b60e306 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -3720,6 +3720,18 @@ MSVCRT_size_t CDECL MSVCRT_fwrite(const void *ptr, MSVCRT_size_t size, MSVCRT_si
}
written += wrcnt;
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 {
if(MSVCRT__flsbuf(*(const char*)ptr, file) == MSVCRT_EOF)
break;
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c
index eb21697..422e41d 100644
--- a/dlls/msvcrt/tests/file.c
+++ b/dlls/msvcrt/tests/file.c
@@ -2243,7 +2243,7 @@ static void test_write_flush_size(FILE *file, int bufsize)
fseek(file, 0, SEEK_SET);
ok(fread(inbuffer, 1, bufsize, file) == bufsize, "read failed\n");
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
ok(memcmp(outbuffer, inbuffer, bufsize) != 0, "unexpected flush by %d byte write\n", size);
}
More information about the wine-cvs
mailing list