mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* range.c (range_each_func): should not leave a variable
uninitialized, which could cause SEGV. * range.c (range_step): removed duplicated and unreachable code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5572494524
commit
4653fedd0c
2 changed files with 9 additions and 13 deletions
|
@ -1,3 +1,10 @@
|
|||
Mon Apr 7 12:15:24 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* range.c (range_each_func): should not leave a variable
|
||||
uninitialized, which could cause SEGV.
|
||||
|
||||
* range.c (range_step): removed duplicated and unreachable code.
|
||||
|
||||
Mon Apr 7 02:12:27 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_intern): need not to check if tainted.
|
||||
|
|
15
range.c
15
range.c
|
@ -228,7 +228,7 @@ range_each_func(VALUE range, VALUE (*func) (VALUE, void *), void *arg)
|
|||
int c;
|
||||
VALUE b = RANGE_BEG(range);
|
||||
VALUE e = RANGE_END(range);
|
||||
VALUE v;
|
||||
VALUE v = b;
|
||||
|
||||
if (EXCL(range)) {
|
||||
while (r_lt(v, e)) {
|
||||
|
@ -295,9 +295,8 @@ step_i(VALUE i, void *arg)
|
|||
static VALUE
|
||||
range_step(int argc, VALUE *argv, VALUE range)
|
||||
{
|
||||
VALUE b, e, step, tmp, c;
|
||||
VALUE b, e, step, tmp;
|
||||
long unit;
|
||||
int nv;
|
||||
|
||||
RETURN_ENUMERATOR(range, argc, argv);
|
||||
|
||||
|
@ -361,16 +360,6 @@ range_step(int argc, VALUE *argv, VALUE range)
|
|||
iter[1] = step;
|
||||
rb_block_call(b, rb_intern("upto"), 2, args, step_i, (VALUE)iter);
|
||||
}
|
||||
else if (rb_obj_is_kind_of(b, rb_cNumeric)) {
|
||||
ID c = rb_intern(EXCL(range) ? "<" : "<=");
|
||||
|
||||
if (rb_equal(step, INT2FIX(0)))
|
||||
rb_raise(rb_eArgError, "step can't be 0");
|
||||
while (RTEST(rb_funcall(b, c, 1, e))) {
|
||||
rb_yield(b);
|
||||
b = rb_funcall(b, '+', 1, step);
|
||||
}
|
||||
}
|
||||
else {
|
||||
VALUE args[2];
|
||||
|
||||
|
|
Loading…
Reference in a new issue