diff options
Diffstat (limited to 'libio')
-rw-r--r-- | libio/fileops.c | 6 | ||||
-rw-r--r-- | libio/oldfileops.c | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/libio/fileops.c b/libio/fileops.c index 3ad9b74..74d5cd0 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -1281,7 +1281,7 @@ _IO_new_file_xsputn (f, data, n) register const char *s = (const char *) data; _IO_size_t to_do = n; int must_flush = 0; - _IO_size_t count; + _IO_size_t count = 0; if (n <= 0) return 0; @@ -1290,7 +1290,6 @@ _IO_new_file_xsputn (f, data, n) (or the filebuf is unbuffered), use sys_write directly. */ /* First figure out how much space is available in the buffer. */ - count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */ if ((f->_flags & _IO_LINE_BUF) && (f->_flags & _IO_CURRENTLY_PUTTING)) { count = f->_IO_buf_end - f->_IO_write_ptr; @@ -1308,6 +1307,9 @@ _IO_new_file_xsputn (f, data, n) } } } + else if (f->_IO_write_end > f->_IO_write_ptr) + count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */ + /* Then fill the buffer. */ if (count > 0) { diff --git a/libio/oldfileops.c b/libio/oldfileops.c index 2dd6182..cd54ea5 100644 --- a/libio/oldfileops.c +++ b/libio/oldfileops.c @@ -695,7 +695,7 @@ _IO_old_file_xsputn (f, data, n) register const char *s = (char *) data; _IO_size_t to_do = n; int must_flush = 0; - _IO_size_t count; + _IO_size_t count = 0; if (n <= 0) return 0; @@ -704,7 +704,6 @@ _IO_old_file_xsputn (f, data, n) (or the filebuf is unbuffered), use sys_write directly. */ /* First figure out how much space is available in the buffer. */ - count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */ if ((f->_flags & _IO_LINE_BUF) && (f->_flags & _IO_CURRENTLY_PUTTING)) { count = f->_IO_buf_end - f->_IO_write_ptr; @@ -722,6 +721,9 @@ _IO_old_file_xsputn (f, data, n) } } } + else if (f->_IO_write_end > f->_IO_write_ptr) + count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */ + /* Then fill the buffer. */ if (count > 0) { |