* include/ruby/intern.h (rb_exec_arg_init): deprecated.

(rb_exec_arg_addopt): ditto.
  (rb_exec_arg_fixup): ditto.
  (rb_run_exec_options): ditto.
  (rb_run_exec_options_err): ditto.

* internal.h (rb_execarg_init): declared.
  (rb_execarg_addopt): ditto.
  (rb_execarg_fixup): ditto.
  (rb_execarg_run_options): ditto.

* process.c: call rb_execarg_addopt, rb_execarg_fixup,
  rb_execarg_run_options, rb_execarg_init.
  (rb_execarg_addopt): renamed from rb_exec_arg_addopt.
  (rb_exec_arg_addopt): stub to call rb_execarg_addopt.
  (rb_execarg_init): renamed from rb_exec_arg_init.
  (rb_exec_arg_init): stub to call rb_execarg_init.
  (rb_execarg_fixup): renamed from rb_exec_arg_fixup.
  (rb_exec_arg_fixup): stub to call rb_execarg_fixup.
  (rb_execarg_run_options): renamed from rb_run_exec_options_err.
  (rb_run_exec_options_err): stub to call rb_execarg_run_options.
  (rb_run_exec_options): call rb_execarg_run_options.

* io.c: call rb_execarg_addopt, rb_execarg_fixup,
  rb_execarg_run_options, rb_execarg_init.

* ext/pty/pty.c (establishShell): call rb_execarg_init and
  rb_execarg_fixup.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2012-06-12 11:34:51 +00:00
Родитель 0284e64922
Коммит 37a1355bf8
6 изменённых файлов: 93 добавлений и 34 удалений

Просмотреть файл

@ -1,3 +1,34 @@
Tue Jun 12 20:29:19 2012 Tanaka Akira <akr@fsij.org>
* include/ruby/intern.h (rb_exec_arg_init): deprecated.
(rb_exec_arg_addopt): ditto.
(rb_exec_arg_fixup): ditto.
(rb_run_exec_options): ditto.
(rb_run_exec_options_err): ditto.
* internal.h (rb_execarg_init): declared.
(rb_execarg_addopt): ditto.
(rb_execarg_fixup): ditto.
(rb_execarg_run_options): ditto.
* process.c: call rb_execarg_addopt, rb_execarg_fixup,
rb_execarg_run_options, rb_execarg_init.
(rb_execarg_addopt): renamed from rb_exec_arg_addopt.
(rb_exec_arg_addopt): stub to call rb_execarg_addopt.
(rb_execarg_init): renamed from rb_exec_arg_init.
(rb_exec_arg_init): stub to call rb_execarg_init.
(rb_execarg_fixup): renamed from rb_exec_arg_fixup.
(rb_exec_arg_fixup): stub to call rb_execarg_fixup.
(rb_execarg_run_options): renamed from rb_run_exec_options_err.
(rb_run_exec_options_err): stub to call rb_execarg_run_options.
(rb_run_exec_options): call rb_execarg_run_options.
* io.c: call rb_execarg_addopt, rb_execarg_fixup,
rb_execarg_run_options, rb_execarg_init.
* ext/pty/pty.c (establishShell): call rb_execarg_init and
rb_execarg_fixup.
Tue Jun 12 18:39:59 2012 URABE Shyouhei <shyouhei@ruby-lang.org> Tue Jun 12 18:39:59 2012 URABE Shyouhei <shyouhei@ruby-lang.org>
* configure.in: enable strict ANSI mode by default in case of GCC, * configure.in: enable strict ANSI mode by default in case of GCC,

Просмотреть файл

@ -176,8 +176,8 @@ establishShell(int argc, VALUE *argv, struct pty_info *info,
argv = &v; argv = &v;
} }
rb_exec_arg_init(argc, argv, 1, &carg.earg); rb_execarg_init(argc, argv, 1, &carg.earg);
rb_exec_arg_fixup(&carg.earg); rb_execarg_fixup(&carg.earg);
getDevice(&master, &slave, SlaveName, 0); getDevice(&master, &slave, SlaveName, 0);

Просмотреть файл

