diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-08-31 05:29:54 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-08-31 05:29:54 +0000 |
commit | e0009b6a5437c5427a6abf3ddeee3804f73b9870 (patch) | |
tree | 0ed5e86f76f9adff8eb848d6be67500adb86edd2 /numeric.c | |
parent | 5b3ed19660ef4d9ea87265416a199e7dc7e940c1 (diff) |
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 24 |
1 files changed, 3 insertions, 21 deletions
@@ -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); } } |