From 5be0ab591cbc71bdafe32bb1b86860da2fe7e03c Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 24 Jun 2012 13:53:44 +0000 Subject: [PATCH] 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 --- ChangeLog | 5 +++++ process.c | 34 ++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30533e4d4f..76005fe5d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Jun 24 22:53:42 2012 Nobuyoshi Nakada + + * process.c (check_exec_fds): separate check_exec_fds_1() since + nonstatic initializer of an aggregate type is not allowed by C89. + Sun Jun 24 07:47:17 2012 Tanaka Akira * internal.h (rb_execarg): options field removed. diff --git a/process.c b/process.c index 63f31457c7..8fa00ffe7d 100644 --- a/process.c +++ b/process.c @@ -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;