@ -609,11 +609,11 @@ struct rb_exec_arg {
}; };
DEPRECATED(int rb_proc_exec_n(int, VALUE*, const char*)); DEPRECATED(int rb_proc_exec_n(int, VALUE*, const char*));
int rb_proc_exec(const char*); int rb_proc_exec(const char*);
VALUE rb_exec_arg_init(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e); DEPRECATED(VALUE 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); DEPRECATED(int rb_exec_arg_addopt(struct rb_exec_arg *e, VALUE key, VALUE val));
void rb_exec_arg_fixup(struct rb_exec_arg *e); DEPRECATED(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); DEPRECATED(int rb_run_exec_options(const struct rb_exec_arg *e, struct rb_exec_arg *s));
int rb_run_exec_options_err(const struct rb_exec_arg *e, struct rb_exec_arg *s, char*, size_t); DEPRECATED(int rb_run_exec_options_err(const struct rb_exec_arg *e, struct rb_exec_arg *s, char*, size_t));
DEPRECATED(int rb_exec(const struct rb_exec_arg*)); DEPRECATED(int rb_exec(const struct rb_exec_arg*));
DEPRECATED(int rb_exec_err(const struct rb_exec_arg*, char*, size_t)); DEPRECATED(int rb_exec_err(const struct rb_exec_arg*, char*, size_t));
DEPRECATED(rb_pid_t rb_fork(int*, int (*)(void*), void*, VALUE)); DEPRECATED(rb_pid_t rb_fork(int*, int (*)(void*), void*, VALUE));

Просмотреть файл

