mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (io_reopen): discards read buffer. [ruby-core:24240]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5e65d8f433
commit
53163f8138
2 changed files with 13 additions and 0 deletions
3
io.c
3
io.c
|
@ -5648,6 +5648,9 @@ io_reopen(VALUE io, VALUE nfile)
|
|||
if (io_fflush(fptr) < 0)
|
||||
rb_sys_fail(0);
|
||||
}
|
||||
else {
|
||||
io_tell(fptr);
|
||||
}
|
||||
|
||||
/* copy rb_io_t structure */
|
||||
fptr->mode = orig->mode | (fptr->mode & FMODE_PREP);
|
||||
|
|
|
@ -1270,6 +1270,16 @@ class TestIO < Test::Unit::TestCase
|
|||
assert_equal("foo\n", f.gets)
|
||||
}
|
||||
end
|
||||
|
||||
open(__FILE__) do |f|
|
||||
f.gets
|
||||
f2 = open(t.path)
|
||||
f2.gets
|
||||
assert_nothing_raised {
|
||||
f.reopen(f2)
|
||||
assert_equal("bar\n", f.gets, '[ruby-core:24240]')
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def test_foreach
|
||||
|
|
Loading…
Add table
Reference in a new issue