* io.c (io_{read,write}_nonblock): use rb_get_kwargs instead of

rb_hash_aref.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2014-05-06 09:37:24 +00:00
parent 915ef9ed9b
commit d85c226f73
2 changed files with 20 additions and 2 deletions

View File

@ -1,3 +1,8 @@
Tue May 6 18:33:12 2014 Tadayoshi Funaba <tadf@dotrb.org>
* io.c (io_{read,write}_nonblock): use rb_get_kwargs instead of
rb_hash_aref.
Tue May 6 18:03:05 2014 Tanaka Akira <akr@fsij.org>
* lib/time.rb (Time.make_time): Argument validation code moved from

17
io.c
View File

@ -2615,6 +2615,19 @@ io_readpartial(int argc, VALUE *argv, VALUE io)
return ret;
}
static VALUE
get_kwargs_exception(VALUE opts)
{
static ID ids[1];
VALUE except;
if (!ids[0])
ids[0] = sym_exception;
rb_get_kwargs(opts, ids, 0, 1, &except);
return except;
}
/*
* call-seq:
* ios.read_nonblock(maxlen) -> string
@ -2675,7 +2688,7 @@ io_read_nonblock(int argc, VALUE *argv, VALUE io)
rb_scan_args(argc, argv, "11:", NULL, NULL, &opts);
if (!NIL_P(opts) && Qfalse == rb_hash_aref(opts, sym_exception))
if (!NIL_P(opts) && Qfalse == get_kwargs_exception(opts))
no_exception = 1;
ret = io_getpartial(argc, argv, io, 1, no_exception);
@ -2790,7 +2803,7 @@ rb_io_write_nonblock(int argc, VALUE *argv, VALUE io)
rb_scan_args(argc, argv, "10:", &str, &opts);
if (!NIL_P(opts) && Qfalse == rb_hash_aref(opts, sym_exception))
if (!NIL_P(opts) && Qfalse == get_kwargs_exception(opts))
no_exceptions = 1;
return io_write_nonblock(io, str, no_exceptions);