ruby-changes:31711
From: mrkn <ko1@a...>
Date: Fri, 22 Nov 2013 14:54:10 +0900 (JST)
Subject: [ruby-changes:31711] mrkn:r43790 (trunk): * ext/bigdecimal/bigdecimal.c (BigMath_s_exp): Fix the inserting points
mrkn 2013-11-22 14:54:05 +0900 (Fri, 22 Nov 2013) New Revision: 43790 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43790 Log: * ext/bigdecimal/bigdecimal.c (BigMath_s_exp): Fix the inserting points of RB_GC_GUARDs. Modified files: trunk/ChangeLog trunk/ext/bigdecimal/bigdecimal.c Index: ChangeLog =================================================================== --- ChangeLog (revision 43789) +++ ChangeLog (revision 43790) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Nov 22 14:35:00 2013 Kenta Murata <mrkn@m...> + + * ext/bigdecimal/bigdecimal.c (BigMath_s_exp): Fix the inserting points + of RB_GC_GUARDs. + Fri Nov 22 14:31:00 2013 Kenta Murata <mrkn@m...> * ext/bigdecimal/bigdecimal.c: Fix indentation. Index: ext/bigdecimal/bigdecimal.c =================================================================== --- ext/bigdecimal/bigdecimal.c (revision 43789) +++ ext/bigdecimal/bigdecimal.c (revision 43790) @@ -2711,22 +2711,22 @@ BigMath_s_exp(VALUE klass, VALUE x, VALU https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2711 else { Real* vy; vy = VpCreateRbObject(prec, "#0"); - RB_GC_GUARD(vy->obj); VpSetInf(vy, VP_SIGN_POSITIVE_INFINITE); + RB_GC_GUARD(vy->obj); return ToValue(vy); } } else if (nan) { Real* vy; vy = VpCreateRbObject(prec, "#0"); - RB_GC_GUARD(vy->obj); VpSetNaN(vy); + RB_GC_GUARD(vy->obj); return ToValue(vy); } else if (vx == NULL) { cannot_be_coerced_into_BigDecimal(rb_eArgError, x); } - x = RB_GC_GUARD(vx->obj); + x = vx->obj; n = prec + rmpd_double_figures(); negative = VpGetSign(vx) < 0; @@ -2734,12 +2734,12 @@ BigMath_s_exp(VALUE klass, VALUE x, VALU https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2734 VpSetSign(vx, 1); } - RB_GC_GUARD(one) = ToValue(VpCreateRbObject(1, "1")); - RB_GC_GUARD(x1) = one; - RB_GC_GUARD(y) = one; - RB_GC_GUARD(d) = y; - RB_GC_GUARD(z) = one; - i = 0; + one = ToValue(VpCreateRbObject(1, "1")); + x1 = one; + y = one; + d = y; + z = one; + i = 0; while (!VpIsZero((Real*)DATA_PTR(d))) { VALUE argv[2]; @@ -2772,6 +2772,13 @@ BigMath_s_exp(VALUE klass, VALUE x, VALU https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2772 vprec = SSIZET2NUM(prec - VpExponent10(DATA_PTR(y))); return BigDecimal_round(1, &vprec, y); } + + RB_GC_GUARD(one); + RB_GC_GUARD(x); + RB_GC_GUARD(x1); + RB_GC_GUARD(y); + RB_GC_GUARD(d); + RB_GC_GUARD(z); } /* call-seq: -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/