mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* array.c (rb_ary_{permutation,combination,product}): must not use
ary_discard on strings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bd85292d3f
commit
330be69e43
2 changed files with 10 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Aug 3 13:05:22 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_{permutation,combination,product}): must not use
|
||||
ary_discard on strings.
|
||||
|
||||
Mon Aug 3 00:32:00 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* random.c (rb_random_int): arguments have to be converted to
|
||||
|
|
10
array.c
10
array.c
|
@ -3748,8 +3748,8 @@ rb_ary_permutation(int argc, VALUE *argv, VALUE ary)
|
|||
for (i = 0; i < n; i++) used[i] = 0; /* initialize array */
|
||||
|
||||
permute0(n, r, p, 0, used, ary0); /* compute and yield permutations */
|
||||
ary_discard(t0);
|
||||
ary_discard(t1);
|
||||
rb_str_resize(t0, 0L);
|
||||
rb_str_resize(t1, 0L);
|
||||
RBASIC(ary0)->klass = rb_cArray;
|
||||
}
|
||||
return ary;
|
||||
|
@ -3839,7 +3839,7 @@ rb_ary_combination(VALUE ary, VALUE num)
|
|||
stack[lev--]++;
|
||||
} while (lev && (stack[lev+1]+n == len+lev+1));
|
||||
}
|
||||
ary_discard(t0);
|
||||
rb_str_resize(t0, 0L);
|
||||
ary_discard(cc);
|
||||
}
|
||||
return ary;
|
||||
|
@ -3918,8 +3918,8 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary)
|
|||
counters[m]++;
|
||||
}
|
||||
}
|
||||
ary_discard(t0);
|
||||
ary_discard(t1);
|
||||
rb_str_resize(t0, 0L);
|
||||
rb_str_resize(t1, 0L);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue