summaryrefslogtreecommitdiffstats
path: root/numeric.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-08-31 05:29:54 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-08-31 05:29:54 +0000
commit9a51fecc55dca8f4feb0b558c048532d5f5b1f3e (patch)
tree0ed5e86f76f9adff8eb848d6be67500adb86edd2 /numeric.c
parent4e2edd1992f7dc775e430547cc4cec28f2bd1035 (diff)
downloadruby-9a51fecc55dca8f4feb0b558c048532d5f5b1f3e.tar.gz
ruby-9a51fecc55dca8f4feb0b558c048532d5f5b1f3e.tar.xz
ruby-9a51fecc55dca8f4feb0b558c048532d5f5b1f3e.zip
matz
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c24
1 files changed, 3 insertions, 21 deletions
diff --git a/numeric.c b/numeric.c
index 3c68917be..5761986ff 100644
--- a/numeric.c
+++ b/numeric.c
@@ -70,7 +70,8 @@ do_coerce(x, y)
VALUE a[2];
a[0] = *x; a[1] = *y;
- ary = rb_rescue2(coerce_body, (VALUE)a, rb_eNameError, coerce_rescue, (VALUE)a);
+ ary = rb_rescue2(coerce_body, (VALUE)a, coerce_rescue, (VALUE)a,
+ rb_eStandardError, rb_eNameError, 0);
if (TYPE(ary) != T_ARRAY || RARRAY(ary)->len != 2) {
rb_raise(rb_eTypeError, "coerce must return [x, y]");
}
@@ -746,22 +747,6 @@ num_truncate(num)
return flo_truncate(rb_Float(num));
}
-static VALUE
-to_integer(val)
- VALUE val;
-{
- return rb_funcall(val, to_i, 0);
-}
-
-static VALUE
-fail_to_integer(val)
- VALUE val;
-{
- rb_raise(rb_eTypeError, "failed to convert %s into Integer",
- rb_class2name(CLASS_OF(val)));
- return Qnil; /* dummy */
-}
-
long
rb_num2long(val)
VALUE val;
@@ -800,10 +785,7 @@ rb_num2long(val)
return Qnil; /* not reached */
default:
- val = rb_rescue(to_integer, val, fail_to_integer, val);
- if (!rb_obj_is_kind_of(val, rb_cInteger)) {
- rb_raise(rb_eTypeError, "`to_i' need to return integer");
- }
+ val = rb_Integer(val);
return NUM2LONG(val);
}
}