ruby-changes:23858
From: akr <ko1@a...>
Date: Mon, 4 Jun 2012 19:19:42 +0900 (JST)
Subject: [ruby-changes:23858] akr:r35909 (trunk): * internal.h (ARGVSTR2ARGC): defined.
akr 2012-06-04 19:19:32 +0900 (Mon, 04 Jun 2012) New Revision: 35909 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35909 Log: * 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. Modified files: trunk/ChangeLog trunk/internal.h trunk/io.c trunk/process.c Index: ChangeLog =================================================================== --- ChangeLog (revision 35908) +++ ChangeLog (revision 35909) @@ -1,3 +1,13 @@ +Mon Jun 4 19:17:06 2012 Tanaka Akira <akr@f...> + + * 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@a...> * vm_insnhelper.h: remove magical code "lfp[0] & 0x02". Index: io.c =================================================================== --- io.c (revision 35908) +++ io.c (revision 35909) @@ -5584,7 +5584,7 @@ } #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: Index: process.c =================================================================== --- process.c (revision 35908) +++ process.c (revision 35909) @@ -1079,7 +1079,7 @@ char **new_argv = NULL; # endif - argv = (char **)RSTRING_PTR(argv_str); + argv = ARGVSTR2ARGV(argv_str); if (!prog) prog = argv[0]; @@ -3135,7 +3135,7 @@ } 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 @@ 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 @@ # 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)); Index: internal.h =================================================================== --- internal.h (revision 35908) +++ internal.h (revision 35909) @@ -157,6 +157,13 @@ 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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/