ruby-changes:30750
From: nobu <ko1@a...>
Date: Wed, 4 Sep 2013 22:57:09 +0900 (JST)
Subject: [ruby-changes:30750] nobu:r42829 (trunk): numeric.c: split NUM_STEP_GET_INF
nobu 2013-09-04 22:57:02 +0900 (Wed, 04 Sep 2013) New Revision: 42829 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42829 Log: numeric.c: split NUM_STEP_GET_INF * numeric.c (NUM_STEP_GET_INF): split from NUM_STEP_SCAN_ARGS(), since inf is not used in num_step_size(). Modified files: trunk/ChangeLog trunk/numeric.c Index: ChangeLog =================================================================== --- ChangeLog (revision 42828) +++ ChangeLog (revision 42829) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Sep 4 22:56:49 2013 Nobuyoshi Nakada <nobu@r...> + + * numeric.c (NUM_STEP_GET_INF): split from NUM_STEP_SCAN_ARGS(), since + inf is not used in num_step_size(). + Wed Sep 4 20:22:43 2013 Tanaka Akira <akr@f...> * bignum.c (bigdivrem_normal): Add assertions. Index: numeric.c =================================================================== --- numeric.c (revision 42828) +++ numeric.c (revision 42829) @@ -1846,7 +1846,7 @@ ruby_num_interval_step_size(VALUE from, https://github.com/ruby/ruby/blob/trunk/numeric.c#L1846 } } -#define NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc, inf) do { \ +#define NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc) do { \ argc = rb_scan_args(argc, argv, "02:", &to, &step, &hash); \ if (!NIL_P(hash)) { \ step = rb_hash_aref(hash, sym_by); \ @@ -1878,7 +1878,10 @@ ruby_num_interval_step_size(VALUE from, https://github.com/ruby/ruby/blob/trunk/numeric.c#L1878 rb_raise(rb_eTypeError, "limit must be numeric"); \ } \ } \ - if (TYPE(to) == T_FLOAT) { \ +} while (0) + +#define NUM_STEP_GET_INF(to, desc, inf) do { \ + if (RB_TYPE_P(to, T_FLOAT)) { \ double f = RFLOAT_VALUE(to); \ inf = isinf(f) && (signbit(f) ? desc : !desc); \ } \ @@ -1889,11 +1892,11 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/numeric.c#L1892 num_step_size(VALUE from, VALUE args, VALUE eobj) { VALUE to, step, hash; - int desc, inf; + int desc; int argc = args ? RARRAY_LENINT(args) : 0; VALUE *argv = args ? RARRAY_PTR(args) : 0; - NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc, inf); + NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc); return ruby_num_interval_step_size(from, to, step, FALSE); } @@ -1959,7 +1962,9 @@ num_step(int argc, VALUE *argv, VALUE fr https://github.com/ruby/ruby/blob/trunk/numeric.c#L1962 RETURN_SIZED_ENUMERATOR(from, argc, argv, num_step_size); - NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc, inf); + NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc); + NUM_STEP_GET_INF(to, desc, inf); + if (FIXNUM_P(from) && (inf || FIXNUM_P(to)) && FIXNUM_P(step)) { long i = FIX2LONG(from); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/