From e0009b6a5437c5427a6abf3ddeee3804f73b9870 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 31 Aug 2000 05:29:54 +0000 Subject: matz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- numeric.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'numeric.c') diff --git a/numeric.c b/numeric.c index 3c68917be8..5761986ffe 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); } } -- cgit v1.2.3