diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-23 09:44:43 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-23 09:44:43 +0000 |
commit | 759c214a339e95f58ffe1fb2220541b1d23f6d73 (patch) | |
tree | 015340244f5c6b99566ea9ea3339efd3f0b33653 /process.c | |
parent | 92af9dddc8f55e0331bf2fc0ee985be4f433b339 (diff) | |
download | ruby-759c214a339e95f58ffe1fb2220541b1d23f6d73.tar.gz |
* process.c (check_exec_redirect1): extracted from
check_exec_redirect.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 41 |
1 files changed, 24 insertions, 17 deletions
@@ -1430,6 +1430,28 @@ check_exec_redirect_fd(VALUE v, int iskey) return INT2FIX(fd); } +static VALUE +check_exec_redirect1(VALUE ary, VALUE key, VALUE param) +{ + if (NIL_P(ary)) { + ary = hide_obj(rb_ary_new()); + } + if (!RB_TYPE_P(key, T_ARRAY)) { + VALUE fd = check_exec_redirect_fd(key, !NIL_P(param)); + rb_ary_push(ary, hide_obj(rb_assoc_new(fd, param))); + } + else { + int i, n=0; + for (i = 0 ; i < RARRAY_LEN(key); i++) { + VALUE v = RARRAY_PTR(key)[i]; + VALUE fd = check_exec_redirect_fd(v, !NIL_P(param)); + rb_ary_push(ary, hide_obj(rb_assoc_new(fd, param))); + n++; + } + } + return ary; +} + static void check_exec_redirect(VALUE key, VALUE val, VALUE options) { @@ -1515,23 +1537,8 @@ check_exec_redirect(VALUE key, VALUE val, VALUE options) } ary = rb_ary_entry(options, index); - if (NIL_P(ary)) { - ary = hide_obj(rb_ary_new()); - rb_ary_store(options, index, ary); - } - if (!RB_TYPE_P(key, T_ARRAY)) { - VALUE fd = check_exec_redirect_fd(key, !NIL_P(param)); - rb_ary_push(ary, hide_obj(rb_assoc_new(fd, param))); - } - else { - int i, n=0; - for (i = 0 ; i < RARRAY_LEN(key); i++) { - VALUE v = RARRAY_PTR(key)[i]; - VALUE fd = check_exec_redirect_fd(v, !NIL_P(param)); - rb_ary_push(ary, hide_obj(rb_assoc_new(fd, param))); - n++; - } - } + ary = check_exec_redirect1(ary, key, param); + rb_ary_store(options, index, ary); } #if defined(HAVE_SETRLIMIT) && defined(NUM2RLIM) |