From: Christoph von Wittich Date: Fri, 14 Feb 2014 20:19:12 +0000 (+0000) Subject: [crt] X-Git-Tag: ReactOS-0.3.16-CLT2014~149 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=9dd9257e8ad27dd8c9d6e7e8f67b884dc9061157 [crt] sync _fflush and _flushall with wine 1.7.11 svn path=/trunk/; revision=62169 --- diff --git a/reactos/lib/sdk/crt/stdio/file.c b/reactos/lib/sdk/crt/stdio/file.c index ba95e5c0cc6..a08d59e16f8 100644 --- a/reactos/lib/sdk/crt/stdio/file.c +++ b/reactos/lib/sdk/crt/stdio/file.c @@ -734,10 +734,8 @@ int CDECL _wunlink(const wchar_t *path) /* _flushall calls fflush which calls _flushall */ int CDECL fflush(FILE* file); -/********************************************************************* - * _flushall (MSVCRT.@) - */ -int CDECL _flushall(void) +/* INTERNAL: Flush all stream buffer */ +static int flush_all_buffers(int mask) { int i, num_flushed = 0; FILE *file; @@ -748,8 +746,8 @@ int CDECL _flushall(void) if (file->_flag) { - if(file->_flag & _IOWRT) { - fflush(file); + if(file->_flag & mask) { + fflush(file); num_flushed++; } } @@ -760,22 +758,41 @@ int CDECL _flushall(void) return num_flushed; } +/********************************************************************* + * _flushall (MSVCRT.@) + */ +int CDECL _flushall(void) +{ + return flush_all_buffers(_IOWRT | _IOREAD); +} + /********************************************************************* * fflush (MSVCRT.@) */ int CDECL fflush(FILE* file) { if(!file) { - _flushall(); + flush_all_buffers(_IOWRT); } else if(file->_flag & _IOWRT) { int res; _lock_file(file); res = flush_buffer(file); + /* FIXME + if(!res && (file->_flag & _IOCOMMIT)) + res = _commit(file->_file) ? EOF : 0; + */ _unlock_file(file); return res; - } + } else if(file->_flag & _IOREAD) { + _lock_file(file); + file->_cnt = 0; + file->_ptr = file->_base; + _unlock_file(file); + + return 0; + } return 0; }