1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* internal.h (ARGVSTR2ARGC): defined.

(ARGVSTR2ARGV): defined.

* process.c (proc_exec_v): use ARGVSTR2ARGV.
  (rb_spawn_process): use ARGVSTR2ARGC and ARGVSTR2ARGV.

* io.c (pipe_open): use ARGVSTR2ARGV.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2012-06-04 10:19:32 +00:00
parent 06513cc1cf
commit 41819dc447
4 changed files with 23 additions and 6 deletions

View file

@ -1,3 +1,13 @@
Mon Jun 4 19:17:06 2012 Tanaka Akira <akr@fsij.org>
* internal.h (ARGVSTR2ARGC): defined.
(ARGVSTR2ARGV): defined.
* process.c (proc_exec_v): use ARGVSTR2ARGV.
(rb_spawn_process): use ARGVSTR2ARGC and ARGVSTR2ARGV.
* io.c (pipe_open): use ARGVSTR2ARGV.
Mon Jun 4 16:13:00 2012 Koichi Sasada <ko1@atdot.net>
* vm_insnhelper.h: remove magical code "lfp[0] & 0x02".

View file

@ -157,6 +157,13 @@ int rb_is_junk_name(VALUE name);
VALUE rb_proc_location(VALUE self);
st_index_t rb_hash_proc(st_index_t hash, VALUE proc);
/* process.c */
/* argv_str contains an extra element for terminating NULL used by execve..
* See rb_exec_fillarg() in process.c. */
#define ARGVSTR2ARGC(argv_str) (RSTRING_LEN(argv_str) / sizeof(char *) - 1)
#define ARGVSTR2ARGV(argv_str) ((char **)RSTRING_PTR(argv_str))
/* rational.c */
VALUE rb_lcm(VALUE x, VALUE y);
VALUE rb_rational_reciprocal(VALUE x);

2
io.c
View file

@ -5584,7 +5584,7 @@ pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *modestr, int fmode,
}
#elif defined(_WIN32)
if (eargp && eargp->argv_str) {
args = (char **)RSTRING_PTR(eargp->argv_str);
args = ARGVSTR2ARGV(eargp->argv_str);
}
switch (fmode & (FMODE_READABLE|FMODE_WRITABLE)) {
case FMODE_READABLE|FMODE_WRITABLE:

View file

@ -1079,7 +1079,7 @@ proc_exec_v(const char *prog, VALUE argv_str, VALUE envp_str)
char **new_argv = NULL;
# endif
argv = (char **)RSTRING_PTR(argv_str);
argv = ARGVSTR2ARGV(argv_str);
if (!prog)
prog = argv[0];
@ -3135,7 +3135,7 @@ rb_spawn_process(struct rb_exec_arg *earg, VALUE prog, char *errmsg, size_t errm
}
if (prog && !earg->use_shell) {
char **argv = (char **)RSTRING_PTR(earg->argv_str);
char **argv = ARGVSTR2ARGV(earg->argv_str);
argv[0] = RSTRING_PTR(prog);
}
# if defined HAVE_SPAWNV
@ -3143,7 +3143,7 @@ rb_spawn_process(struct rb_exec_arg *earg, VALUE prog, char *errmsg, size_t errm
pid = proc_spawn(RSTRING_PTR(prog));
}
else {
char **argv = (char **)RSTRING_PTR(earg->argv_str);
char **argv = ARGVSTR2ARGV(earg->argv_str);
pid = proc_spawn_n(argv, prog, earg->options);
}
# if defined(_WIN32)
@ -3152,8 +3152,8 @@ rb_spawn_process(struct rb_exec_arg *earg, VALUE prog, char *errmsg, size_t errm
# endif
# else
if (!earg->use_shell) {
char **argv = (char **)RSTRING_PTR(earg->argv_str);
int argc = RSTRING_LEN(earg->argv_str) / sizeof(char *) - 1;
char **argv = ARGVSTR2ARGV(earg->argv_str);
int argc = ARGVSTR2ARGC(earg->argv_str);
prog = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" "));
}
status = system(StringValuePtr(prog));