diff options
author | Ulrich Drepper <drepper@redhat.com> | 2005-09-27 19:40:49 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2005-09-27 19:40:49 +0000 |
commit | cae6ebb2c9d01846d4f5085590dd5c0893825773 (patch) | |
tree | 4ccea370a6ae5766011a8c79acfed7521327ed31 /libio/fileops.c | |
parent | 7dac9f3d90fc108d2db8e305f6d3d475b6c5b793 (diff) | |
download | glibc-cae6ebb2c9d01846d4f5085590dd5c0893825773.tar.gz glibc-cae6ebb2c9d01846d4f5085590dd5c0893825773.tar.xz glibc-cae6ebb2c9d01846d4f5085590dd5c0893825773.zip |
[BZ #1078]
2005-09-27 Ulrich Drepper <drepper@redhat.com> [BZ #1078] * libio/fileops.c (_IO_new_file_xsputn): Determine amount of available space in non-line-buffered buffer correctly. * libio/oldfileops.c (_IO_old_file_xsputn): Likewise. * stdio-common/Makefile (tests): Add tst-fwrite. * stdio-common/tst-fwrite.c: New file.
Diffstat (limited to 'libio/fileops.c')
-rw-r--r-- | libio/fileops.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libio/fileops.c b/libio/fileops.c index 3ad9b74011..74d5cd0dbc 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) { |