ruby-changes:24142
From: akr <ko1@a...>
Date: Sat, 23 Jun 2012 10:44:04 +0900 (JST)
Subject: [ruby-changes:24142] akr:r36193 (trunk): * internal.h (rb_execarg): add unsetenv_others_given and
akr 2012-06-23 10:43:51 +0900 (Sat, 23 Jun 2012) New Revision: 36193 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36193 Log: * internal.h (rb_execarg): add unsetenv_others_given and unsetenv_others_do fields. * process.c (EXEC_OPTION_UNSETENV_OTHERS): removed. (rb_execarg_addopt): update the new fields, instead of options array. (rb_execarg_fixup): use the new fields. Modified files: trunk/ChangeLog trunk/internal.h trunk/process.c Index: ChangeLog =================================================================== --- ChangeLog (revision 36192) +++ ChangeLog (revision 36193) @@ -1,3 +1,12 @@ +Sat Jun 23 10:41:59 2012 Tanaka Akira <akr@f...> + + * internal.h (rb_execarg): add unsetenv_others_given and + unsetenv_others_do fields. + + * process.c (EXEC_OPTION_UNSETENV_OTHERS): removed. + (rb_execarg_addopt): update the new fields, instead of options array. + (rb_execarg_fixup): use the new fields. + Sat Jun 23 09:35:47 2012 Tanaka Akira <akr@f...> * process.c: use the variable name "soptions" for sargp->options. Index: process.c =================================================================== --- process.c (revision 36192) +++ process.c (revision 36193) @@ -1255,7 +1255,6 @@ enum { EXEC_OPTION_RLIMIT, - EXEC_OPTION_UNSETENV_OTHERS, EXEC_OPTION_ENV, EXEC_OPTION_CHDIR, EXEC_OPTION_DUP2, @@ -1617,11 +1616,11 @@ else #endif if (id == rb_intern("unsetenv_others")) { - if (!NIL_P(rb_ary_entry(options, EXEC_OPTION_UNSETENV_OTHERS))) { + if (eargp->unsetenv_others_given) { rb_raise(rb_eArgError, "unsetenv_others option specified twice"); } - val = RTEST(val) ? Qtrue : Qfalse; - rb_ary_store(options, EXEC_OPTION_UNSETENV_OTHERS, val); + eargp->unsetenv_others_given = 1; + eargp->unsetenv_others_do = RTEST(val) ? 1 : 0; } else if (id == rb_intern("chdir")) { if (!NIL_P(rb_ary_entry(options, EXEC_OPTION_CHDIR))) { @@ -2116,7 +2115,8 @@ rb_execarg_fixup(VALUE execarg_obj) { struct rb_execarg *eargp = rb_execarg_get(execarg_obj); - VALUE unsetenv_others, envopts; + int unsetenv_others; + VALUE envopts; VALUE ary; eargp->redirect_fds = check_exec_fds(eargp->options); @@ -2129,12 +2129,12 @@ eargp->dup2_tmpbuf = tmpbuf; } - unsetenv_others = rb_ary_entry(eargp->options, EXEC_OPTION_UNSETENV_OTHERS); + unsetenv_others = eargp->unsetenv_others_given && eargp->unsetenv_others_do; envopts = rb_ary_entry(eargp->options, EXEC_OPTION_ENV); - if (RTEST(unsetenv_others) || !NIL_P(envopts)) { + if (unsetenv_others || !NIL_P(envopts)) { VALUE envtbl, envp_str, envp_buf; char *p, *ep; - if (RTEST(unsetenv_others)) { + if (unsetenv_others) { envtbl = rb_hash_new(); } else { Index: internal.h =================================================================== --- internal.h (revision 36192) +++ internal.h (revision 36193) @@ -178,6 +178,8 @@ VALUE dup2_tmpbuf; unsigned pgroup_given : 1; unsigned umask_given : 1; + unsigned unsetenv_others_given : 1; + unsigned unsetenv_others_do : 1; pid_t pgroup_pgid; /* asis(-1), new pgroup(0), specified pgroup (0<V). */ mode_t umask_mask; }; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/