ruby-changes:9789
From: matz <ko1@a...>
Date: Mon, 5 Jan 2009 08:21:32 +0900 (JST)
Subject: [ruby-changes:9789] Ruby:r21330 (trunk): * range.c (range_step): should not add up errors on loops.
matz 2009-01-05 08:20:39 +0900 (Mon, 05 Jan 2009) New Revision: 21330 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21330 Log: * range.c (range_step): should not add up errors on loops. [ruby-dev:37691] Modified files: trunk/ChangeLog trunk/range.c Index: ChangeLog =================================================================== --- ChangeLog (revision 21329) +++ ChangeLog (revision 21330) @@ -1,3 +1,8 @@ +Mon Jan 5 08:17:56 2009 Yukihiro Matsumoto <matz@r...> + + * range.c (range_step): should not add up errors on loops. + [ruby-dev:37691] + Mon Jan 5 07:58:37 2009 Yukihiro Matsumoto <matz@r...> * random.c (rb_f_srand): update RDoc. [ruby-core:21113] Index: range.c =================================================================== --- range.c (revision 21329) +++ range.c (revision 21330) @@ -343,10 +343,13 @@ !NIL_P(rb_check_to_integer(b, "to_int")) || !NIL_P(rb_check_to_integer(e, "to_int"))) { ID op = EXCL(range) ? '<' : rb_intern("<="); + VALUE v = b; + int i = 0; - while (RTEST(rb_funcall(b, op, 1, e))) { - rb_yield(b); - b = rb_funcall(b, '+', 1, step); + while (RTEST(rb_funcall(v, op, 1, e))) { + rb_yield(v); + i++; + v = rb_funcall(b, '+', 1, rb_funcall(INT2NUM(i), '*', 1, step)); } } else { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/