From 759c214a339e95f58ffe1fb2220541b1d23f6d73 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 23 Jun 2012 09:44:43 +0000 Subject: * 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 --- process.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'process.c') diff --git a/process.c b/process.c index 164a5230a5..a0c1c79a80 100644 --- a/process.c +++ b/process.c @@ -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) -- cgit v1.2.3