Project

General

Profile

Feature #7067 » patch.diff

Glass_saga (Masaki Matsushita), 09/27/2012 11:34 PM

View differences:

io.c
}
if (!NIL_P(nmode)) {
int fmode = rb_io_modestr_fmode(StringValueCStr(nmode));
VALUE intmode;
int fmode;
if (!NIL_P(intmode = rb_check_to_integer(nmode, "to_int"))) {
oflags = NUM2INT(intmode);
fmode = rb_io_oflags_fmode(oflags);
}
else {
fmode = rb_io_modestr_fmode(StringValueCStr(nmode));
}
if (IS_PREP_STDIO(fptr) &&
((fptr->mode & FMODE_READWRITE) & (fmode & FMODE_READWRITE)) !=
(fptr->mode & FMODE_READWRITE)) {
......
rb_io_fmode_modestr(fmode));
}
fptr->mode = fmode;
rb_io_mode_enc(fptr, StringValueCStr(nmode));
if (NIL_P(intmode)) {
rb_io_mode_enc(fptr, StringValueCStr(nmode));
}
fptr->encs.ecflags = 0;
fptr->encs.ecopts = Qnil;
}
test/ruby/test_io.rb
}
end
def test_reopen_mode
make_tempfile {|t|
open(__FILE__) do |f|
assert_nothing_raised {
f.reopen(t.path, "r")
assert_equal("foo\n", f.gets)
}
end
open(__FILE__) do |f|
assert_nothing_raised {
f.reopen(t.path, File::RDONLY)
assert_equal("foo\n", f.gets)
}
end
}
end
def test_foreach
a = []
IO.foreach("|" + EnvUtil.rubybin + " -e 'puts :foo; puts :bar; puts :baz'") {|x| a << x }
(2-2/2)