From: Piotr Caban piotr@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56837 --- dlls/msvcrt/file.c | 2 ++ dlls/msvcrt/tests/file.c | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 98df53be77d..97bfc746abc 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -4101,6 +4101,8 @@ int CDECL _flsbuf(int c, FILE* file) int res = 0;
if(file->_cnt <= 0) { + if(!file->_cnt && get_ioinfo_nolock(file->_file)->wxflag & WX_APPEND) + _lseek(file->_file, 0, FILE_END); res = msvcrt_flush_buffer(file); if(res) return res; diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index 9ce3654bebe..6ead01e9e2d 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -695,11 +695,9 @@ static void test_fputc( void )
static void test_flsbuf( void ) { + int bufmode, ret, c, pos; char* tempf; FILE *tempfh; - int c; - int ret; - int bufmode; static const int bufmodes[] = {_IOFBF,_IONBF};
tempf=_tempnam(".","wne"); @@ -756,6 +754,16 @@ static void test_flsbuf( void ) ok(c == EOF, "there should only be one byte\n"); fclose(tempfh);
+ tempfh = fopen(tempf,"ab"); + ok(tempfh != NULL, "fopen failed\n"); + pos = _lseek(_fileno(tempfh), 0, SEEK_CUR); + ok(!pos, "incorrect stream position: %d\n", pos); + ret = _flsbuf(0, tempfh); + ok(!ret, "_flsbuf returned %x\n", ret); + pos = _lseek(_fileno(tempfh), 0, SEEK_CUR); + ok(pos == 1, "incorrect stream position: %d\n", pos); + fclose(tempfh); + unlink(tempf); free(tempf); }