From e4b53b22228d935847b72e8f9ab0f49a15b54215 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 1 Feb 2000 03:12:21 +0000 Subject: 2000-02-01 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index 6222d9047e..88c95a02c5 100644 --- a/io.c +++ b/io.c @@ -1576,7 +1576,12 @@ rb_io_s_popen(argc, argv, self) } Check_SafeStr(pname); port = pipe_open(RSTRING(pname)->ptr, mode); - if (NIL_P(port)) return Qnil; + if (NIL_P(port)) { + rb_yield(port); + } + else if (rb_iterator_p()) { + return rb_ensure(rb_yield, port, rb_io_close, port); + } return port; } @@ -1647,8 +1652,10 @@ rb_f_open(argc, argv) } port = pipe_open(RSTRING(pname)->ptr+1, mode); - if (NIL_P(port)) return Qnil; - if (rb_iterator_p()) { + if (NIL_P(port)) { + rb_yield(port); + } + else if (rb_iterator_p()) { return rb_ensure(rb_yield, port, rb_io_close, port); } @@ -3222,7 +3229,7 @@ Init_IO() rb_rs = rb_default_rs = rb_str_new2("\n"); rb_output_rs = Qnil; rb_global_variable(&rb_default_rs); - rb_str_freeze(rb_default_rs); /* avoid modifying RS_default */ + OBJ_FREEZE(rb_default_rs); /* avoid modifying RS_default */ rb_define_hooked_variable("$/", &rb_rs, 0, rb_str_setter); rb_define_hooked_variable("$-0", &rb_rs, 0, rb_str_setter); rb_define_hooked_variable("$\\", &rb_output_rs, 0, rb_str_setter); -- cgit v1.2.3