diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-05 15:24:32 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-05 15:24:32 +0000 |
commit | 3162e673a1f376ae2126c10eec0e97ae76181af3 (patch) | |
tree | b96175555eb9d28fd24f924cbafdf9d1f011af28 | |
parent | 53b17a769b873a889c15c4cf4d34e9a58a03b552 (diff) | |
download | ruby-3162e673a1f376ae2126c10eec0e97ae76181af3.tar.gz |
* internal.h (rb_exec_arg_init): change return type to void.
* process.c (rb_exec_arg_init): don't return a value.
(rb_exec_arg_prepare): ditto.
(rb_spawn_process): don't take the prog argument. extract the
information from earg.
(rb_spawn_internal): follow rb_spawn_process change.
(rb_f_spawn): ditto.
* io.c (pipe_open): don't take the prog argument. extract the
information from eargp.
(pipe_open_v): follow pipe_open change.
(pipe_open_s): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | internal.h | 2 | ||||
-rw-r--r-- | io.c | 12 | ||||
-rw-r--r-- | process.c | 20 |
4 files changed, 34 insertions, 16 deletions
@@ -1,3 +1,19 @@ +Wed Jun 6 00:20:37 2012 Tanaka Akira <akr@fsij.org> + + * internal.h (rb_exec_arg_init): change return type to void. + + * process.c (rb_exec_arg_init): don't return a value. + (rb_exec_arg_prepare): ditto. + (rb_spawn_process): don't take the prog argument. extract the + information from earg. + (rb_spawn_internal): follow rb_spawn_process change. + (rb_f_spawn): ditto. + + * io.c (pipe_open): don't take the prog argument. extract the + information from eargp. + (pipe_open_v): follow pipe_open change. + (pipe_open_s): ditto. + Tue Jun 5 23:51:33 2012 Tanaka Akira <akr@fsij.org> * internal.h (rb_exec_arg): use union to represent command invocation diff --git a/internal.h b/internal.h index 05e855df00..6a988c95c6 100644 --- a/internal.h +++ b/internal.h @@ -185,7 +185,7 @@ struct rb_exec_arg { #define ARGVSTR2ARGC(argv_str) (RSTRING_LEN(argv_str) / sizeof(char *) - 2) #define ARGVSTR2ARGV(argv_str) ((char **)RSTRING_PTR(argv_str) + 1) -VALUE rb_exec_arg_init(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e); +void rb_exec_arg_init(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e); int rb_exec_arg_addopt(struct rb_exec_arg *e, VALUE key, VALUE val); void rb_exec_arg_fixup(struct rb_exec_arg *e); int rb_run_exec_options(const struct rb_exec_arg *e, struct rb_exec_arg *s); @@ -5471,8 +5471,9 @@ popen_exec(void *pp, char *errmsg, size_t errmsg_len) #endif static VALUE -pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *modestr, int fmode, convconfig_t *convconfig) +pipe_open(struct rb_exec_arg *eargp, const char *modestr, int fmode, convconfig_t *convconfig) { + VALUE prog = eargp ? (eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name) : Qfalse ; rb_pid_t pid = 0; rb_io_t *fptr; VALUE port; @@ -5730,10 +5731,9 @@ pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *modestr, int fmode, static VALUE pipe_open_v(int argc, VALUE *argv, const char *modestr, int fmode, convconfig_t *convconfig) { - VALUE prog; struct rb_exec_arg earg; - prog = rb_exec_arg_init(argc, argv, FALSE, &earg); - return pipe_open(&earg, prog, modestr, fmode, convconfig); + rb_exec_arg_init(argc, argv, FALSE, &earg); + return pipe_open(&earg, modestr, fmode, convconfig); } static VALUE @@ -5749,11 +5749,11 @@ pipe_open_s(VALUE prog, const char *modestr, int fmode, convconfig_t *convconfig rb_raise(rb_eNotImpError, "fork() function is unimplemented on this machine"); #endif - return pipe_open(0, 0, modestr, fmode, convconfig); + return pipe_open(NULL, modestr, fmode, convconfig); } rb_exec_arg_init(argc, argv, TRUE, &earg); - return pipe_open(&earg, prog, modestr, fmode, convconfig); + return pipe_open(&earg, modestr, fmode, convconfig); } /* @@ -1846,14 +1846,13 @@ rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, str } } -VALUE +void rb_exec_arg_init(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e) { VALUE prog; VALUE env = Qnil, opthash = Qnil; prog = rb_exec_getargs(&argc, &argv, accept_shell, &env, &opthash); rb_exec_fillarg(prog, argc, argv, env, opthash, e); - return prog; } static int @@ -3113,21 +3112,21 @@ rb_syswait(rb_pid_t pid) rb_waitpid(pid, &status, 0); } -static VALUE +static void rb_exec_arg_prepare(struct rb_exec_arg *earg, int argc, VALUE *argv, int default_close_others) { - VALUE prog = rb_exec_arg_init(argc, argv, TRUE, earg); + rb_exec_arg_init(argc, argv, TRUE, earg); if (NIL_P(rb_ary_entry(earg->options, EXEC_OPTION_CLOSE_OTHERS))) { VALUE v = default_close_others ? Qtrue : Qfalse; rb_exec_arg_addopt(earg, ID2SYM(rb_intern("close_others")), v); } rb_exec_arg_fixup(earg); - return prog; } static rb_pid_t -rb_spawn_process(struct rb_exec_arg *earg, VALUE prog, char *errmsg, size_t errmsg_buflen) +rb_spawn_process(struct rb_exec_arg *earg, char *errmsg, size_t errmsg_buflen) { + VALUE prog; rb_pid_t pid; #if !USE_SPAWNV int status; @@ -3136,6 +3135,8 @@ rb_spawn_process(struct rb_exec_arg *earg, VALUE prog, char *errmsg, size_t errm struct rb_exec_arg sarg; #endif + prog = earg->use_shell ? earg->invoke.sh.shell_script : earg->invoke.cmd.command_name; + #if defined HAVE_FORK && !USE_SPAWNV pid = rb_fork_err(&status, rb_exec_atfork, earg, earg->redirect_fds, errmsg, errmsg_buflen); #else @@ -3179,8 +3180,8 @@ rb_spawn_internal(int argc, VALUE *argv, int default_close_others, char *errmsg, size_t errmsg_buflen) { struct rb_exec_arg earg; - VALUE prog = rb_exec_arg_prepare(&earg, argc, argv, default_close_others); - return rb_spawn_process(&earg, prog, errmsg, errmsg_buflen); + rb_exec_arg_prepare(&earg, argc, argv, default_close_others); + return rb_spawn_process(&earg, errmsg, errmsg_buflen); } rb_pid_t @@ -3513,7 +3514,8 @@ rb_f_spawn(int argc, VALUE *argv) char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' }; struct rb_exec_arg earg; - pid = rb_spawn_process(&earg, rb_exec_arg_prepare(&earg, argc, argv, TRUE), errmsg, sizeof(errmsg)); + rb_exec_arg_prepare(&earg, argc, argv, TRUE); + pid = rb_spawn_process(&earg, errmsg, sizeof(errmsg)); if (pid == -1) { const char *prog = errmsg; if (!prog[0]) { |