* 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:
nobu 2007-10-09 07:33:35 +00:00
Родитель 51baef22a6
Коммит 81b55c0ff3
2 изменённых файлов: 16 добавлений и 1 удалений

Просмотреть файл

@ -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.

12
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)
@ -690,7 +692,7 @@ rb_ary_subseq(VALUE ary, long beg, long len)
if (len == 0) return ary_new(klass, 0);
shared = ary_make_shared(ary);
ptr = RARRAY_PTR(ary);
ptr = RARRAY_PTR(ary);
ary2 = ary_alloc(klass);
RARRAY(ary2)->ptr = ptr + beg;
RARRAY(ary2)->len = len;
@ -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];