summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-01-27 08:08:39 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-01-27 08:08:39 +0000
commit1f25ed85a9a066ecff452df1512a42de04666053 (patch)
treef9c619a2977e62b8f4ef34281fa845aee33dbc5c /numeric.c
parentceb8031b6b795b189012c38057ebf82733f4aeaf (diff)
990127
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/numeric.c b/numeric.c
index 6bc2e4478e5..2562a7778ef 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1330,20 +1330,23 @@ fix_step(from, to, step)
if (!FIXNUM_P(to) || !FIXNUM_P(step))
return int_step(from, to, step);
+ i = FIX2LONG(from);
end = FIX2LONG(to);
diff = FIX2LONG(step);
if (diff == 0) {
rb_raise(rb_eArgError, "step cannot be 0");
}
- else if (diff > 0) {
- for (i=FIX2LONG(from); i <= end; i+=diff) {
+ if (diff > 0) {
+ while (i <= end) {
rb_yield(INT2FIX(i));
+ i += diff;
}
}
else {
- for (i=FIX2LONG(from); i >= end; i+=diff) {
+ while (i >= end) {
rb_yield(INT2FIX(i));
+ i += diff;
}
}
return from;