summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-06 09:37:24 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-06 09:37:24 +0000
commitd85c226f73f5d59e03190ef8f29d316ea33f34e0 (patch)
tree707c8fa585ee3f6a109452a504da19d91fae910a /io.c
parent915ef9ed9b6222e2b890641051a21e77de64fb16 (diff)
* 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
Diffstat (limited to 'io.c')
-rw-r--r--io.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/io.c b/io.c
index 3062a5fc3a..533989cb62 100644
--- a/io.c
+++ b/io.c
@@ -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);