summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-02-01 03:12:21 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-02-01 03:12:21 +0000
commite4b53b22228d935847b72e8f9ab0f49a15b54215 (patch)
treeae6cd78921bf626d54145b5485474bf59c3dceb4 /io.c
parent005f12582975d8382851b740690f97dba35aaa2a (diff)
2000-02-01
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c15
1 files changed, 11 insertions, 4 deletions
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);