From aacd7710462142df7397618ffff4279e495f10f9 Mon Sep 17 00:00:00 2001 From: ko1 Date: Mon, 13 May 2013 09:56:22 +0000 Subject: [PATCH] * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro instead of using RARRAY_PTR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++ array.c | 112 +++++++++++++++++++++++++-------------------------- compile.c | 10 ++--- complex.c | 4 +- enum.c | 26 ++++++------ enumerator.c | 16 ++++---- error.c | 2 +- eval_error.c | 2 +- file.c | 10 ++--- gc.c | 8 ++-- hash.c | 34 ++++++++-------- insns.def | 2 +- io.c | 14 +++---- iseq.c | 2 +- load.c | 10 ++--- marshal.c | 10 ++--- numeric.c | 12 +++--- pack.c | 8 ++-- parse.y | 2 +- proc.c | 6 +-- process.c | 76 +++++++++++++++++----------------- range.c | 2 +- rational.c | 6 +-- re.c | 2 +- ruby.c | 4 +- string.c | 2 +- struct.c | 2 +- thread.c | 18 ++++----- transcode.c | 6 +-- vm.c | 4 +- vm_dump.c | 2 +- vm_eval.c | 6 +-- vm_method.c | 4 +- 33 files changed, 217 insertions(+), 212 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9bf818061d..b8bf4f08d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon May 13 18:44:14 2013 Koichi Sasada + + * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro + instead of using RARRAY_PTR(). + Mon May 13 16:53:53 2013 Koichi Sasada * include/ruby/ruby.h: add new utility macros to access diff --git a/array.c b/array.c index 37334a8367..47ff7ac611 100644 --- a/array.c +++ b/array.c @@ -440,7 +440,7 @@ rb_ary_new3(long n, ...) va_start(ar, n); for (i=0; i= RARRAY_LEN(ary)) { ARY_SET_LEN(ary, idx + 1); } - RARRAY_PTR(ary)[idx] = val; + RARRAY_ASET(ary, idx, val); } static VALUE @@ -825,7 +825,7 @@ rb_ary_push(VALUE ary, VALUE item) long idx = RARRAY_LEN(ary); ary_ensure_room_for_push(ary, 1); - RARRAY_PTR(ary)[idx] = item; + RARRAY_ASET(ary, idx, item); ARY_SET_LEN(ary, idx + 1); return ary; } @@ -838,7 +838,7 @@ rb_ary_push_1(VALUE ary, VALUE item) if (idx >= ARY_CAPA(ary)) { ary_double_capa(ary, idx); } - RARRAY_PTR(ary)[idx] = item; + RARRAY_ASET(ary, idx, item); ARY_SET_LEN(ary, idx + 1); return ary; } @@ -890,7 +890,7 @@ rb_ary_pop(VALUE ary) } n = RARRAY_LEN(ary)-1; ARY_SET_LEN(ary, n); - return RARRAY_PTR(ary)[n]; + return RARRAY_AREF(ary, n); } /* @@ -933,7 +933,7 @@ rb_ary_shift(VALUE ary) rb_ary_modify_check(ary); if (RARRAY_LEN(ary) == 0) return Qnil; - top = RARRAY_PTR(ary)[0]; + top = RARRAY_AREF(ary, 0); if (!ARY_SHARED_P(ary)) { if (RARRAY_LEN(ary) < ARY_DEFAULT_SIZE) { MEMMOVE(RARRAY_PTR(ary), RARRAY_PTR(ary)+1, VALUE, RARRAY_LEN(ary)-1); @@ -942,11 +942,11 @@ rb_ary_shift(VALUE ary) } assert(!ARY_EMBED_P(ary)); /* ARY_EMBED_LEN_MAX < ARY_DEFAULT_SIZE */ - RARRAY_PTR(ary)[0] = Qnil; + RARRAY_ASET(ary, 0, Qnil); ary_make_shared(ary); } else if (ARY_SHARED_NUM(ARY_SHARED(ary)) == 1) { - RARRAY_PTR(ary)[0] = Qnil; + RARRAY_ASET(ary, 0, Qnil); } ARY_INCREASE_PTR(ary, 1); /* shift ptr */ ARY_INCREASE_LEN(ary, -1); @@ -1095,7 +1095,7 @@ rb_ary_elt(VALUE ary, long offset) if (offset < 0 || RARRAY_LEN(ary) <= offset) { return Qnil; } - return RARRAY_PTR(ary)[offset]; + return RARRAY_AREF(ary, offset); } VALUE @@ -1233,7 +1233,7 @@ rb_ary_first(int argc, VALUE *argv, VALUE ary) { if (argc == 0) { if (RARRAY_LEN(ary) == 0) return Qnil; - return RARRAY_PTR(ary)[0]; + return RARRAY_AREF(ary, 0); } else { return ary_take_first_or_last(argc, argv, ary, ARY_TAKE_FIRST); @@ -1260,7 +1260,7 @@ rb_ary_last(int argc, VALUE *argv, VALUE ary) { if (argc == 0) { if (RARRAY_LEN(ary) == 0) return Qnil; - return RARRAY_PTR(ary)[RARRAY_LEN(ary)-1]; + return RARRAY_AREF(ary, RARRAY_LEN(ary)-1); } else { return ary_take_first_or_last(argc, argv, ary, ARY_TAKE_LAST); @@ -1315,7 +1315,7 @@ rb_ary_fetch(int argc, VALUE *argv, VALUE ary) } return ifnone; } - return RARRAY_PTR(ary)[idx]; + return RARRAY_AREF(ary, idx); } /* @@ -1353,7 +1353,7 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary) if (argc == 0) { RETURN_ENUMERATOR(ary, 0, 0); for (i=0; i RARRAY_LEN(ary)) { i = RARRAY_LEN(ary); @@ -1414,7 +1414,7 @@ rb_ary_rindex(int argc, VALUE *argv, VALUE ary) if (rb_block_given_p()) rb_warn("given block not used"); while (i--) { - if (rb_equal(RARRAY_PTR(ary)[i], val)) + if (rb_equal(RARRAY_AREF(ary, i), val)) return LONG2NUM(i); if (i > RARRAY_LEN(ary)) { i = RARRAY_LEN(ary); @@ -1676,7 +1676,7 @@ rb_ary_each(VALUE array) RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); for (i=0; i 0) rb_enc_copy(result, RARRAY_PTR(ary)[0]); + if (max > 0) rb_enc_copy(result, RARRAY_AREF(ary, 0)); for (i=0; i 0 && !NIL_P(sep)) rb_str_buf_append(result, sep); rb_str_buf_append(result, val); @@ -1839,7 +1839,7 @@ ary_join_1(VALUE obj, VALUE ary, VALUE sep, long i, VALUE result, int *first) if (i > 0 && !NIL_P(sep)) rb_str_buf_append(result, sep); - val = RARRAY_PTR(ary)[i]; + val = RARRAY_AREF(ary, i); if (RB_TYPE_P(val, T_STRING)) { str_join: rb_str_buf_append(result, val); @@ -1900,7 +1900,7 @@ rb_ary_join(VALUE ary, VALUE sep) len += RSTRING_LEN(sep) * (RARRAY_LEN(ary) - 1); } for (i=0; i 0) rb_str_buf_cat2(str, ", "); @@ -2539,7 +2539,7 @@ rb_ary_collect(VALUE ary) RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); collect = rb_ary_new2(RARRAY_LEN(ary)); for (i = 0; i < RARRAY_LEN(ary); i++) { - rb_ary_push(collect, rb_yield(RARRAY_PTR(ary)[i])); + rb_ary_push(collect, rb_yield(RARRAY_AREF(ary, i))); } return collect; } @@ -2572,7 +2572,7 @@ rb_ary_collect_bang(VALUE ary) RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); rb_ary_modify(ary); for (i = 0; i < RARRAY_LEN(ary); i++) { - rb_ary_store(ary, i, rb_yield(RARRAY_PTR(ary)[i])); + rb_ary_store(ary, i, rb_yield(RARRAY_AREF(ary, i))); } return ary; } @@ -2655,7 +2655,7 @@ rb_ary_select(VALUE ary) RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); result = rb_ary_new2(RARRAY_LEN(ary)); for (i = 0; i < RARRAY_LEN(ary); i++) { - if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) { + if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) { rb_ary_push(result, rb_ary_elt(ary, i)); } } @@ -2686,7 +2686,7 @@ rb_ary_select_bang(VALUE ary) RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length); rb_ary_modify(ary); for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) { - VALUE v = RARRAY_PTR(ary)[i1]; + VALUE v = RARRAY_AREF(ary, i1); if (!RTEST(rb_yield(v))) continue; if (i1 != i2) { rb_ary_store(ary, i2, v); @@ -2764,7 +2764,7 @@ rb_ary_delete(VALUE ary, VALUE item) long i1, i2; for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) { - VALUE e = RARRAY_PTR(ary)[i1]; + VALUE e = RARRAY_AREF(ary, i1); if (rb_equal(e, item)) { v = e; @@ -2793,7 +2793,7 @@ rb_ary_delete_same(VALUE ary, VALUE item) long i1, i2; for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) { - VALUE e = RARRAY_PTR(ary)[i1]; + VALUE e = RARRAY_AREF(ary, i1); if (e == item) { continue; @@ -2823,7 +2823,7 @@ rb_ary_delete_at(VALUE ary, long pos) } rb_ary_modify(ary); - del = RARRAY_PTR(ary)[pos]; + del = RARRAY_AREF(ary, pos); MEMMOVE(RARRAY_PTR(ary)+pos, RARRAY_PTR(ary)+pos+1, VALUE, RARRAY_LEN(ary)-pos-1); ARY_INCREASE_LEN(ary, -1); @@ -2930,7 +2930,7 @@ ary_reject(VALUE orig, VALUE result) long i; for (i = 0; i < RARRAY_LEN(orig); i++) { - VALUE v = RARRAY_PTR(orig)[i]; + VALUE v = RARRAY_AREF(orig, i); if (!RTEST(rb_yield(v))) { rb_ary_push_1(result, v); } @@ -2946,7 +2946,7 @@ ary_reject_bang(VALUE ary) rb_ary_modify_check(ary); for (i = 0; i < RARRAY_LEN(ary); ) { - VALUE v = RARRAY_PTR(ary)[i]; + VALUE v = RARRAY_AREF(ary, i); if (RTEST(rb_yield(v))) { rb_ary_delete_at(ary, i); result = ary; @@ -3323,7 +3323,7 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary) for (i=beg; i=RARRAY_LEN(ary)) break; - RARRAY_PTR(ary)[i] = v; + RARRAY_ASET(ary, i, v); } } else { @@ -3482,9 +3482,9 @@ rb_ary_assoc(VALUE ary, VALUE key) VALUE v; for (i = 0; i < RARRAY_LEN(ary); ++i) { - v = rb_check_array_type(RARRAY_PTR(ary)[i]); + v = rb_check_array_type(RARRAY_AREF(ary, i)); if (!NIL_P(v) && RARRAY_LEN(v) > 0 && - rb_equal(RARRAY_PTR(v)[0], key)) + rb_equal(RARRAY_AREF(v, 0), key)) return v; } return Qnil; @@ -3515,10 +3515,10 @@ rb_ary_rassoc(VALUE ary, VALUE value) VALUE v; for (i = 0; i < RARRAY_LEN(ary); ++i) { - v = RARRAY_PTR(ary)[i]; + v = RARRAY_AREF(ary, i); if (RB_TYPE_P(v, T_ARRAY) && RARRAY_LEN(v) > 1 && - rb_equal(RARRAY_PTR(v)[1], value)) + rb_equal(RARRAY_AREF(v, 1), value)) return v; } return Qnil; @@ -3628,7 +3628,7 @@ recursive_hash(VALUE ary, VALUE dummy, int recur) } else { for (i=0; iklass) { rb_raise(rb_eRuntimeError, "flatten reentered"); @@ -4483,7 +4483,7 @@ rb_ary_cycle_size(VALUE self, VALUE args) long mul; VALUE n = Qnil; if (args && (RARRAY_LEN(args) > 0)) { - n = RARRAY_PTR(args)[0]; + n = RARRAY_AREF(args, 0); } if (RARRAY_LEN(self) == 0) return INT2FIX(0); if (n == Qnil) return DBL2NUM(INFINITY); @@ -4531,7 +4531,7 @@ rb_ary_cycle(int argc, VALUE *argv, VALUE ary) while (RARRAY_LEN(ary) > 0 && (n < 0 || 0 < n--)) { for (i=0; i 0)) ? NUM2LONG(RARRAY_PTR(args)[0]) : n; + long k = (args && (RARRAY_LEN(args) > 0)) ? NUM2LONG(RARRAY_AREF(args, 0)) : n; return descending_factorial(n, k); } @@ -4670,7 +4670,7 @@ rb_ary_permutation(int argc, VALUE *argv, VALUE ary) } else if (r == 1) { /* this is a special, easy case */ for (i = 0; i < RARRAY_LEN(ary); i++) { - rb_yield(rb_ary_new3(1, RARRAY_PTR(ary)[i])); + rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else { /* this is the general case */ @@ -4695,7 +4695,7 @@ static VALUE rb_ary_combination_size(VALUE ary, VALUE args) { long n = RARRAY_LEN(ary); - long k = NUM2LONG(RARRAY_PTR(args)[0]); + long k = NUM2LONG(RARRAY_AREF(args, 0)); return binomial_coefficient(k, n); } @@ -4741,7 +4741,7 @@ rb_ary_combination(VALUE ary, VALUE num) } else if (n == 1) { for (i = 0; i < len; i++) { - rb_yield(rb_ary_new3(1, RARRAY_PTR(ary)[i])); + rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else { @@ -4754,9 +4754,9 @@ rb_ary_combination(VALUE ary, VALUE num) MEMZERO(stack, long, n); stack[0] = -1; for (;;) { - chosen[lev] = RARRAY_PTR(ary)[stack[lev+1]]; + chosen[lev] = RARRAY_AREF(ary, stack[lev+1]); for (lev++; lev < n; lev++) { - chosen[lev] = RARRAY_PTR(ary)[stack[lev+1] = stack[lev]+1]; + chosen[lev] = RARRAY_AREF(ary, stack[lev+1] = stack[lev]+1); } rb_yield(rb_ary_new4(n, chosen)); if (RBASIC(t0)->klass) { @@ -4818,7 +4818,7 @@ static VALUE rb_ary_repeated_permutation_size(VALUE ary, VALUE args) { long n = RARRAY_LEN(ary); - long k = NUM2LONG(RARRAY_PTR(args)[0]); + long k = NUM2LONG(RARRAY_AREF(args, 0)); if (k < 0) { return LONG2FIX(0); @@ -4867,7 +4867,7 @@ rb_ary_repeated_permutation(VALUE ary, VALUE num) } else if (r == 1) { /* this is a special, easy case */ for (i = 0; i < RARRAY_LEN(ary); i++) { - rb_yield(rb_ary_new3(1, RARRAY_PTR(ary)[i])); + rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else { /* this is the general case */ @@ -4911,7 +4911,7 @@ static VALUE rb_ary_repeated_combination_size(VALUE ary, VALUE args) { long n = RARRAY_LEN(ary); - long k = NUM2LONG(RARRAY_PTR(args)[0]); + long k = NUM2LONG(RARRAY_AREF(args, 0)); if (k == 0) { return LONG2FIX(1); } @@ -4961,7 +4961,7 @@ rb_ary_repeated_combination(VALUE ary, VALUE num) } else if (n == 1) { for (i = 0; i < len; i++) { - rb_yield(rb_ary_new3(1, RARRAY_PTR(ary)[i])); + rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else if (len == 0) { @@ -5139,7 +5139,7 @@ rb_ary_take_while(VALUE ary) RETURN_ENUMERATOR(ary, 0, 0); for (i = 0; i < RARRAY_LEN(ary); i++) { - if (!RTEST(rb_yield(RARRAY_PTR(ary)[i]))) break; + if (!RTEST(rb_yield(RARRAY_AREF(ary, i)))) break; } return rb_ary_take(ary, LONG2FIX(i)); } @@ -5199,7 +5199,7 @@ rb_ary_drop_while(VALUE ary) RETURN_ENUMERATOR(ary, 0, 0); for (i = 0; i < RARRAY_LEN(ary); i++) { - if (!RTEST(rb_yield(RARRAY_PTR(ary)[i]))) break; + if (!RTEST(rb_yield(RARRAY_AREF(ary, i)))) break; } return rb_ary_drop(ary, LONG2FIX(i)); } diff --git a/compile.c b/compile.c index c9b59b275b..1a911f1f4d 100644 --- a/compile.c +++ b/compile.c @@ -223,7 +223,7 @@ r_value(VALUE value) do { \ if ((event) == RUBY_EVENT_LINE && iseq->coverage && \ (line) != iseq->compile_data->last_coverable_line) { \ - RARRAY_PTR(iseq->coverage)[(line) - 1] = INT2FIX(0); \ + RARRAY_ASET(iseq->coverage, (line) - 1, INT2FIX(0)); \ iseq->compile_data->last_coverable_line = (line); \ ADD_INSN1((seq), (line), trace, INT2FIX(RUBY_EVENT_COVERAGE)); \ } \ @@ -1209,7 +1209,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args) keywords = required; } for (j = 0; j < i; j++) { - iseq->arg_keyword_table[j] = FIX2INT(RARRAY_PTR(keywords)[j]); + iseq->arg_keyword_table[j] = FIX2INT(RARRAY_AREF(keywords, j)); } ADD_INSN(optargs, nd_line(args->kw_args), pop); } @@ -5571,7 +5571,7 @@ iseq_build_from_ary_exception(rb_iseq_t *iseq, struct st_table *labels_table, LABEL *lstart, *lend, *lcont; int sp; - RB_GC_GUARD(v) = rb_convert_type(RARRAY_PTR(exception)[i], T_ARRAY, + RB_GC_GUARD(v) = rb_convert_type(RARRAY_AREF(exception, i), T_ARRAY, "Array", "to_ary"); if (RARRAY_LEN(v) != 6) { rb_raise(rb_eSyntaxError, "wrong exception entry"); @@ -5663,7 +5663,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor, st_data_t insn_id; VALUE insn; - insn = (argc < 0) ? Qnil : RARRAY_PTR(obj)[0]; + insn = (argc < 0) ? Qnil : RARRAY_AREF(obj, 0); if (st_lookup(insn_table, (st_data_t)insn, &insn_id) == 0) { /* TODO: exception */ RB_GC_GUARD(insn) = rb_inspect(insn); @@ -5794,7 +5794,7 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args, iseq->local_size = iseq->local_table_size + 1; for (i=0; ibuf)[data->n*2] = v; - RARRAY_PTR(data->buf)[data->n*2+1] = i; + RARRAY_ASET(data->buf, data->n*2, v); + RARRAY_ASET(data->buf, data->n*2+1, i); data->n++; if (data->n == SORT_BY_BUFSIZE) { rb_ary_concat(ary, data->buf); @@ -955,7 +955,7 @@ enum_sort_by(VALUE obj) rb_raise(rb_eRuntimeError, "sort_by reentered"); } for (i=1; iklass = rb_cArray; @@ -1725,7 +1725,7 @@ enum_reverse_each(int argc, VALUE *argv, VALUE obj) ary = enum_to_a(argc, argv, obj); for (i = RARRAY_LEN(ary); --i >= 0; ) { - rb_yield(RARRAY_PTR(ary)[i]); + rb_yield(RARRAY_AREF(ary, i)); } return obj; @@ -1800,7 +1800,7 @@ static VALUE enum_each_slice_size(VALUE obj, VALUE args) { VALUE n, size; - long slice_size = NUM2LONG(RARRAY_PTR(args)[0]); + long slice_size = NUM2LONG(RARRAY_AREF(args, 0)); if (slice_size <= 0) rb_raise(rb_eArgError, "invalid slice size"); size = enum_size(obj, 0); @@ -1867,7 +1867,7 @@ static VALUE enum_each_cons_size(VALUE obj, VALUE args) { VALUE n, size; - long cons_size = NUM2LONG(RARRAY_PTR(args)[0]); + long cons_size = NUM2LONG(RARRAY_AREF(args, 0)); if (cons_size <= 0) rb_raise(rb_eArgError, "invalid size"); size = enum_size(obj, 0); @@ -1955,13 +1955,13 @@ zip_ary(VALUE val, NODE *memo, int argc, VALUE *argv) tmp = rb_ary_new2(RARRAY_LEN(args) + 1); rb_ary_store(tmp, 0, rb_enum_values_pack(argc, argv)); for (i=0; i 0)) { - n = RARRAY_PTR(args)[0]; + n = RARRAY_AREF(args, 0); } if (n == Qnil) return DBL2NUM(INFINITY); mul = NUM2LONG(n); @@ -2315,7 +2315,7 @@ enum_cycle(int argc, VALUE *argv, VALUE obj) if (len == 0) return Qnil; while (n < 0 || 0 < --n) { for (i=0; iklass = 0; OBJ_INFECT(result, ary); for (i=0; i 0) { rb_file_expand_path_internal(path, str, 0, 0, tmp); diff --git a/gc.c b/gc.c index fbdc964514..8283e581c0 100644 --- a/gc.c +++ b/gc.c @@ -1387,9 +1387,9 @@ run_finalizer(rb_objspace_t *objspace, VALUE obj, VALUE table) args[2] = (VALUE)rb_safe_level(); for (i=0; iobj2wmap, &orig, &data)) { rids = (VALUE)data; for (i = 0; i < RARRAY_LEN(rids); ++i) { - wmap = (st_data_t)RARRAY_PTR(rids)[i]; + wmap = (st_data_t)RARRAY_AREF(rids, i); st_delete(w->wmap2obj, &wmap, NULL); } } diff --git a/hash.c b/hash.c index 2cb570505c..e990f53d3e 100644 --- a/hash.c +++ b/hash.c @@ -411,7 +411,7 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass) hash = hash_alloc(klass); for (i = 0; i < RARRAY_LEN(tmp); ++i) { - VALUE e = RARRAY_PTR(tmp)[i]; + VALUE e = RARRAY_AREF(tmp, i); VALUE v = rb_check_array_type(e); VALUE key, val = Qnil; @@ -433,9 +433,9 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass) rb_raise(rb_eArgError, "invalid number of elements (%ld for 1..2)", RARRAY_LEN(v)); case 2: - val = RARRAY_PTR(v)[1]; + val = RARRAY_AREF(v, 1); case 1: - key = RARRAY_PTR(v)[0]; + key = RARRAY_AREF(v, 0); rb_hash_aset(hash, key, val); } } @@ -2597,7 +2597,7 @@ env_each_key(VALUE ehash) RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size); keys = env_keys(); /* rb_secure(4); */ for (i=0; iklass = 0; for (i=0; iklass = 0; for (i=0; ifd, &fds[0]); if (READ_DATA_PENDING(fptr) || READ_CHAR_PENDING(fptr)) { /* check for buffered data */ pending++; @@ -8116,7 +8116,7 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd if (!NIL_P(write)) { Check_Type(write, T_ARRAY); for (i=0; ifd, &fds[1]); if (max < fptr->fd) max = fptr->fd; @@ -8129,7 +8129,7 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd if (!NIL_P(except)) { Check_Type(except, T_ARRAY); for (i=0; ifd, &fds[2]); @@ -8160,7 +8160,7 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd rb_ary_push(res, ep?rb_ary_new():rb_ary_new2(0)); if (rp) { - list = RARRAY_PTR(res)[0]; + list = RARRAY_AREF(res, 0); for (i=0; i< RARRAY_LEN(read); i++) { VALUE obj = rb_ary_entry(read, i); VALUE io = rb_io_get_io(obj); @@ -8173,7 +8173,7 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd } if (wp) { - list = RARRAY_PTR(res)[1]; + list = RARRAY_AREF(res, 1); for (i=0; i< RARRAY_LEN(write); i++) { VALUE obj = rb_ary_entry(write, i); VALUE io = rb_io_get_io(obj); @@ -8186,7 +8186,7 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd } if (ep) { - list = RARRAY_PTR(res)[2]; + list = RARRAY_AREF(res, 2); for (i=0; i< RARRAY_LEN(except); i++) { VALUE obj = rb_ary_entry(except, i); VALUE io = rb_io_get_io(obj); diff --git a/iseq.c b/iseq.c index 93a2410d39..1e32bc31d6 100644 --- a/iseq.c +++ b/iseq.c @@ -1848,7 +1848,7 @@ iseq_data_to_ary(rb_iseq_t *iseq) ti = 0; for (i=0, pos=0; i= RARRAY_LEN(this_feature_index)) break; - entry = RARRAY_PTR(this_feature_index)[i]; + entry = RARRAY_AREF(this_feature_index, i); } else { if (i > 0) break; @@ -433,7 +433,7 @@ rb_feature_p(const char *feature, const char *ext, int rb, int expanded, const c } index = FIX2LONG(entry); - v = RARRAY_PTR(features)[index]; + v = RARRAY_AREF(features, index); f = StringValuePtr(v); if ((n = RSTRING_LEN(v)) < len) continue; if (strncmp(f, feature, len) != 0) { diff --git a/marshal.c b/marshal.c index abe3375b34..79fd94880e 100644 --- a/marshal.c +++ b/marshal.c @@ -783,7 +783,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) w_long(len, arg); for (i=0; i 0) { - VALUE m = RARRAY_PTR(extmod)[--i]; + VALUE m = RARRAY_AREF(extmod, --i); rb_extend_object(obj, m); } return obj; @@ -1756,11 +1756,11 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod) for (i=0; ireadable -= 2; diff --git a/numeric.c b/numeric.c index 413e9a9bbc..69cc71968d 100644 --- a/numeric.c +++ b/numeric.c @@ -260,8 +260,8 @@ do_coerce(VALUE *x, VALUE *y, int err) return FALSE; } - *x = RARRAY_PTR(ary)[0]; - *y = RARRAY_PTR(ary)[1]; + *x = RARRAY_AREF(ary, 0); + *y = RARRAY_AREF(ary, 1); return TRUE; } @@ -1846,8 +1846,8 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl) static VALUE num_step_size(VALUE from, VALUE args) { - VALUE to = RARRAY_PTR(args)[0]; - VALUE step = (RARRAY_LEN(args) > 1) ? RARRAY_PTR(args)[1] : INT2FIX(1); + VALUE to = RARRAY_AREF(args, 0); + VALUE step = (RARRAY_LEN(args) > 1) ? RARRAY_AREF(args, 1) : INT2FIX(1); return ruby_num_interval_step_size(from, to, step, FALSE); } /* @@ -3490,7 +3490,7 @@ fix_size(VALUE fix) static VALUE int_upto_size(VALUE from, VALUE args) { - return ruby_num_interval_step_size(from, RARRAY_PTR(args)[0], INT2FIX(1), FALSE); + return ruby_num_interval_step_size(from, RARRAY_AREF(args, 0), INT2FIX(1), FALSE); } /* @@ -3537,7 +3537,7 @@ int_upto(VALUE from, VALUE to) static VALUE int_downto_size(VALUE from, VALUE args) { - return ruby_num_interval_step_size(from, RARRAY_PTR(args)[0], INT2FIX(-1), FALSE); + return ruby_num_interval_step_size(from, RARRAY_AREF(args, 0), INT2FIX(-1), FALSE); } /* diff --git a/pack.c b/pack.c index 644ffd947a..ea83b0c037 100644 --- a/pack.c +++ b/pack.c @@ -421,8 +421,8 @@ pack_pack(VALUE ary, VALUE fmt) idx = 0; #define TOO_FEW (rb_raise(rb_eArgError, toofew), 0) -#define THISFROM (items > 0 ? RARRAY_PTR(ary)[idx] : TOO_FEW) -#define NEXTFROM (items-- > 0 ? RARRAY_PTR(ary)[idx++] : TOO_FEW) +#define THISFROM (items > 0 ? RARRAY_AREF(ary, idx) : TOO_FEW) +#define NEXTFROM (items-- > 0 ? RARRAY_AREF(ary, idx++) : TOO_FEW) while (p < pend) { int explicit_endian = 0; @@ -1020,9 +1020,9 @@ pack_pack(VALUE ary, VALUE fmt) VALUE big128 = rb_uint2big(128); while (RB_TYPE_P(from, T_BIGNUM)) { from = rb_big_divmod(from, big128); - c = castchar(NUM2INT(RARRAY_PTR(from)[1]) | 0x80); /* mod */ + c = castchar(NUM2INT(RARRAY_AREF(from, 1)) | 0x80); /* mod */ rb_str_buf_cat(buf, &c, sizeof(char)); - from = RARRAY_PTR(from)[0]; /* div */ + from = RARRAY_AREF(from, 0); /* div */ } } diff --git a/parse.y b/parse.y index 82adf171c2..c86649736e 100644 --- a/parse.y +++ b/parse.y @@ -5299,7 +5299,7 @@ coverage(const char *f, int n) VALUE lines = rb_ary_new2(n); int i; RBASIC(lines)->klass = 0; - for (i = 0; i < n; i++) RARRAY_PTR(lines)[i] = Qnil; + for (i = 0; i < n; i++) RARRAY_ASET(lines, i, Qnil); RARRAY(lines)->as.heap.len = n; rb_hash_aset(coverages, fname, lines); return lines; diff --git a/proc.c b/proc.c index 510b0fea5d..f4ce8382b8 100644 --- a/proc.c +++ b/proc.c @@ -2208,9 +2208,9 @@ static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc) { VALUE proc, passed, arity; - proc = RARRAY_PTR(args)[0]; - passed = RARRAY_PTR(args)[1]; - arity = RARRAY_PTR(args)[2]; + proc = RARRAY_AREF(args, 0); + passed = RARRAY_AREF(args, 1); + arity = RARRAY_AREF(args, 2); passed = rb_ary_plus(passed, rb_ary_new4(argc, argv)); rb_ary_freeze(passed); diff --git a/process.c b/process.c index f71886415e..f741d28089 100644 --- a/process.c +++ b/process.c @@ -1493,7 +1493,7 @@ check_exec_redirect1(VALUE ary, VALUE key, VALUE param) else { int i, n=0; for (i = 0 ; i < RARRAY_LEN(key); i++) { - VALUE v = RARRAY_PTR(key)[i]; + VALUE v = RARRAY_AREF(key, i); VALUE fd = check_exec_redirect_fd(v, !NIL_P(param)); rb_ary_push(ary, hide_obj(rb_assoc_new(fd, param))); n++; @@ -1808,21 +1808,21 @@ check_exec_fds_1(struct rb_execarg *eargp, VALUE h, int maxhint, VALUE ary) if (ary != Qfalse) { for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE elt = RARRAY_PTR(ary)[i]; - int fd = FIX2INT(RARRAY_PTR(elt)[0]); + VALUE elt = RARRAY_AREF(ary, i); + int fd = FIX2INT(RARRAY_AREF(elt, 0)); if (RTEST(rb_hash_lookup(h, INT2FIX(fd)))) { rb_raise(rb_eArgError, "fd %d specified twice", fd); } if (ary == eargp->fd_open || ary == eargp->fd_dup2) rb_hash_aset(h, INT2FIX(fd), Qtrue); else if (ary == eargp->fd_dup2_child) - rb_hash_aset(h, INT2FIX(fd), RARRAY_PTR(elt)[1]); + rb_hash_aset(h, INT2FIX(fd), RARRAY_AREF(elt, 1)); else /* ary == eargp->fd_close */ rb_hash_aset(h, INT2FIX(fd), INT2FIX(-1)); if (maxhint < fd) maxhint = fd; if (ary == eargp->fd_dup2 || ary == eargp->fd_dup2_child) { - fd = FIX2INT(RARRAY_PTR(elt)[1]); + fd = FIX2INT(RARRAY_AREF(elt, 1)); if (maxhint < fd) maxhint = fd; } @@ -1847,9 +1847,9 @@ check_exec_fds(struct rb_execarg *eargp) if (eargp->fd_dup2_child) { ary = eargp->fd_dup2_child; for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE elt = RARRAY_PTR(ary)[i]; - int newfd = FIX2INT(RARRAY_PTR(elt)[0]); - int oldfd = FIX2INT(RARRAY_PTR(elt)[1]); + VALUE elt = RARRAY_AREF(ary, i); + int newfd = FIX2INT(RARRAY_AREF(elt, 0)); + int oldfd = FIX2INT(RARRAY_AREF(elt, 1)); int lastfd = oldfd; VALUE val = rb_hash_lookup(h, INT2FIX(lastfd)); long depth = 0; @@ -1945,8 +1945,8 @@ rb_check_argv(int argc, VALUE *argv) if (RARRAY_LEN(tmp) != 2) { rb_raise(rb_eArgError, "wrong first argument"); } - prog = RARRAY_PTR(tmp)[0]; - argv[0] = RARRAY_PTR(tmp)[1]; + prog = RARRAY_AREF(tmp, 0); + argv[0] = RARRAY_AREF(tmp, 1); SafeStringValue(prog); StringValueCStr(prog); prog = rb_str_new_frozen(prog); @@ -2279,9 +2279,9 @@ rb_execarg_fixup(VALUE execarg_obj) st_table *stenv = RHASH_TBL(envtbl); long i; for (i = 0; i < RARRAY_LEN(envopts); i++) { - VALUE pair = RARRAY_PTR(envopts)[i]; - VALUE key = RARRAY_PTR(pair)[0]; - VALUE val = RARRAY_PTR(pair)[1]; + VALUE pair = RARRAY_AREF(envopts, i); + VALUE key = RARRAY_AREF(pair, 0); + VALUE val = RARRAY_AREF(pair, 1); if (NIL_P(val)) { st_data_t stkey = (st_data_t)key; st_delete(stenv, &stkey, NULL); @@ -2560,9 +2560,9 @@ run_exec_dup2(VALUE ary, VALUE tmpbuf, struct rb_execarg *sargp, char *errmsg, s /* initialize oldfd and newfd: O(n) */ for (i = 0; i < n; i++) { - VALUE elt = RARRAY_PTR(ary)[i]; - pairs[i].oldfd = FIX2INT(RARRAY_PTR(elt)[1]); - pairs[i].newfd = FIX2INT(RARRAY_PTR(elt)[0]); /* unique */ + VALUE elt = RARRAY_AREF(ary, i); + pairs[i].oldfd = FIX2INT(RARRAY_AREF(elt, 1)); + pairs[i].newfd = FIX2INT(RARRAY_AREF(elt, 0)); /* unique */ pairs[i].older_index = -1; } @@ -2686,8 +2686,8 @@ run_exec_close(VALUE ary, char *errmsg, size_t errmsg_buflen) int ret; for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE elt = RARRAY_PTR(ary)[i]; - int fd = FIX2INT(RARRAY_PTR(elt)[0]); + VALUE elt = RARRAY_AREF(ary, i); + int fd = FIX2INT(RARRAY_AREF(elt, 0)); ret = redirect_close(fd); /* async-signal-safe */ if (ret == -1) { ERRMSG("close"); @@ -2705,12 +2705,12 @@ run_exec_open(VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t errmsg_b int ret; for (i = 0; i < RARRAY_LEN(ary);) { - VALUE elt = RARRAY_PTR(ary)[i]; - int fd = FIX2INT(RARRAY_PTR(elt)[0]); - VALUE param = RARRAY_PTR(elt)[1]; - char *path = RSTRING_PTR(RARRAY_PTR(param)[0]); - int flags = NUM2INT(RARRAY_PTR(param)[1]); - int perm = NUM2INT(RARRAY_PTR(param)[2]); + VALUE elt = RARRAY_AREF(ary, i); + int fd = FIX2INT(RARRAY_AREF(elt, 0)); + VALUE param = RARRAY_AREF(elt, 1); + char *path = RSTRING_PTR(RARRAY_AREF(param, 0)); + int flags = NUM2INT(RARRAY_AREF(param, 1)); + int perm = NUM2INT(RARRAY_AREF(param, 2)); int need_close = 1; int fd2 = redirect_open(path, flags, perm); /* async-signal-safe */ if (fd2 == -1) { @@ -2719,8 +2719,8 @@ run_exec_open(VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t errmsg_b } rb_update_max_fd(fd2); while (i < RARRAY_LEN(ary) && - (elt = RARRAY_PTR(ary)[i], RARRAY_PTR(elt)[1] == param)) { - fd = FIX2INT(RARRAY_PTR(elt)[0]); + (elt = RARRAY_AREF(ary, i), RARRAY_AREF(elt, 1) == param)) { + fd = FIX2INT(RARRAY_AREF(elt, 0)); if (fd == fd2) { need_close = 0; } @@ -2755,9 +2755,9 @@ run_exec_dup2_child(VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t er int ret; for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE elt = RARRAY_PTR(ary)[i]; - int newfd = FIX2INT(RARRAY_PTR(elt)[0]); - int oldfd = FIX2INT(RARRAY_PTR(elt)[1]); + VALUE elt = RARRAY_AREF(ary, i); + int newfd = FIX2INT(RARRAY_AREF(elt, 0)); + int oldfd = FIX2INT(RARRAY_AREF(elt, 1)); if (save_redirect_fd(newfd, sargp, errmsg, errmsg_buflen) < 0) /* async-signal-safe */ return -1; @@ -2811,8 +2811,8 @@ run_exec_rlimit(VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t errmsg { long i; for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE elt = RARRAY_PTR(ary)[i]; - int rtype = NUM2INT(RARRAY_PTR(elt)[0]); + VALUE elt = RARRAY_AREF(ary, i); + int rtype = NUM2INT(RARRAY_AREF(elt, 0)); struct rlimit rlim; if (sargp) { VALUE tmp, newary; @@ -2820,7 +2820,7 @@ run_exec_rlimit(VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t errmsg ERRMSG("getrlimit"); return -1; } - tmp = hide_obj(rb_ary_new3(3, RARRAY_PTR(elt)[0], + tmp = hide_obj(rb_ary_new3(3, RARRAY_AREF(elt, 0), RLIM2NUM(rlim.rlim_cur), RLIM2NUM(rlim.rlim_max))); if (sargp->rlimit_limits == Qfalse) @@ -2829,8 +2829,8 @@ run_exec_rlimit(VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t errmsg newary = sargp->rlimit_limits; rb_ary_push(newary, tmp); } - rlim.rlim_cur = NUM2RLIM(RARRAY_PTR(elt)[1]); - rlim.rlim_max = NUM2RLIM(RARRAY_PTR(elt)[2]); + rlim.rlim_cur = NUM2RLIM(RARRAY_AREF(elt, 1)); + rlim.rlim_max = NUM2RLIM(RARRAY_AREF(elt, 2)); if (setrlimit(rtype, &rlim) == -1) { /* hopefully async-signal-safe */ ERRMSG("setrlimit"); return -1; @@ -2905,9 +2905,9 @@ rb_execarg_run_options(const struct rb_execarg *eargp, struct rb_execarg *sargp, long i; save_env(sargp); for (i = 0; i < RARRAY_LEN(obj); i++) { - VALUE pair = RARRAY_PTR(obj)[i]; - VALUE key = RARRAY_PTR(pair)[0]; - VALUE val = RARRAY_PTR(pair)[1]; + VALUE pair = RARRAY_AREF(obj, i); + VALUE key = RARRAY_AREF(pair, 0); + VALUE val = RARRAY_AREF(pair, 1); if (NIL_P(val)) ruby_setenv(StringValueCStr(key), 0); else @@ -5527,7 +5527,7 @@ proc_setgroups(VALUE obj, VALUE ary) groups = ALLOCA_N(rb_gid_t, ngroups); for (i = 0; i < ngroups; i++) { - VALUE g = RARRAY_PTR(ary)[i]; + VALUE g = RARRAY_AREF(ary, i); groups[i] = OBJ2GID(g); } diff --git a/range.c b/range.c index 1e4347ed2f..d3ead78d94 100644 --- a/range.c +++ b/range.c @@ -327,7 +327,7 @@ range_step_size(VALUE range, VALUE args) VALUE b = RANGE_BEG(range), e = RANGE_END(range); VALUE step = INT2FIX(1); if (args) { - step = RARRAY_PTR(args)[0]; + step = RARRAY_AREF(args, 0); if (!rb_obj_is_kind_of(step, rb_cNumeric)) { step = rb_to_int(step); } diff --git a/rational.c b/rational.c index 7b3e851e7e..bbf1cafcb1 100644 --- a/rational.c +++ b/rational.c @@ -1666,11 +1666,11 @@ nurat_marshal_load(VALUE self, VALUE a) Check_Type(a, T_ARRAY); if (RARRAY_LEN(a) != 2) rb_raise(rb_eArgError, "marshaled rational must have an array whose length is 2 but %ld", RARRAY_LEN(a)); - if (f_zero_p(RARRAY_PTR(a)[1])) + if (f_zero_p(RARRAY_AREF(a, 1))) rb_raise_zerodiv(); - rb_ivar_set(self, id_i_num, RARRAY_PTR(a)[0]); - rb_ivar_set(self, id_i_den, RARRAY_PTR(a)[1]); + rb_ivar_set(self, id_i_num, RARRAY_AREF(a, 0)); + rb_ivar_set(self, id_i_den, RARRAY_AREF(a, 1)); return self; } diff --git a/re.c b/re.c index fe7e3903b5..1b44f36b21 100644 --- a/re.c +++ b/re.c @@ -2342,7 +2342,7 @@ rb_reg_preprocess_dregexp(VALUE ary, int options) } for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE str = RARRAY_PTR(ary)[i]; + VALUE str = RARRAY_AREF(ary, i); VALUE buf; char *p, *end; rb_encoding *src_enc; diff --git a/ruby.c b/ruby.c index c1c65137af..fc298878ee 100644 --- a/ruby.c +++ b/ruby.c @@ -1442,8 +1442,8 @@ process_options(int argc, char **argv, struct cmdline_options *opt) long i; VALUE load_path = GET_VM()->load_path; for (i = 0; i < RARRAY_LEN(load_path); ++i) { - RARRAY_PTR(load_path)[i] = - rb_enc_associate(rb_str_dup(RARRAY_PTR(load_path)[i]), lenc); + RARRAY_ASET(load_path, i, + rb_enc_associate(rb_str_dup(RARRAY_AREF(load_path, i)), lenc)); } } if (!(opt->disable & DISABLE_BIT(gems))) { diff --git a/string.c b/string.c index cc03afbfa4..11e974ea32 100644 --- a/string.c +++ b/string.c @@ -6115,7 +6115,7 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str) if (NIL_P(limit) && lim == 0) { long len; while ((len = RARRAY_LEN(result)) > 0 && - (tmp = RARRAY_PTR(result)[len-1], RSTRING_LEN(tmp) == 0)) + (tmp = RARRAY_AREF(result, len-1), RSTRING_LEN(tmp) == 0)) rb_ary_pop(result); } diff --git a/struct.c b/struct.c index 7091322d05..d938c0ed55 100644 --- a/struct.c +++ b/struct.c @@ -354,7 +354,7 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass) rest = rb_ary_tmp_new(argc); for (i=0; ipending_interrupt_queue); i++) { - VALUE e = RARRAY_PTR(th->pending_interrupt_queue)[i]; + VALUE e = RARRAY_AREF(th->pending_interrupt_queue, i); if (rb_class_inherited_p(e, err)) { return TRUE; } @@ -1597,7 +1597,7 @@ rb_threadptr_pending_interrupt_deque(rb_thread_t *th, enum handle_interrupt_timi int i; for (i=0; ipending_interrupt_queue); i++) { - VALUE err = RARRAY_PTR(th->pending_interrupt_queue)[i]; + VALUE err = RARRAY_AREF(th->pending_interrupt_queue, i); enum handle_interrupt_timing mask_timing = rb_threadptr_pending_interrupt_check_mask(th, CLASS_OF(err)); @@ -3869,8 +3869,8 @@ clear_coverage_i(st_data_t key, st_data_t val, st_data_t dummy) VALUE lines = (VALUE)val; for (i = 0; i < RARRAY_LEN(lines); i++) { - if (RARRAY_PTR(lines)[i] != Qnil) { - RARRAY_PTR(lines)[i] = INT2FIX(0); + if (RARRAY_AREF(lines, i) != Qnil) { + RARRAY_ASET(lines, i, INT2FIX(0)); } } return ST_CONTINUE; @@ -5210,12 +5210,12 @@ update_coverage(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klas if (coverage && RBASIC(coverage)->klass == 0) { long line = rb_sourceline() - 1; long count; - if (RARRAY_PTR(coverage)[line] == Qnil) { + if (RARRAY_AREF(coverage, line) == Qnil) { return; } - count = FIX2LONG(RARRAY_PTR(coverage)[line]) + 1; + count = FIX2LONG(RARRAY_AREF(coverage, line)) + 1; if (POSFIXABLE(count)) { - RARRAY_PTR(coverage)[line] = LONG2FIX(count); + RARRAY_ASET(coverage, line, LONG2FIX(count)); } } } diff --git a/transcode.c b/transcode.c index b03241fcfc..58a4265e0e 100644 --- a/transcode.c +++ b/transcode.c @@ -3057,10 +3057,10 @@ decorate_convpath(VALUE convpath, int ecflags) len = n = RARRAY_LENINT(convpath); if (n != 0) { - VALUE pair = RARRAY_PTR(convpath)[n-1]; + VALUE pair = RARRAY_AREF(convpath, n-1); if (RB_TYPE_P(pair, T_ARRAY)) { - const char *sname = rb_enc_name(rb_to_encoding(RARRAY_PTR(pair)[0])); - const char *dname = rb_enc_name(rb_to_encoding(RARRAY_PTR(pair)[1])); + const char *sname = rb_enc_name(rb_to_encoding(RARRAY_AREF(pair, 0))); + const char *dname = rb_enc_name(rb_to_encoding(RARRAY_AREF(pair, 1))); transcoder_entry_t *entry = get_transcoder_entry(sname, dname); const rb_transcoder *tr = load_transcoder_entry(entry); if (!tr) diff --git a/vm.c b/vm.c index c467882323..bd38d2d640 100644 --- a/vm.c +++ b/vm.c @@ -2129,7 +2129,7 @@ m_core_hash_from_ary(VALUE self, VALUE ary) assert(RARRAY_LEN(ary) % 2 == 0); for (i=0; iloaded_features); i++) { - name = RARRAY_PTR(vm->loaded_features)[i]; + name = RARRAY_AREF(vm->loaded_features, i); if (RB_TYPE_P(name, T_STRING)) { fprintf(stderr, " %4d %.*s\n", i, LIMITED_NAME_LENGTH(name), RSTRING_PTR(name)); diff --git a/vm_eval.c b/vm_eval.c index 0db24040e6..7b8aafeb63 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -1256,15 +1256,15 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char (bt2 = rb_vm_backtrace_str_ary(th, 0, 0), RARRAY_LEN(bt2) > 0)) { if (!NIL_P(mesg) && RB_TYPE_P(mesg, T_STRING) && !RSTRING_LEN(mesg)) { if (OBJ_FROZEN(mesg)) { - VALUE m = rb_str_cat(rb_str_dup(RARRAY_PTR(errat)[0]), ": ", 2); + VALUE m = rb_str_cat(rb_str_dup(RARRAY_AREF(errat, 0)), ": ", 2); rb_ivar_set(errinfo, id_mesg, rb_str_append(m, mesg)); } else { rb_str_update(mesg, 0, 0, rb_str_new2(": ")); - rb_str_update(mesg, 0, 0, RARRAY_PTR(errat)[0]); + rb_str_update(mesg, 0, 0, RARRAY_AREF(errat, 0)); } } - RARRAY_PTR(errat)[0] = RARRAY_PTR(bt2)[0]; + RARRAY_AREF(errat, 0) = RARRAY_AREF(bt2, 0); } } rb_exc_raise(errinfo); diff --git a/vm_method.c b/vm_method.c index 516b87cb3e..3882b98d4e 100644 --- a/vm_method.c +++ b/vm_method.c @@ -1574,8 +1574,8 @@ rb_obj_respond_to(VALUE obj, ID id, int priv) (FL_TEST(klass, FL_SINGLETON) ? '.' : '#'), QUOTE_ID(id)); if (!NIL_P(location)) { - VALUE path = RARRAY_PTR(location)[0]; - VALUE line = RARRAY_PTR(location)[1]; + VALUE path = RARRAY_AREF(location, 0); + VALUE line = RARRAY_AREF(location, 1); if (!NIL_P(path)) { rb_compile_warn(RSTRING_PTR(path), NUM2INT(line), "respond_to? is defined here");