@ -266,6 +266,10 @@ void rb_maygvl_fd_fix_cloexec(int fd);
/* process.c */ /* 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_exec_arg *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); 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_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);
#if defined __GNUC__ && __GNUC__ >= 4 #if defined __GNUC__ && __GNUC__ >= 4
#pragma GCC visibility pop #pragma GCC visibility pop

36
io.c
Просмотреть файл

@ -5517,27 +5517,27 @@ pipe_open(struct rb_exec_arg *eargp, const char *modestr, int fmode, convconfig_
rb_sys_fail_str(prog); rb_sys_fail_str(prog);
} }
if (eargp) { if (eargp) {
rb_exec_arg_addopt(eargp, INT2FIX(0), INT2FIX(arg.write_pair[0])); rb_execarg_addopt(eargp, INT2FIX(0), INT2FIX(arg.write_pair[0]));
rb_exec_arg_addopt(eargp, INT2FIX(1), INT2FIX(arg.pair[1])); rb_execarg_addopt(eargp, INT2FIX(1), INT2FIX(arg.pair[1]));
} }
break; break;
case FMODE_READABLE: case FMODE_READABLE:
if (rb_pipe(arg.pair) < 0) if (rb_pipe(arg.pair) < 0)
rb_sys_fail_str(prog); rb_sys_fail_str(prog);
if (eargp) if (eargp)
rb_exec_arg_addopt(eargp, INT2FIX(1), INT2FIX(arg.pair[1])); rb_execarg_addopt(eargp, INT2FIX(1), INT2FIX(arg.pair[1]));
break; break;
case FMODE_WRITABLE: case FMODE_WRITABLE:
if (rb_pipe(arg.pair) < 0) if (rb_pipe(arg.pair) < 0)
rb_sys_fail_str(prog); rb_sys_fail_str(prog);
if (eargp) if (eargp)
rb_exec_arg_addopt(eargp, INT2FIX(0), INT2FIX(arg.pair[0])); rb_execarg_addopt(eargp, INT2FIX(0), INT2FIX(arg.pair[0]));
break; break;
default: default:
rb_sys_fail_str(prog); rb_sys_fail_str(prog);
} }
if (eargp) { if (eargp) {
rb_exec_arg_fixup(arg.execp); rb_execarg_fixup(arg.execp);
pid = rb_fork_async_signal_safe(&status, popen_exec, &arg, arg.execp->redirect_fds, errmsg, sizeof(errmsg)); pid = rb_fork_async_signal_safe(&status, popen_exec, &arg, arg.execp->redirect_fds, errmsg, sizeof(errmsg));
} }
else { else {
@ -5595,28 +5595,28 @@ pipe_open(struct rb_exec_arg *eargp, const char *modestr, int fmode, convconfig_
rb_sys_fail_str(prog); rb_sys_fail_str(prog);
} }
if (eargp) { if (eargp) {
rb_exec_arg_addopt(eargp, INT2FIX(0), INT2FIX(write_pair[0])); rb_execarg_addopt(eargp, INT2FIX(0), INT2FIX(write_pair[0]));
rb_exec_arg_addopt(eargp, INT2FIX(1), INT2FIX(pair[1])); rb_execarg_addopt(eargp, INT2FIX(1), INT2FIX(pair[1]));
} }
break; break;
case FMODE_READABLE: case FMODE_READABLE:
if (rb_pipe(pair) < 0) if (rb_pipe(pair) < 0)
rb_sys_fail_str(prog); rb_sys_fail_str(prog);
if (eargp) if (eargp)
rb_exec_arg_addopt(eargp, INT2FIX(1), INT2FIX(pair[1])); rb_execarg_addopt(eargp, INT2FIX(1), INT2FIX(pair[1]));
break; break;
case FMODE_WRITABLE: case FMODE_WRITABLE:
if (rb_pipe(pair) < 0) if (rb_pipe(pair) < 0)
rb_sys_fail_str(prog); rb_sys_fail_str(prog);
if (eargp) if (eargp)
rb_exec_arg_addopt(eargp, INT2FIX(0), INT2FIX(pair[0])); rb_execarg_addopt(eargp, INT2FIX(0), INT2FIX(pair[0]));
break; break;
default: default:
rb_sys_fail_str(prog); rb_sys_fail_str(prog);
} }
if (eargp) { if (eargp) {
rb_exec_arg_fixup(eargp); rb_execarg_fixup(eargp);
rb_run_exec_options(eargp, &sarg); rb_execarg_run_options(eargp, &sarg, NULL, 0);
} }
while ((pid = (args ? while ((pid = (args ?
rb_w32_aspawn(P_NOWAIT, cmd, args) : rb_w32_aspawn(P_NOWAIT, cmd, args) :
@ -5633,7 +5633,7 @@ pipe_open(struct rb_exec_arg *eargp, const char *modestr, int fmode, convconfig_
{ {
int e = errno; int e = errno;
if (eargp) if (eargp)
rb_run_exec_options(&sarg, NULL); rb_execarg_run_options(&sarg, NULL, NULL, 0);
close(pair[0]); close(pair[0]);
close(pair[1]); close(pair[1]);
if ((fmode & (FMODE_READABLE|FMODE_WRITABLE)) == (FMODE_READABLE|FMODE_WRITABLE)) { if ((fmode & (FMODE_READABLE|FMODE_WRITABLE)) == (FMODE_READABLE|FMODE_WRITABLE)) {
@ -5650,7 +5650,7 @@ pipe_open(struct rb_exec_arg *eargp, const char *modestr, int fmode, convconfig_
RB_GC_GUARD(argbuf); RB_GC_GUARD(argbuf);
if (eargp) if (eargp)
rb_run_exec_options(&sarg, NULL); rb_execarg_run_options(&sarg, NULL, NULL, 0);
if ((fmode & FMODE_READABLE) && (fmode & FMODE_WRITABLE)) { if ((fmode & FMODE_READABLE) && (fmode & FMODE_WRITABLE)) {
close(pair[1]); close(pair[1]);
fd = pair[0]; fd = pair[0];
@ -5671,12 +5671,12 @@ pipe_open(struct rb_exec_arg *eargp, const char *modestr, int fmode, convconfig_
cmd = StringValueCStr(prog); cmd = StringValueCStr(prog);
} }
if (eargp) { if (eargp) {
rb_exec_arg_fixup(eargp); rb_execarg_fixup(eargp);
rb_run_exec_options(eargp, &sarg); rb_execarg_run_options(eargp, &sarg, NULL, 0);
} }
fp = popen(cmd, modestr); fp = popen(cmd, modestr);
if (eargp) if (eargp)
rb_run_exec_options(&sarg, NULL); rb_execarg_run_options(&sarg, NULL, NULL, 0);
if (!fp) rb_sys_fail_path(prog); if (!fp) rb_sys_fail_path(prog);
fd = fileno(fp); fd = fileno(fp);
#endif #endif
@ -5727,7 +5727,7 @@ static VALUE
pipe_open_v(int argc, VALUE *argv, const char *modestr, int fmode, convconfig_t *convconfig) pipe_open_v(int argc, VALUE *argv, const char *modestr, int fmode, convconfig_t *convconfig)
{ {
struct rb_exec_arg earg; struct rb_exec_arg earg;
rb_exec_arg_init(argc, argv, FALSE, &earg); rb_execarg_init(argc, argv, FALSE, &earg);
return pipe_open(&earg, modestr, fmode, convconfig); return pipe_open(&earg, modestr, fmode, convconfig);
} }
@ -5747,7 +5747,7 @@ pipe_open_s(VALUE prog, const char *modestr, int fmode, convconfig_t *convconfig
return pipe_open(NULL, modestr, fmode, convconfig); return pipe_open(NULL, modestr, fmode, convconfig);
} }
rb_exec_arg_init(argc, argv, TRUE, &earg); rb_execarg_init(argc, argv, TRUE, &earg);
return pipe_open(&earg, modestr, fmode, convconfig); return pipe_open(&earg, modestr, fmode, convconfig);
} }

Просмотреть файл

@ -1503,7 +1503,7 @@ static int rlimit_type_by_lname(const char *name);
#endif #endif
int int
rb_exec_arg_addopt(struct rb_exec_arg *e, VALUE key, VALUE val) rb_execarg_addopt(struct rb_exec_arg *e, VALUE key, VALUE val)
{ {
VALUE options = e->options; VALUE options = e->options;
ID id; ID id;
@ -1636,13 +1636,19 @@ redirect:
return ST_CONTINUE; return ST_CONTINUE;
} }
int
rb_exec_arg_addopt(struct rb_exec_arg *e, VALUE key, VALUE val)
{
return rb_execarg_addopt(e, key, val);
}
static int static int
check_exec_options_i(st_data_t st_key, st_data_t st_val, st_data_t arg) check_exec_options_i(st_data_t st_key, st_data_t st_val, st_data_t arg)
{ {
VALUE key = (VALUE)st_key; VALUE key = (VALUE)st_key;
VALUE val = (VALUE)st_val; VALUE val = (VALUE)st_val;
struct rb_exec_arg *e = (struct rb_exec_arg *)arg; struct rb_exec_arg *e = (struct rb_exec_arg *)arg;
return rb_exec_arg_addopt(e, key, val); return rb_execarg_addopt(e, key, val);
} }
static VALUE static VALUE
@ -1942,7 +1948,7 @@ rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, str
} }
VALUE VALUE
rb_exec_arg_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_exec_arg *e)
{ {
VALUE prog; VALUE prog;
VALUE env = Qnil, opthash = Qnil; VALUE env = Qnil, opthash = Qnil;
@ -1951,6 +1957,12 @@ rb_exec_arg_init(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e)
return e->use_shell ? e->invoke.sh.shell_script : e->invoke.cmd.command_name; return e->use_shell ? e->invoke.sh.shell_script : e->invoke.cmd.command_name;
} }
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);
}
static int static int
fill_envp_buf_i(st_data_t st_key, st_data_t st_val, st_data_t arg) fill_envp_buf_i(st_data_t st_key, st_data_t st_val, st_data_t arg)
{ {
@ -1970,7 +1982,7 @@ fill_envp_buf_i(st_data_t st_key, st_data_t st_val, st_data_t arg)
static long run_exec_dup2_tmpbuf_size(long n); static long run_exec_dup2_tmpbuf_size(long n);
void void
rb_exec_arg_fixup(struct rb_exec_arg *e) rb_execarg_fixup(struct rb_exec_arg *e)
{ {
VALUE unsetenv_others, envopts; VALUE unsetenv_others, envopts;
VALUE ary; VALUE ary;
@ -2040,11 +2052,17 @@ rb_exec_arg_fixup(struct rb_exec_arg *e)
} }
} }
void
rb_exec_arg_fixup(struct rb_exec_arg *e)
{
return rb_execarg_fixup(e);
}
static void static void
rb_exec_arg_prepare(struct rb_exec_arg *earg, int argc, VALUE *argv) rb_exec_arg_prepare(struct rb_exec_arg *earg, int argc, VALUE *argv)
{ {
rb_exec_arg_init(argc, argv, TRUE, earg); rb_execarg_init(argc, argv, TRUE, earg);
rb_exec_arg_fixup(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_exec_arg *e, char *errmsg, size_t errmsg_buflen);
@ -2556,7 +2574,7 @@ save_env(VALUE save)
/* This function should be async-signal-safe when _s_ is not NULL. Hopefully it is. */ /* This function should be async-signal-safe when _s_ is not NULL. Hopefully it is. */
int int
rb_run_exec_options_err(const struct rb_exec_arg *e, struct rb_exec_arg *s, char *errmsg, size_t errmsg_buflen) rb_execarg_run_options(const struct rb_exec_arg *e, struct rb_exec_arg *s, char *errmsg, size_t errmsg_buflen)
{ {
VALUE options = e->options; VALUE options = e->options;
VALUE soptions = Qnil; VALUE soptions = Qnil;
@ -2681,10 +2699,16 @@ rb_run_exec_options_err(const struct rb_exec_arg *e, struct rb_exec_arg *s, char
return 0; return 0;
} }
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);
}
int int
rb_run_exec_options(const struct rb_exec_arg *e, struct rb_exec_arg *s) rb_run_exec_options(const struct rb_exec_arg *e, struct rb_exec_arg *s)
{ {
return rb_run_exec_options_err(e, s, NULL, 0); return rb_execarg_run_options(e, s, NULL, 0);
} }
/* This function should be async-signal-safe. Hopefully it is. */ /* This function should be async-signal-safe. Hopefully it is. */
@ -2699,7 +2723,7 @@ rb_exec_async_signal_safe(const struct rb_exec_arg *e, char *errmsg, size_t errm
before_exec_async_signal_safe(); /* async-signal-safe */ before_exec_async_signal_safe(); /* async-signal-safe */
if (rb_run_exec_options_err(e, sargp, errmsg, errmsg_buflen) < 0) { /* hopefully async-signal-safe */ if (rb_execarg_run_options(e, sargp, errmsg, errmsg_buflen) < 0) { /* hopefully async-signal-safe */
goto failure; goto failure;
} }