about summary refs log tree commit diff
path: root/libio
diff options
context:
space:
mode:
Diffstat (limited to 'libio')
-rw-r--r--libio/fileops.c10
-rw-r--r--libio/genops.c2
2 files changed, 10 insertions, 2 deletions
diff --git a/libio/fileops.c b/libio/fileops.c
index b4bd5ce7cd..1851d9a1fa 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -308,7 +308,15 @@ DEFUN(_IO_file_overflow, (f, ch),
 	  _IO_doallocbuf(f);
 	  _IO_setg (f, f->_IO_buf_base, f->_IO_buf_base, f->_IO_buf_base);
 	}
-      /* Otherwise must be currently reading. */
+      /* Otherwise must be currently reading.
+	 If _IO_read_ptr (and hence also _IO_read_end) is at the buffer end,
+	 logically slide the buffer forwards one block (by setting the
+	 read pointers to all point at the beginning of the block).  This
+	 makes room for subsequent output.
+	 Otherwise, set the read pointers to _IO_read_end (leaving that
+	 alone, so it can continue to correspond to the external position). */
+      if (f->_IO_read_ptr == f->_IO_buf_end)
+	f->_IO_read_end = f->_IO_read_ptr = f->_IO_buf_base;
       f->_IO_write_ptr = f->_IO_read_ptr;
       f->_IO_write_base = f->_IO_write_ptr;
       f->_IO_write_end = f->_IO_buf_end;
diff --git a/libio/genops.c b/libio/genops.c
index bd741ec66e..fc4c61d9a4 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -466,7 +466,7 @@ DEFUN(_IO_init, (fp, flags),
   fp->_markers = NULL;
   fp->_cur_column = 0;
 #ifdef _IO_MTSAFE_IO
-  __libc_lock_init (*fp->_lock);
+  __libc_lock_init_recursive (*fp->_lock);
 #endif
 }