diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-13 09:56:22 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-13 09:56:22 +0000 |
commit | aacd7710462142df7397618ffff4279e495f10f9 (patch) | |
tree | 6611fdbf0f66b471386ad19d7854275c583b8914 /process.c | |
parent | 12bf73637b960cf0ef463f966554595ff2c37ecd (diff) | |
download | ruby-aacd7710462142df7397618ffff4279e495f10f9.tar.gz |
* *.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
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 76 |
1 files changed, 38 insertions, 38 deletions
@@ -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); } |