Author: tkreuzer
Date: Wed Jun 1 12:08:02 2011
New Revision: 52040
URL:
http://svn.reactos.org/svn/reactos?rev=52040&view=rev
Log:
[CRT]
in _flsbuf, always reset _cnt to 0 and don't allocate/use a buffer when _IONBUF is
set. Fixes a regression in msvcrt_winetest file.
See issue #5829 for more details.
Modified:
trunk/reactos/lib/sdk/crt/stdio/_flsbuf.c
Modified: trunk/reactos/lib/sdk/crt/stdio/_flsbuf.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdio/_flsbuf.…
==============================================================================
--- trunk/reactos/lib/sdk/crt/stdio/_flsbuf.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/stdio/_flsbuf.c [iso-8859-1] Wed Jun 1 12:08:02 2011
@@ -24,6 +24,9 @@
return EOF;
}
+ /* Always reset _cnt */
+ stream->_cnt = 0;
+
/* Check if this was a read buffer */
if (stream->_flag & _IOREAD)
{
@@ -31,7 +34,6 @@
if (!(stream->_flag & _IOEOF))
{
stream->_flag |= _IOERR;
- stream->_cnt = 0;
return EOF;
}
@@ -43,16 +45,17 @@
stream->_flag &= ~(_IOREAD|_IOEOF);
stream->_flag |= _IOWRT;
- /* If we have no buffer, try to allocate one */
- if (!stream->_base && stream != stdout && stream != stderr)
+ /* Check if should get a buffer */
+ if (!(stream->_flag & _IONBF) && stream != stdout && stream !=
stderr)
{
- alloc_buffer(stream);
+ /* If we have no buffer, try to allocate one */
+ if (!stream->_base) alloc_buffer(stream);
}
- /* Check if we have a buffer now */
- if (stream->_base)
+ /* Check if we can use a buffer now */
+ if (stream->_base && !(stream->_flag & _IONBF))
{
- /* We have one, check if there is something to write */
+ /* We can, check if there is something to write */
count = stream->_ptr - stream->_base;
if (count > 0)
written = _write(stream->_file, stream->_base, count);