summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-05 15:55:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-05 15:55:09 +0000
commitce44928d2b4d32b41f9a19097fb7bd7b2c13c4bd (patch)
treee2e9c28e8caf5535b343988de6fa23ed0f941695 /io.c
parentcded3d5c93f0964fc504a4344146e3624a9875a1 (diff)
* error.c (Init_Exception): remove Exception#to_str. [Ruby2]
* eval.c (error_print): should no call "to_str" anymore use "message" method instead. * io.c (rb_f_open): Kernel#open() calls "to_open" if the first argument responds to it. [Ruby2] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/io.c b/io.c
index ef46499920..a5f6f1431d 100644
--- a/io.c
+++ b/io.c
@@ -3039,10 +3039,17 @@ rb_f_open(argc, argv)
VALUE *argv;
{
if (argc >= 1) {
- char *str = StringValuePtr(argv[0]);
+ ID to_open = rb_intern("to_open");
- if (str[0] == '|') {
- return rb_io_popen(str+1, argc, argv, rb_cIO);
+ if (rb_respond_to(argv[0], to_open)) {
+ return rb_funcall2(argv[0], to_open, argc-1, argv+1);
+ }
+ else {
+ char *str = StringValuePtr(argv[0]);
+
+ if (str[0] == '|') {
+ return rb_io_popen(str+1, argc, argv, rb_cIO);
+ }
}
}
return rb_io_s_open(argc, argv, rb_cFile);