diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-24 13:53:44 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-24 13:53:44 +0000 |
commit | 5be0ab591cbc71bdafe32bb1b86860da2fe7e03c (patch) | |
tree | 387e470ebba91af2e65563ee4daae0368fd3ef0c /process.c | |
parent | 5cc2112ed1180635adad9d0ca5db162fc171d85d (diff) | |
download | ruby-5be0ab591cbc71bdafe32bb1b86860da2fe7e03c.tar.gz |
process.c: separate check_exec_fds_1
* process.c (check_exec_fds): separate check_exec_fds_1() since
nonstatic initializer of an aggregate type is not allowed by C89.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 36 |
1 files changed, 19 insertions, 17 deletions
@@ -1689,25 +1689,12 @@ check_exec_options_i(st_data_t st_key, st_data_t st_val, st_data_t arg) return rb_execarg_addopt(execarg_obj, key, val); } -static VALUE -check_exec_fds(struct rb_execarg *eargp) +static int +check_exec_fds_1(struct rb_execarg *eargp, VALUE h, int maxhint, VALUE ary) { - VALUE h = rb_hash_new(); - VALUE ary; - int maxhint = -1; long i; - int j; - VALUE fd_opts[] = { - eargp->fd_dup2, - eargp->fd_close, - eargp->fd_open, - eargp->fd_dup2_child - }; - - for (j = 0; j < (int)(sizeof(fd_opts)/sizeof(*fd_opts)); j++) { - ary = fd_opts[j]; - if (ary == Qfalse) - continue; + + if (ary != Qfalse) { for (i = 0; i < RARRAY_LEN(ary); i++) { VALUE elt = RARRAY_PTR(ary)[i]; int fd = FIX2INT(RARRAY_PTR(elt)[0]); @@ -1729,6 +1716,21 @@ check_exec_fds(struct rb_execarg *eargp) } } } + return maxhint; +} + +static VALUE +check_exec_fds(struct rb_execarg *eargp) +{ + VALUE h = rb_hash_new(); + VALUE ary; + int maxhint = -1; + long i; + + maxhint = check_exec_fds_1(eargp, h, maxhint, eargp->fd_dup2); + maxhint = check_exec_fds_1(eargp, h, maxhint, eargp->fd_close); + maxhint = check_exec_fds_1(eargp, h, maxhint, eargp->fd_open); + maxhint = check_exec_fds_1(eargp, h, maxhint, eargp->fd_dup2_child); if (eargp->fd_dup2_child) { ary = eargp->fd_dup2_child; |