ruby-changes:37879
From: nobu <ko1@a...>
Date: Fri, 13 Mar 2015 15:03:22 +0900 (JST)
Subject: [ruby-changes:37879] nobu:r49960 (trunk): io.c: rb_io_get_fptr
nobu 2015-03-13 15:03:03 +0900 (Fri, 13 Mar 2015) New Revision: 49960 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49960 Log: io.c: rb_io_get_fptr * io.c (rb_io_get_fptr): return non-null fptr. Modified files: trunk/io.c Index: io.c =================================================================== --- io.c (revision 49959) +++ io.c (revision 49960) @@ -651,6 +651,13 @@ rb_io_check_closed(rb_io_t *fptr) https://github.com/ruby/ruby/blob/trunk/io.c#L651 } } +static rb_io_t * +rb_io_get_fptr(VALUE io) +{ + rb_io_t *fptr = RFILE(io)->fptr; + rb_io_check_initialized(fptr); + return fptr; +} VALUE rb_io_get_io(VALUE io) @@ -668,8 +675,7 @@ VALUE https://github.com/ruby/ruby/blob/trunk/io.c#L675 rb_io_get_write_io(VALUE io) { VALUE write_io; - rb_io_check_initialized(RFILE(io)->fptr); - write_io = RFILE(io)->fptr->tied_io_for_writing; + write_io = rb_io_get_fptr(io)->tied_io_for_writing; if (write_io) { return write_io; } @@ -680,15 +686,15 @@ VALUE https://github.com/ruby/ruby/blob/trunk/io.c#L686 rb_io_set_write_io(VALUE io, VALUE w) { VALUE write_io; - rb_io_check_initialized(RFILE(io)->fptr); + rb_io_t *fptr = rb_io_get_fptr(io); if (!RTEST(w)) { w = 0; } else { GetWriteIO(w); } - write_io = RFILE(io)->fptr->tied_io_for_writing; - RFILE(io)->fptr->tied_io_for_writing = w; + write_io = fptr->tied_io_for_writing; + fptr->tied_io_for_writing = w; return write_io ? write_io : Qnil; } @@ -4422,8 +4428,7 @@ rb_io_close(VALUE io) https://github.com/ruby/ruby/blob/trunk/io.c#L4428 static VALUE rb_io_close_m(VALUE io) { - rb_io_t *fptr = RFILE(io)->fptr; - rb_io_check_initialized(fptr); + rb_io_t *fptr = rb_io_get_fptr(io); if (fptr->fd < 0) { return Qnil; } @@ -4495,8 +4500,7 @@ rb_io_closed(VALUE io) https://github.com/ruby/ruby/blob/trunk/io.c#L4500 } } - fptr = RFILE(io)->fptr; - rb_io_check_initialized(fptr); + fptr = rb_io_get_fptr(io); return 0 <= fptr->fd ? Qfalse : Qtrue; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/