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.

svn path=/trunk/; revision=52040
This commit is contained in:
Timo Kreuzer 2011-06-01 12:08:02 +00:00
parent 80f8e1b66c
commit 29a7aa1288

View file

@ -24,6 +24,9 @@ _flsbuf(int ch, FILE *stream)
return EOF;
}
/* Always reset _cnt */
stream->_cnt = 0;
/* Check if this was a read buffer */
if (stream->_flag & _IOREAD)
{
@ -31,7 +34,6 @@ _flsbuf(int ch, FILE *stream)
if (!(stream->_flag & _IOEOF))
{
stream->_flag |= _IOERR;
stream->_cnt = 0;
return EOF;
}
@ -43,16 +45,17 @@ _flsbuf(int ch, FILE *stream)
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);