* 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
@ -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>
|
Mon Jan 5 07:58:37 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* random.c (rb_f_srand): update RDoc. [ruby-core:21113]
|
* 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(b, "to_int")) ||
|
||||||
!NIL_P(rb_check_to_integer(e, "to_int"))) {
|
!NIL_P(rb_check_to_integer(e, "to_int"))) {
|
||||||
ID op = EXCL(range) ? '<' : rb_intern("<=");
|
ID op = EXCL(range) ? '<' : rb_intern("<=");
|
||||||
|
VALUE v = b;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
while (RTEST(rb_funcall(b, op, 1, e))) {
|
while (RTEST(rb_funcall(v, op, 1, e))) {
|
||||||
rb_yield(b);
|
rb_yield(v);
|
||||||
b = rb_funcall(b, '+', 1, step);
|
i++;
|
||||||
|
v = rb_funcall(b, '+', 1, rb_funcall(INT2NUM(i), '*', 1, step));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user