From a1b57d0add85a248666fb55c58aa8c0c772136fc Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 24 Aug 1999 08:21:56 +0000 Subject: 1.4.1 to be git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index fb1e0d894b..93cf75ece2 100644 --- a/io.c +++ b/io.c @@ -184,7 +184,7 @@ io_write(io, str) str = rb_obj_as_string(str); if (RSTRING(str)->len == 0) return INT2FIX(0); - if (BUILTIN_TYPE(io) != T_FILE) { + if (TYPE(io) != T_FILE) { /* port is not IO, call write method for it. */ return rb_funcall(io, id_write, 1, str); } @@ -1823,13 +1823,12 @@ rb_io_printf(argc, argv, out) VALUE argv[]; VALUE out; { - rb_funcall(out, id_write, 1, rb_f_sprintf(argc, argv)); - + io_write(out, rb_f_sprintf(argc, argv)); return Qnil; } static VALUE -rb_rb_f_printf(argc, argv) +rb_f_printf(argc, argv) int argc; VALUE argv[]; { @@ -1839,15 +1838,12 @@ rb_rb_f_printf(argc, argv) if (TYPE(argv[0]) == T_STRING) { out = rb_defout; } - else if (rb_respond_to(argv[0], id_write)) { + else { out = argv[0]; argv++; argc--; } - else { - rb_raise(rb_eNameError, "output must responds to `write'"); - } - rb_funcall(out, id_write, 1, rb_f_sprintf(argc, argv)); + io_write(out, rb_f_sprintf(argc, argv)); return Qnil; } @@ -3151,7 +3147,7 @@ Init_IO() rb_define_global_function("syscall", rb_f_syscall, -1); rb_define_global_function("open", rb_f_open, -1); - rb_define_global_function("printf", rb_rb_f_printf, -1); + rb_define_global_function("printf", rb_f_printf, -1); rb_define_global_function("print", rb_f_print, -1); rb_define_global_function("putc", rb_f_putc, 1); rb_define_global_function("puts", rb_f_puts, -1); -- cgit v1.2.3