ruby-changes:4195
From: ko1@a...
Date: Tue, 4 Mar 2008 14:36:32 +0900 (JST)
Subject: [ruby-changes:4195] naruse - Ruby:r15685 (trunk): * io.c (open_key_args): use rb_io_open_with_args instead of rb_f_open.
naruse 2008-03-04 14:36:08 +0900 (Tue, 04 Mar 2008) New Revision: 15685 Modified files: trunk/ChangeLog trunk/io.c Log: * io.c (open_key_args): use rb_io_open_with_args instead of rb_f_open. [ruby-core:15763] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15685&r2=15684&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/io.c?r1=15685&r2=15684&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 15684) +++ ChangeLog (revision 15685) @@ -1,3 +1,8 @@ +Tue Mar 04 14:35:12 2008 NARUSE, Yui <naruse@r...> + + * io.c (open_key_args): use rb_io_open_with_args instead of rb_f_open. + [ruby-core:15763] + Tue Mar 4 13:41:46 2008 Tanaka Akira <akr@f...> * gc.c (add_heap): fix previous change. [ruby-dev:33988] Index: io.c =================================================================== --- io.c (revision 15684) +++ io.c (revision 15685) @@ -4093,6 +4093,24 @@ } static VALUE +rb_io_open_with_args(int argc, VALUE *argv) +{ + const char *mode; + VALUE pname, pmode; + + if (rb_scan_args(argc, argv, "11", &pname, &pmode) == 1) { + mode = "r"; + } + else if (FIXNUM_P(pmode)) { + mode = rb_io_modenum_mode(FIX2INT(pmode)); + } + else { + mode = StringValueCStr(pmode); + } + return rb_io_open(StringValueCStr(pname), mode); +} + +static VALUE io_reopen(VALUE io, VALUE nfile) { rb_io_t *fptr, *orig; @@ -5927,15 +5945,14 @@ rb_ary_concat(args, v); MEMCPY(RARRAY_PTR(args)+1, RARRAY_PTR(v), VALUE, RARRAY_LEN(v)); - arg->io = rb_f_open(RARRAY_LEN(args), RARRAY_PTR(args)); + arg->io = rb_io_open_with_args(RARRAY_LEN(args), RARRAY_PTR(args)); return; } v = rb_hash_aref(opt, mode); if (!NIL_P(v)) { arg->io = rb_io_open(RSTRING_PTR(argv[0]), StringValueCStr(v)); } - - if (!arg->io) { + else { arg->io = rb_io_open(RSTRING_PTR(argv[0]), "r"); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/