aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-15 05:58:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-15 05:58:00 +0000
commit6069202867ab9016aaf66301468d5f4c64b3b028 (patch)
tree93e83f3ed141511424a35051c1e878244a1b41da /io.c
parentc7afd1aef49c0dc459b3d9dda6ddc51e301f5473 (diff)
downloadruby-6069202867ab9016aaf66301468d5f4c64b3b028.tar.gz
* io.c (io_reopen): unread current buffer before telling the
position, for the case of reopening same file. [ruby-dev:39479] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/io.c b/io.c
index 9b0aadfda8..ccec1601dc 100644
--- a/io.c
+++ b/io.c
@@ -5654,13 +5654,6 @@ io_reopen(VALUE io, VALUE nfile)
rb_io_fmode_modestr(orig->mode));
}
}
- if (orig->mode & FMODE_READABLE) {
- pos = io_tell(orig);
- }
- if (orig->mode & FMODE_WRITABLE) {
- if (io_fflush(orig) < 0)
- rb_sys_fail(0);
- }
if (fptr->mode & FMODE_WRITABLE) {
if (io_fflush(fptr) < 0)
rb_sys_fail(0);
@@ -5668,6 +5661,13 @@ io_reopen(VALUE io, VALUE nfile)
else {
io_tell(fptr);
}
+ if (orig->mode & FMODE_READABLE) {
+ pos = io_tell(orig);
+ }
+ if (orig->mode & FMODE_WRITABLE) {
+ if (io_fflush(orig) < 0)
+ rb_sys_fail(0);
+ }
/* copy rb_io_t structure */
fptr->mode = orig->mode | (fptr->mode & FMODE_PREP);