mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* range.c (range_step): should not add up errors on loops.
[ruby-dev:37691] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3c66767bda
commit
f3844ccf44
2 changed files with 11 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Jan 5 08:17:56 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* range.c (range_step): should not add up errors on loops.
|
||||
[ruby-dev:37691]
|
||||
|
||||
Mon Jan 5 07:58:37 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* random.c (rb_f_srand): update RDoc. [ruby-core:21113]
|
||||
|
|
9
range.c
9
range.c
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue