* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@7404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2004-11-28 16:31:12 +00:00
parent 44b9ca6696
commit 06646d1b4e
2 changed files with 9 additions and 3 deletions

View File

@ -1,3 +1,10 @@
Mon Nov 29 01:18:18 2004 Tanaka Akira <akr@m17n.org>
* 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.
Sun Nov 28 15:57:58 2004 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/rss.rb (RSS::Element#tag): not use block_given? for

5
io.c
View File

@ -261,11 +261,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;
}