ruby-changes:24102
From: akr <ko1@a...>
Date: Wed, 20 Jun 2012 20:47:03 +0900 (JST)
Subject: [ruby-changes:24102] akr:r36153 (trunk): * internal.h (struct rb_execarg) moved and renamed from
akr 2012-06-20 20:46:50 +0900 (Wed, 20 Jun 2012) New Revision: 36153 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36153 Log: * internal.h (struct rb_execarg) moved and renamed from struct rb_exec_arg in intern.h. * include/ruby/intern.h (struct rb_exec_arg): refer Data object which contains struct rb_execarg. * process.c: use struct rb_execarg instead of struct rb_exec_arg except functions declared in intern.h. (rb_exec_arg_addopt): extract a pointer to struct rb_execarg from struct rb_exec_arg. (rb_exec_arg_init): ditto. (rb_exec_arg_fixup): ditto. (rb_run_exec_options_err): ditto. (rb_run_exec_options): ditto. (rb_exec_err): ditto. (rb_exec): ditto. * io.c: use struct rb_execarg instead of struct rb_exec_arg. * ext/pty/pty.c: ditto. Modified files: trunk/ChangeLog trunk/ext/pty/pty.c trunk/include/ruby/intern.h trunk/internal.h trunk/io.c trunk/process.c Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 36152) +++ include/ruby/intern.h (revision 36153) @@ -582,23 +582,7 @@ void rb_last_status_set(int status, rb_pid_t pid); VALUE rb_last_status_get(void); struct rb_exec_arg { - int use_shell; - union { - struct { - VALUE shell_script; - } sh; - struct { - VALUE command_name; - VALUE command_abspath; /* full path string or nil */ - VALUE argv_str; - VALUE argv_buf; - } cmd; - } invoke; - VALUE options; - VALUE redirect_fds; - VALUE envp_str; - VALUE envp_buf; - VALUE dup2_tmpbuf; + VALUE execarg_obj; }; DEPRECATED(int rb_proc_exec_n(int, VALUE*, const char*)); int rb_proc_exec(const char*); Index: ChangeLog =================================================================== --- ChangeLog (revision 36152) +++ ChangeLog (revision 36153) @@ -1,3 +1,26 @@ +Wed Jun 20 20:38:23 2012 Tanaka Akira <akr@f...> + + * internal.h (struct rb_execarg) moved and renamed from + struct rb_exec_arg in intern.h. + + * include/ruby/intern.h (struct rb_exec_arg): refer Data object which + contains struct rb_execarg. + + * process.c: use struct rb_execarg instead of struct rb_exec_arg + except functions declared in intern.h. + (rb_exec_arg_addopt): extract a pointer to struct rb_execarg from + struct rb_exec_arg. + (rb_exec_arg_init): ditto. + (rb_exec_arg_fixup): ditto. + (rb_run_exec_options_err): ditto. + (rb_run_exec_options): ditto. + (rb_exec_err): ditto. + (rb_exec): ditto. + + * io.c: use struct rb_execarg instead of struct rb_exec_arg. + + * ext/pty/pty.c: ditto. + Wed Jun 20 19:13:25 2012 Tanaka Akira <akr@f...> * internal.h (rb_execarg_new): declared. Index: io.c =================================================================== --- io.c (revision 36152) +++ io.c (revision 36153) @@ -5342,7 +5342,7 @@ #ifdef HAVE_FORK struct popen_arg { - struct rb_exec_arg *execp; + struct rb_execarg *execp; int modef; int pair[2]; int write_pair[2]; @@ -5466,7 +5466,7 @@ #endif static VALUE -pipe_open(struct rb_exec_arg *eargp, const char *modestr, int fmode, convconfig_t *convconfig) +pipe_open(struct rb_execarg *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; @@ -5484,7 +5484,7 @@ int pair[2], write_pair[2]; #endif #if !defined(HAVE_FORK) - struct rb_exec_arg sarg; + struct rb_execarg sarg; #endif FILE *fp = 0; int fd = -1; @@ -5727,7 +5727,7 @@ pipe_open_v(int argc, VALUE *argv, const char *modestr, int fmode, convconfig_t *convconfig) { VALUE execarg_obj, ret; - struct rb_exec_arg *earg; + struct rb_execarg *earg; execarg_obj = rb_execarg_new(argc, argv, FALSE); earg = rb_execarg_get(execarg_obj); ret = pipe_open(earg, modestr, fmode, convconfig); @@ -5742,7 +5742,7 @@ int argc = 1; VALUE *argv = &prog; VALUE execarg_obj, ret; - struct rb_exec_arg *earg; + struct rb_execarg *earg; if (RSTRING_LEN(prog) == 1 && cmd[0] == '-') { #if !defined(HAVE_FORK) Index: process.c =================================================================== --- process.c (revision 36152) +++ process.c (revision 36153) @@ -1273,7 +1273,7 @@ static void mark_exec_arg(void *ptr) { - struct rb_exec_arg *earg = ptr; + struct rb_execarg *earg = ptr; if (earg->use_shell) rb_gc_mark(earg->invoke.sh.shell_script); else { @@ -1298,7 +1298,7 @@ static size_t memsize_exec_arg(const void *ptr) { - return ptr ? sizeof(struct rb_exec_arg) : 0; + return ptr ? sizeof(struct rb_execarg) : 0; } static const rb_data_type_t exec_arg_data_type = { @@ -1545,7 +1545,7 @@ #endif int -rb_execarg_addopt(struct rb_exec_arg *e, VALUE key, VALUE val) +rb_execarg_addopt(struct rb_execarg *e, VALUE key, VALUE val) { VALUE options = e->options; ID id; @@ -1682,7 +1682,7 @@ int rb_exec_arg_addopt(struct rb_exec_arg *e, VALUE key, VALUE val) { - return rb_execarg_addopt(e, key, val); + return rb_execarg_addopt(rb_execarg_get(e->execarg_obj), key, val); } static int @@ -1690,7 +1690,7 @@ { VALUE key = (VALUE)st_key; VALUE val = (VALUE)st_val; - struct rb_exec_arg *e = (struct rb_exec_arg *)arg; + struct rb_execarg *e = (struct rb_execarg *)arg; return rb_execarg_addopt(e, key, val); } @@ -1766,7 +1766,7 @@ } static void -rb_check_exec_options(VALUE opthash, struct rb_exec_arg *e) +rb_check_exec_options(VALUE opthash, struct rb_execarg *e) { if (RHASH_EMPTY_P(opthash)) return; @@ -1884,12 +1884,12 @@ #endif static void -rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, struct rb_exec_arg *e) +rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, struct rb_execarg *e) { VALUE options; char fbuf[MAXPATHLEN]; - MEMZERO(e, struct rb_exec_arg, 1); + MEMZERO(e, struct rb_execarg, 1); options = hide_obj(rb_ary_new()); e->options = options; @@ -2059,22 +2059,22 @@ rb_execarg_new(int argc, VALUE *argv, int accept_shell) { VALUE execarg_obj; - struct rb_exec_arg *e; - execarg_obj = TypedData_Make_Struct(rb_cData, struct rb_exec_arg, &exec_arg_data_type, e); + struct rb_execarg *e; + execarg_obj = TypedData_Make_Struct(rb_cData, struct rb_execarg, &exec_arg_data_type, e); hide_obj(execarg_obj); rb_execarg_init(argc, argv, accept_shell, e); return execarg_obj; } -struct rb_exec_arg *rb_execarg_get(VALUE execarg_obj) +struct rb_execarg *rb_execarg_get(VALUE execarg_obj) { - struct rb_exec_arg *e; - TypedData_Get_Struct(execarg_obj, struct rb_exec_arg, &exec_arg_data_type, e); + struct rb_execarg *e; + TypedData_Get_Struct(execarg_obj, struct rb_execarg, &exec_arg_data_type, e); return e; } VALUE -rb_execarg_init(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e) +rb_execarg_init(int argc, VALUE *argv, int accept_shell, struct rb_execarg *e) { VALUE prog; VALUE env = Qnil, opthash = Qnil; @@ -2086,7 +2086,7 @@ VALUE rb_exec_arg_init(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e) { - return rb_execarg_init(argc, argv, accept_shell, e); + return rb_execarg_init(argc, argv, accept_shell, rb_execarg_get(e->execarg_obj)); } static int @@ -2108,7 +2108,7 @@ static long run_exec_dup2_tmpbuf_size(long n); void -rb_execarg_fixup(struct rb_exec_arg *e) +rb_execarg_fixup(struct rb_execarg *e) { VALUE unsetenv_others, envopts; VALUE ary; @@ -2181,17 +2181,17 @@ void rb_exec_arg_fixup(struct rb_exec_arg *e) { - rb_execarg_fixup(e); + rb_execarg_fixup(rb_execarg_get(e->execarg_obj)); } static void -rb_exec_arg_prepare(struct rb_exec_arg *earg, int argc, VALUE *argv) +rb_exec_arg_prepare(struct rb_execarg *earg, int argc, VALUE *argv) { rb_execarg_init(argc, argv, TRUE, earg); rb_execarg_fixup(earg); } -static int rb_exec_without_timer_thread(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen); +static int rb_exec_without_timer_thread(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen); /* * call-seq: @@ -2248,7 +2248,7 @@ rb_f_exec(int argc, VALUE *argv) { VALUE execarg_obj, fail_str; - struct rb_exec_arg *earg; + struct rb_execarg *earg; #define CHILD_ERRMSG_BUFLEN 80 char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' }; @@ -2712,7 +2712,7 @@ /* This function should be async-signal-safe when _s_ is NULL. Hopefully it is. */ int -rb_execarg_run_options(const struct rb_exec_arg *e, struct rb_exec_arg *s, char *errmsg, size_t errmsg_buflen) +rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, char *errmsg, size_t errmsg_buflen) { VALUE options = e->options; VALUE soptions = Qnil; @@ -2840,21 +2840,21 @@ int rb_run_exec_options_err(const struct rb_exec_arg *e, struct rb_exec_arg *s, char *errmsg, size_t errmsg_buflen) { - return rb_execarg_run_options(e, s, errmsg, errmsg_buflen); + return rb_execarg_run_options(rb_execarg_get(e->execarg_obj), rb_execarg_get(s->execarg_obj), errmsg, errmsg_buflen); } int rb_run_exec_options(const struct rb_exec_arg *e, struct rb_exec_arg *s) { - return rb_execarg_run_options(e, s, NULL, 0); + return rb_execarg_run_options(rb_execarg_get(e->execarg_obj), rb_execarg_get(s->execarg_obj), NULL, 0); } /* This function should be async-signal-safe. Hopefully it is. */ int -rb_exec_async_signal_safe(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen) +rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen) { #if !defined(HAVE_FORK) - struct rb_exec_arg sarg, *sargp = &sarg; + struct rb_execarg sarg, *sargp = &sarg; #else # define sargp NULL #endif @@ -2886,7 +2886,7 @@ } static int -rb_exec_without_timer_thread(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen) +rb_exec_without_timer_thread(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen) { int ret; before_exec_non_async_signal_safe(); /* async-signal-safe if forked_child is true */ @@ -2898,7 +2898,7 @@ int rb_exec_err(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen) { - return rb_exec_without_timer_thread(e, errmsg, errmsg_buflen); + return rb_exec_without_timer_thread(rb_execarg_get(e->execarg_obj), errmsg, errmsg_buflen); } int @@ -2906,7 +2906,7 @@ { #if !defined FD_CLOEXEC && !defined HAVE_SPAWNV char errmsg[80] = { '\0' }; - int ret = rb_exec_without_timer_thread(e, errmsg, sizeof(errmsg)); + int ret = rb_exec_without_timer_thread(rb_execarg_get(e->execarg_obj), errmsg, sizeof(errmsg)); preserving_errno( if (errmsg[0]) { fprintf(stderr, "%s\n", errmsg); @@ -2919,7 +2919,7 @@ ); return ret; #else - return rb_exec_without_timer_thread(e, NULL, 0); + return rb_exec_without_timer_thread(rb_execarg_get(e->execarg_obj), NULL, 0); #endif } @@ -3485,7 +3485,7 @@ } static rb_pid_t -rb_spawn_process(struct rb_exec_arg *earg, char *errmsg, size_t errmsg_buflen) +rb_spawn_process(struct rb_execarg *earg, char *errmsg, size_t errmsg_buflen) { rb_pid_t pid; #if !USE_SPAWNV @@ -3493,7 +3493,7 @@ #endif #if !defined HAVE_FORK || USE_SPAWNV VALUE prog; - struct rb_exec_arg sarg; + struct rb_execarg sarg; #endif #if defined HAVE_FORK && !USE_SPAWNV @@ -3540,7 +3540,7 @@ rb_spawn_internal(int argc, VALUE *argv, char *errmsg, size_t errmsg_buflen) { VALUE execarg_obj; - struct rb_exec_arg *earg; + struct rb_execarg *earg; VALUE ret; execarg_obj = rb_execarg_new(argc, argv, TRUE); @@ -3880,7 +3880,7 @@ rb_pid_t pid; char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' }; VALUE execarg_obj, fail_str; - struct rb_exec_arg *earg; + struct rb_execarg *earg; execarg_obj = rb_execarg_new(argc, argv, TRUE); earg = rb_execarg_get(execarg_obj); Index: ext/pty/pty.c =================================================================== --- ext/pty/pty.c (revision 36152) +++ ext/pty/pty.c (revision 36153) @@ -79,7 +79,7 @@ int master, slave; char *slavename; VALUE execarg_obj; - struct rb_exec_arg *earg; + struct rb_execarg *earg; }; static int Index: internal.h =================================================================== --- internal.h (revision 36152) +++ internal.h (revision 36153) @@ -159,6 +159,26 @@ /* process.c */ +struct rb_execarg { + int use_shell; + union { + struct { + VALUE shell_script; + } sh; + struct { + VALUE command_name; + VALUE command_abspath; /* full path string or nil */ + VALUE argv_str; + VALUE argv_buf; + } cmd; + } invoke; + VALUE options; + VALUE redirect_fds; + VALUE envp_str; + VALUE envp_buf; + VALUE dup2_tmpbuf; +}; + /* argv_str contains extra two elements. * The beginning one is for /bin/sh used by exec_with_sh. * The last one for terminating NULL used by execve. @@ -264,14 +284,14 @@ void rb_maygvl_fd_fix_cloexec(int fd); /* process.c */ -int rb_exec_async_signal_safe(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen); +int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen); rb_pid_t rb_fork_async_signal_safe(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds, char *errmsg, size_t errmsg_buflen); VALUE rb_execarg_new(int argc, VALUE *argv, int accept_shell); -struct rb_exec_arg *rb_execarg_get(VALUE execarg_obj); /* dangerous. needs GC guard. */ -VALUE rb_execarg_init(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e); -int rb_execarg_addopt(struct rb_exec_arg *e, VALUE key, VALUE val); -void rb_execarg_fixup(struct rb_exec_arg *e); -int rb_execarg_run_options(const struct rb_exec_arg *e, struct rb_exec_arg *s, char* errmsg, size_t errmsg_buflen); +struct rb_execarg *rb_execarg_get(VALUE execarg_obj); /* dangerous. needs GC guard. */ +VALUE rb_execarg_init(int argc, VALUE *argv, int accept_shell, struct rb_execarg *e); +int rb_execarg_addopt(struct rb_execarg *e, VALUE key, VALUE val); +void rb_execarg_fixup(struct rb_execarg *e); +int rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, char* errmsg, size_t errmsg_buflen); #if defined __GNUC__ && __GNUC__ >= 4 #pragma GCC visibility pop -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/