summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-12-04 04:53:31 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-12-04 04:53:31 +0000
commitdc6de95cf2f61f3c2dd11b85d67894dbb208b2ec (patch)
tree4755b13166d7e50d7c4f01d0b44a79f8dce4dc8c /object.c
parent2db0bdd9c0bf9e63708400d4bb8c5e8890e21bb3 (diff)
* io.c (io_fread): EAGAIN/EWOULDBLOCK should not terminate and
throw away the input. * time.c (time_new_internal): underflow adjustment must not use negative div/mod. * time.c (time_cmp): should consider tv_usec on non Fixnum number comparison. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/object.c b/object.c
index 56e0e3d514..3d5ea3af57 100644
--- a/object.c
+++ b/object.c
@@ -845,6 +845,27 @@ rb_convert_type(val, type, tname, method)
return val;
}
+VALUE
+rb_check_convert_type(val, type, tname, method)
+ VALUE val;
+ int type;
+ const char *tname, *method;
+{
+ struct arg_to arg1, arg2;
+
+ if (TYPE(val) == type) return val;
+ arg1.val = arg2.val = val;
+ arg1.s = method;
+ arg2.s = tname;
+ val = rb_rescue2(to_type, (VALUE)&arg1, 0, 0,
+ rb_eStandardError, rb_eNameError, 0);
+ if (!NIL_P(val) && TYPE(val) != type) {
+ rb_raise(rb_eTypeError, "%s#%s should return %s",
+ rb_class2name(CLASS_OF(arg1.val)), method, tname);
+ }
+ return val;
+}
+
static VALUE
rb_to_integer(val, method)
VALUE val;