From 26ecb6cbc4d6ebd3fcb7d8a1f829e2910ad26bdc Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 23 Jun 2012 08:18:34 +0000 Subject: [PATCH] * internal.h (rb_execarg): add env_modification field. * process.c (EXEC_OPTION_ENV): removed. (mark_exec_arg): mark env_modification field. (rb_exec_fillarg): update the new field, instead of options array. (rb_execarg_fixup): use the new field. (save_env): ditto. (rb_execarg_run_options): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ internal.h | 1 + process.c | 16 ++++++++-------- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49f5cfe161..41f9c473c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Sat Jun 23 17:04:08 2012 Tanaka Akira + + * internal.h (rb_execarg): add env_modification field. + + * process.c (EXEC_OPTION_ENV): removed. + (mark_exec_arg): mark env_modification field. + (rb_exec_fillarg): update the new field, instead of options array. + (rb_execarg_fixup): use the new field. + (save_env): ditto. + (rb_execarg_run_options): ditto. + Sat Jun 23 16:27:01 2012 Tanaka Akira * internal.h (rb_execarg): add rlimit_limits field. diff --git a/internal.h b/internal.h index 662d8bf474..ea0846c8f1 100644 --- a/internal.h +++ b/internal.h @@ -187,6 +187,7 @@ struct rb_execarg { VALUE rlimit_limits; /* Qfalse or [[rtype, softlim, hardlim], ...] */ mode_t umask_mask; int close_others_maxhint; + VALUE env_modification; /* Qfalse or [[k1,v1], ...] */ VALUE chdir_dir; }; diff --git a/process.c b/process.c index bf937dfa7a..61a0d01aa9 100644 --- a/process.c +++ b/process.c @@ -1254,7 +1254,6 @@ rb_proc_exec(const char *str) } enum { - EXEC_OPTION_ENV, EXEC_OPTION_DUP2, EXEC_OPTION_CLOSE, EXEC_OPTION_OPEN, @@ -1280,6 +1279,7 @@ mark_exec_arg(void *ptr) rb_gc_mark(eargp->envp_buf); rb_gc_mark(eargp->dup2_tmpbuf); rb_gc_mark(eargp->rlimit_limits); + rb_gc_mark(eargp->env_modification); rb_gc_mark(eargp->chdir_dir); } @@ -1896,7 +1896,7 @@ rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, VAL } if (!NIL_P(env)) { env = rb_check_exec_env(env); - rb_ary_store(options, EXEC_OPTION_ENV, env); + eargp->env_modification = env; } eargp->use_shell = argc == 0; @@ -2128,8 +2128,8 @@ rb_execarg_fixup(VALUE execarg_obj) } unsetenv_others = eargp->unsetenv_others_given && eargp->unsetenv_others_do; - envopts = rb_ary_entry(eargp->options, EXEC_OPTION_ENV); - if (unsetenv_others || !NIL_P(envopts)) { + envopts = eargp->env_modification; + if (unsetenv_others || envopts != Qfalse) { VALUE envtbl, envp_str, envp_buf; char *p, *ep; if (unsetenv_others) { @@ -2705,13 +2705,13 @@ save_env(struct rb_execarg *sargp) if (!sargp) return; soptions = sargp->options; - if (NIL_P(rb_ary_entry(soptions, EXEC_OPTION_ENV))) { + if (sargp->env_modification == Qfalse) { VALUE env = rb_const_get(rb_cObject, rb_intern("ENV")); if (RTEST(env)) { VALUE ary = hide_obj(rb_ary_new()); rb_block_call(env, rb_intern("each"), 0, 0, save_env_i, (VALUE)ary); - rb_ary_store(soptions, EXEC_OPTION_ENV, ary); + sargp->env_modification = ary; } rb_ary_store(soptions, EXEC_OPTION_UNSETENV_OTHERS, Qtrue); } @@ -2757,8 +2757,8 @@ rb_execarg_run_options(const struct rb_execarg *eargp, struct rb_execarg *sargp, rb_env_clear(); } - obj = rb_ary_entry(options, EXEC_OPTION_ENV); - if (!NIL_P(obj)) { + obj = eargp->env_modification; + if (obj != Qfalse) { long i; save_env(sargp); for (i = 0; i < RARRAY_LEN(obj); i++) {