ruby-changes:17430
From: naruse <ko1@a...>
Date: Mon, 11 Oct 2010 06:35:06 +0900 (JST)
Subject: [ruby-changes:17430] Ruby:r29435 (trunk): * io.c (rb_io_set_encoding): use rb_funcall2 when the io is not
naruse 2010-10-11 06:29:29 +0900 (Mon, 11 Oct 2010) New Revision: 29435 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29435 Log: * io.c (rb_io_set_encoding): use rb_funcall2 when the io is not a T_FILE. [ruby-dev:42356] Modified files: trunk/ChangeLog trunk/io.c Index: ChangeLog =================================================================== --- ChangeLog (revision 29434) +++ ChangeLog (revision 29435) @@ -1,3 +1,8 @@ +Mon Oct 11 06:11:30 2010 NARUSE, Yui <naruse@r...> + + * io.c (rb_io_set_encoding): use rb_funcall2 when the io is not + a T_FILE. [ruby-dev:42356] + Sun Oct 10 18:42:23 2010 Akinori MUSHA <knu@i...> * lib/set.rb (Set#replace): Apply a bit of optimization. Index: io.c =================================================================== --- io.c (revision 29434) +++ io.c (revision 29435) @@ -137,7 +137,7 @@ static VALUE argf; -static ID id_write, id_read, id_getc, id_flush, id_readpartial; +static ID id_write, id_read, id_getc, id_flush, id_readpartial, id_set_encoding; static VALUE sym_mode, sym_perm, sym_extenc, sym_intenc, sym_encoding, sym_open_args; static VALUE sym_textmode, sym_binmode, sym_autoclose; @@ -8687,6 +8687,10 @@ rb_io_t *fptr; VALUE v1, v2, opt; + if (TYPE(io) != T_FILE) { + return rb_funcall2(io, id_set_encoding, argc, argv); + } + argc = rb_scan_args(argc, argv, "11:", &v1, &v2, &opt); GetOpenFile(io, fptr); io_encoding_set(fptr, v1, v2, opt); @@ -9863,6 +9867,7 @@ id_getc = rb_intern("getc"); id_flush = rb_intern("flush"); id_readpartial = rb_intern("readpartial"); + id_set_encoding = rb_intern("set_encoding"); rb_define_global_function("syscall", rb_f_syscall, -1); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/