* io.c (pipe_close): removed.
(pipe_yield): defined. (rb_io_s_pipe): use pipe_yield. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d42b3e5c88
commit
bb4329becd
@ -1,3 +1,9 @@
|
||||
Thu Dec 25 18:36:04 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* io.c (pipe_close): removed.
|
||||
(pipe_yield): defined.
|
||||
(rb_io_s_pipe): use pipe_yield.
|
||||
|
||||
Thu Dec 25 17:49:45 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* transcode.c (decorate_convpath): show type of escaping for
|
||||
|
15
io.c
15
io.c
@ -7003,18 +7003,9 @@ io_encoding_set(rb_io_t *fptr, VALUE v1, VALUE v2, VALUE opt)
|
||||
}
|
||||
|
||||
static VALUE
|
||||
pipe_close(VALUE args)
|
||||
pipe_yield(VALUE rw)
|
||||
{
|
||||
VALUE *rw = (VALUE*)args;
|
||||
VALUE io;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
io = rw[i];
|
||||
if (!rb_io_closed(io))
|
||||
rb_io_close(io);
|
||||
}
|
||||
return Qnil;
|
||||
return rb_ensure(rb_yield, rw, io_close, rb_ary_entry(rw, 1));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -7122,7 +7113,7 @@ rb_io_s_pipe(int argc, VALUE *argv, VALUE klass)
|
||||
rw[0] = r;
|
||||
rw[1] = w;
|
||||
if (rb_block_given_p()) {
|
||||
return rb_ensure(rb_yield, ret, pipe_close, (VALUE)rw);
|
||||
return rb_ensure(pipe_yield, ret, io_close, r);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -50,6 +50,19 @@ class TestIO < Test::Unit::TestCase
|
||||
assert(x[1].closed?)
|
||||
end
|
||||
|
||||
def test_pipe_block_close
|
||||
4.times {|i|
|
||||
x = nil
|
||||
IO.pipe {|r, w|
|
||||
x = [r,w]
|
||||
r.close if (i&1) == 0
|
||||
w.close if (i&2) == 0
|
||||
}
|
||||
assert(x[0].closed?)
|
||||
assert(x[1].closed?)
|
||||
}
|
||||
end
|
||||
|
||||
def test_gets_rs
|
||||
# default_rs
|
||||
r, w = IO.pipe
|
||||
|
Loading…
x
Reference in New Issue
Block a user