From 9fd5e5e0e5126156edaa5759813dc0da4faee058 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 28 Nov 2004 16:31:12 +0000 Subject: * io.c (rb_io_check_writable): restrict io_seek by READ_DATA_PENDING because io_seek(fptr, 0, SEEK_CUR) is meaningful only if read buffer is not empty. call io_seek regardless of NEED_IO_SEEK_BETWEEN_RW. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@7404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ io.c | 5 ++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f6cdccd86..e844d180b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Nov 29 01:18:18 2004 Tanaka Akira + + * io.c (rb_io_check_writable): restrict io_seek by + READ_DATA_PENDING because io_seek(fptr, 0, SEEK_CUR) is + meaningful only if read buffer is not empty. + call io_seek regardless of NEED_IO_SEEK_BETWEEN_RW. + Sat Nov 27 21:43:39 2004 Tanaka Akira * io.c: avoid data lost with nonblocking fd and diff --git a/io.c b/io.c index a24faf964..cc1b58395 100644 --- a/io.c +++ b/io.c @@ -251,11 +251,10 @@ rb_io_check_writable(fptr) if (!(fptr->mode & FMODE_WRITABLE)) { rb_raise(rb_eIOError, "not opened for writing"); } -#if NEED_IO_SEEK_BETWEEN_RW - if ((fptr->mode & FMODE_RBUF) && !feof(fptr->f) && !fptr->f2) { + if ((fptr->mode & FMODE_RBUF) && !feof(fptr->f) && !fptr->f2 && + READ_DATA_PENDING(fptr->f)) { io_seek(fptr, 0, SEEK_CUR); } -#endif if (!fptr->f2) { fptr->mode &= ~FMODE_RBUF; } -- cgit