ruby-changes:44678
From: mrkn <ko1@a...>
Date: Sat, 12 Nov 2016 21:02:06 +0900 (JST)
Subject: [ruby-changes:44678] mrkn:r56751 (trunk): rational.c: use rb_num_zerodiv instead of rb_raise_zerodiv
mrkn 2016-11-12 20:52:09 +0900 (Sat, 12 Nov 2016) New Revision: 56751 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56751 Log: rational.c: use rb_num_zerodiv instead of rb_raise_zerodiv * rational.c (rb_raize_zerodiv): replace by rb_num_zerodiv. Author: Tadashi Saito <tad.a.digger@g...> Modified files: trunk/rational.c Index: rational.c =================================================================== --- rational.c (revision 56750) +++ rational.c (revision 56751) @@ -400,8 +400,6 @@ nurat_s_alloc(VALUE klass) https://github.com/ruby/ruby/blob/trunk/rational.c#L400 return nurat_s_new_internal(klass, ZERO, ONE); } -#define rb_raise_zerodiv() rb_raise(rb_eZeroDivError, "divided by 0") - #if 0 static VALUE nurat_s_new_bang(int argc, VALUE *argv, VALUE klass) @@ -425,7 +423,7 @@ nurat_s_new_bang(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/rational.c#L423 den = f_negate(den); } else if (INT_ZERO_P(den)) { - rb_raise_zerodiv(); + rb_num_zerodiv(); } break; } @@ -480,7 +478,7 @@ nurat_canonicalize(VALUE *num, VALUE *de https://github.com/ruby/ruby/blob/trunk/rational.c#L478 *den = f_negate(*den); } else if (INT_ZERO_P(*den)) { - rb_raise_zerodiv(); + rb_num_zerodiv(); } } @@ -903,7 +901,7 @@ nurat_div(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/rational.c#L901 { if (RB_INTEGER_TYPE_P(other)) { if (f_zero_p(other)) - rb_raise_zerodiv(); + rb_num_zerodiv(); { get_dat1(self); @@ -916,7 +914,7 @@ nurat_div(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/rational.c#L914 return DBL2NUM(nurat_to_double(self) / RFLOAT_VALUE(other)); else if (RB_TYPE_P(other, T_RATIONAL)) { if (f_zero_p(other)) - rb_raise_zerodiv(); + rb_num_zerodiv(); { get_dat2(self, other); @@ -1009,7 +1007,7 @@ nurat_expt(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/rational.c#L1007 } else if (INT_ZERO_P(dat->num)) { if (f_negative_p(other)) { - rb_raise_zerodiv(); + rb_num_zerodiv(); } else { return f_rational_new_bang1(CLASS_OF(self), ZERO); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/