mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* array.c (rb_ary_permutation, rb_ary_combination, rb_ary_product):
hide internal buffer objects. [ruby-dev:31982] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
51baef22a6
commit
81b55c0ff3
2 changed files with 16 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
Tue Oct 9 16:33:32 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_permutation, rb_ary_combination, rb_ary_product):
|
||||
hide internal buffer objects. [ruby-dev:31982]
|
||||
|
||||
Tue Oct 9 16:00:32 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* parse.y (parser_read_escape, parser_tokadd_escape): check code range.
|
||||
|
|
10
array.c
10
array.c
|
@ -231,11 +231,13 @@ to_ary(VALUE ary)
|
|||
return rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
|
||||
}
|
||||
|
||||
#if 0
|
||||
static VALUE
|
||||
to_a(VALUE ary)
|
||||
{
|
||||
return rb_convert_type(ary, T_ARRAY, "Array", "to_a");
|
||||
}
|
||||
#endif
|
||||
|
||||
VALUE
|
||||
rb_check_array_type(VALUE ary)
|
||||
|
@ -3041,6 +3043,9 @@ rb_ary_permutation(VALUE ary, VALUE num)
|
|||
long *p = (long*)RSTRING_PTR(t0); /* array indexes of current permutation */
|
||||
volatile VALUE t1 = rb_str_new(0, n*sizeof(int));
|
||||
int *used = (int*)RSTRING_PTR(t1); /* booleans: which indexes are already used */
|
||||
|
||||
RBASIC(t0)->klass = 0;
|
||||
RBASIC(t1)->klass = 0;
|
||||
ary = rb_ary_dup(ary); /* private defensive copy of ary */
|
||||
|
||||
for(i = 0; i < n; i++) used[i] = 0; /* initialize array */
|
||||
|
@ -3116,6 +3121,8 @@ rb_ary_combination(VALUE ary, VALUE num)
|
|||
VALUE *chosen = RARRAY_PTR(cc);
|
||||
long lev = 0;
|
||||
|
||||
RBASIC(tmp)->klass = 0;
|
||||
RBASIC(cc)->klass = 0;
|
||||
MEMZERO(stack, long, n);
|
||||
stack[0] = -1;
|
||||
for (i = 0; i < nlen; i++) {
|
||||
|
@ -3160,6 +3167,9 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary)
|
|||
long i,j;
|
||||
long resultlen = 1;
|
||||
|
||||
RBASIC(t0)->klass = 0;
|
||||
RBASIC(t1)->klass = 0;
|
||||
|
||||
/* initialize the arrays of arrays */
|
||||
arrays[0] = ary;
|
||||
for(i = 1; i < n; i++) arrays[i] = argv[i-1];
|
||||
|
|
Loading…
Reference in a new issue