Skip to content

Commit

Permalink
* range.c (range_step): should not add up errors on loops.
Browse files Browse the repository at this point in the history
  [ruby-dev:37691]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Jan 4, 2009
1 parent 3c66767 commit f3844cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Mon Jan 5 08:17:56 2009 Yukihiro Matsumoto <[email protected]>

* range.c (range_step): should not add up errors on loops.
[ruby-dev:37691]

Mon Jan 5 07:58:37 2009 Yukihiro Matsumoto <[email protected]>

* random.c (rb_f_srand): update RDoc. [ruby-core:21113]
Expand Down
9 changes: 6 additions & 3 deletions range.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,13 @@ range_step(int argc, VALUE *argv, VALUE range)
!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 {
Expand Down

0 comments on commit f3844cc

Please sign in to comment.