mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (argf_close): untie tied io before closing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
684a6059e9
commit
a77d2ac5ba
2 changed files with 13 additions and 3 deletions
|
@ -1,4 +1,6 @@
|
|||
Thu Nov 11 21:56:10 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Thu Nov 11 23:03:12 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* io.c (argf_close): untie tied io before closing.
|
||||
|
||||
* io.c (argf_write): add ARGF.write and so on.
|
||||
|
||||
|
|
12
io.c
12
io.c
|
@ -315,10 +315,15 @@ rb_io_set_write_io(VALUE io, VALUE w)
|
|||
{
|
||||
VALUE write_io;
|
||||
rb_io_check_initialized(RFILE(io)->fptr);
|
||||
GetWriteIO(w);
|
||||
if (!RTEST(w)) {
|
||||
w = 0;
|
||||
}
|
||||
else {
|
||||
GetWriteIO(w);
|
||||
}
|
||||
write_io = RFILE(io)->fptr->tied_io_for_writing;
|
||||
RFILE(io)->fptr->tied_io_for_writing = w;
|
||||
return write_io;
|
||||
return write_io ? write_io : Qnil;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -6781,6 +6786,9 @@ argf_forward(int argc, VALUE *argv, VALUE argf)
|
|||
static void
|
||||
argf_close(VALUE file)
|
||||
{
|
||||
if (RB_TYPE_P(file, T_FILE)) {
|
||||
rb_io_set_write_io(file, Qnil);
|
||||
}
|
||||
rb_funcall3(file, rb_intern("close"), 0, 0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue