[前][次][番号順一覧][スレッド一覧]

ruby-changes:43017

From: nobu <ko1@a...>
Date: Sat, 21 May 2016 00:36:38 +0900 (JST)
Subject: [ruby-changes:43017] nobu:r55091 (trunk): fix build on no-fork-spawnv platforms

nobu	2016-05-21 00:36:34 +0900 (Sat, 21 May 2016)

  New Revision: 55091

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55091

  Log:
    fix build on no-fork-spawnv platforms
    
    * process.c (rb_execarg_commandline): build command line string
      from argument vector in rb_execarg.
      [ruby-core:75611] [Bug #12398]

  Modified files:
    trunk/ChangeLog
    trunk/io.c
    trunk/process.c
Index: io.c
===================================================================
--- io.c	(revision 55090)
+++ io.c	(revision 55091)
@@ -5886,6 +5886,8 @@ rb_execarg_fixup_v(VALUE execarg_obj) https://github.com/ruby/ruby/blob/trunk/io.c#L5886
     rb_execarg_parent_start(execarg_obj);
     return Qnil;
 }
+#else
+char *rb_execarg_commandline(const struct rb_execarg *eargp, VALUE *prog);
 #endif
 
 static VALUE
@@ -5933,10 +5935,6 @@ pipe_open(VALUE execarg_obj, const char https://github.com/ruby/ruby/blob/trunk/io.c#L5935
     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);
@@ -6065,10 +6063,7 @@ pipe_open(VALUE execarg_obj, const char https://github.com/ruby/ruby/blob/trunk/io.c#L6063
         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: ChangeLog
===================================================================
--- ChangeLog	(revision 55090)
+++ ChangeLog	(revision 55091)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat May 21 00:36:32 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 May 20 23:25:42 2016  Kazuki Yamaguchi  <k@r...>
 
 	* ext/openssl/ossl.c (ossl_pem_passwd_value): Added. Convert the
Index: process.c
===================================================================
--- process.c	(revision 55090)
+++ process.c	(revision 55091)
@@ -3902,6 +3902,29 @@ rb_syswait(rb_pid_t pid) https://github.com/ruby/ruby/blob/trunk/process.c#L3902
     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)
 {
@@ -3909,6 +3932,9 @@ rb_spawn_process(struct rb_execarg *earg https://github.com/ruby/ruby/blob/trunk/process.c#L3932
 #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
@@ -3935,12 +3961,7 @@ rb_spawn_process(struct rb_execarg *earg https://github.com/ruby/ruby/blob/trunk/process.c#L3961
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]