ruby-changes:43797
From: nagachika <ko1@a...>
Date: Fri, 12 Aug 2016 04:13:46 +0900 (JST)
Subject: [ruby-changes:43797] nagachika:r55870 (ruby_2_3): merge revision(s) 55090, 55091: [Backport #12398]
nagachika 2016-08-12 04:13:38 +0900 (Fri, 12 Aug 2016) New Revision: 55870 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55870 Log: merge revision(s) 55090,55091: [Backport #12398] io.c: conditionally used functions * io.c (pipe_atexit): only used on Windows * io.c (rb_execarg_fixup_v): wrapper only used fork or spawnv is available. * process.c (rb_execarg_commandline): build command line string from argument vector in rb_execarg. [ruby-core:75611] [Bug #12398] Modified directories: branches/ruby_2_3/ Modified files: branches/ruby_2_3/ChangeLog branches/ruby_2_3/io.c branches/ruby_2_3/process.c branches/ruby_2_3/version.h Index: ruby_2_3/ChangeLog =================================================================== --- ruby_2_3/ChangeLog (revision 55869) +++ ruby_2_3/ChangeLog (revision 55870) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1 +Fri Aug 12 04:04:23 2016 Nobuyoshi Nakada <nobu@r...> + + * process.c (rb_execarg_commandline): build command line string + from argument vector in rb_execarg. + [ruby-core:75611] [Bug #12398] + Fri Aug 12 03:50:38 2016 Nobuyoshi Nakada <nobu@r...> * vm_method.c (vm_respond_to): try method_missing if respond_to? Index: ruby_2_3/io.c =================================================================== --- ruby_2_3/io.c (revision 55869) +++ ruby_2_3/io.c (revision 55870) @@ -5671,6 +5671,7 @@ pipe_del_fptr(rb_io_t *fptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/io.c#L5671 } } +#if defined (_WIN32) || defined(__CYGWIN__) static void pipe_atexit(void) { @@ -5683,6 +5684,7 @@ pipe_atexit(void) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/io.c#L5684 list = tmp; } } +#endif static void pipe_finalize(rb_io_t *fptr, int noraise) @@ -5868,12 +5870,16 @@ popen_exec(void *pp, char *errmsg, size_ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/io.c#L5870 } #endif +#if defined(HAVE_WORKING_FORK) || defined(HAVE_SPAWNV) static VALUE rb_execarg_fixup_v(VALUE execarg_obj) { rb_execarg_parent_start(execarg_obj); return Qnil; } +#else +char *rb_execarg_commandline(const struct rb_execarg *eargp, VALUE *prog); +#endif static VALUE pipe_open(VALUE execarg_obj, const char *modestr, int fmode, convconfig_t *convconfig) @@ -5919,10 +5925,6 @@ pipe_open(VALUE execarg_obj, const char https://github.com/ruby/ruby/blob/trunk/ruby_2_3/io.c#L5925 int write_fd = -1; #if !defined(HAVE_WORKING_FORK) const char *cmd = 0; -#if !defined(HAVE_SPAWNV) - int argc; - VALUE *argv; -#endif if (prog) cmd = StringValueCStr(prog); @@ -6051,10 +6053,7 @@ pipe_open(VALUE execarg_obj, const char https://github.com/ruby/ruby/blob/trunk/ruby_2_3/io.c#L6053 fd = arg.pair[1]; } #else - if (argc) { - prog = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" ")); - cmd = StringValueCStr(prog); - } + cmd = rb_execarg_commandline(eargp, &prog); if (!NIL_P(execarg_obj)) { rb_execarg_parent_start(execarg_obj); rb_execarg_run_options(eargp, sargp, NULL, 0); Index: ruby_2_3/process.c =================================================================== --- ruby_2_3/process.c (revision 55869) +++ ruby_2_3/process.c (revision 55870) @@ -3901,6 +3901,29 @@ rb_syswait(rb_pid_t pid) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/process.c#L3901 rb_waitpid(pid, &status, 0); } +#if !defined HAVE_WORKING_FORK && !defined HAVE_SPAWNV +char * +rb_execarg_commandline(const struct rb_execarg *eargp, VALUE *prog) +{ + VALUE cmd = *prog; + if (eargp && !eargp->use_shell) { + VALUE str = eargp->invoke.cmd.argv_str; + VALUE buf = eargp->invoke.cmd.argv_buf; + char *p, **argv = ARGVSTR2ARGV(str); + long i, argc = ARGVSTR2ARGC(str); + const char *start = RSTRING_PTR(buf); + cmd = rb_str_new(start, RSTRING_LEN(buf)); + p = RSTRING_PTR(cmd); + for (i = 1; i < argc; ++i) { + p[argv[i] - start - 1] = ' '; + } + *prog = cmd; + return p; + } + return StringValueCStr(*prog); +} +#endif + static rb_pid_t rb_spawn_process(struct rb_execarg *eargp, char *errmsg, size_t errmsg_buflen) { @@ -3908,6 +3931,9 @@ rb_spawn_process(struct rb_execarg *earg https://github.com/ruby/ruby/blob/trunk/ruby_2_3/process.c#L3931 #if !defined HAVE_WORKING_FORK || USE_SPAWNV VALUE prog; struct rb_execarg sarg; +# if !defined HAVE_SPAWNV + int status; +# endif #endif #if defined HAVE_WORKING_FORK && !USE_SPAWNV @@ -3934,12 +3960,7 @@ rb_spawn_process(struct rb_execarg *earg https://github.com/ruby/ruby/blob/trunk/ruby_2_3/process.c#L3960 if (pid == -1) rb_last_status_set(0x7f << 8, 0); # else - if (!eargp->use_shell) { - char **argv = ARGVSTR2ARGV(eargp->invoke.cmd.argv_str); - int argc = ARGVSTR2ARGC(eargp->invoke.cmd.argv_str); - prog = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" ")); - } - status = system(StringValuePtr(prog)); + status = system(rb_execarg_commandline(eargp, &prog)); rb_last_status_set((status & 0xff) << 8, 0); pid = 1; /* dummy */ # endif Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 55869) +++ ruby_2_3/version.h (revision 55870) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.2" #define RUBY_RELEASE_DATE "2016-08-12" -#define RUBY_PATCHLEVEL 150 +#define RUBY_PATCHLEVEL 151 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 8 Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r55090-55091 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/