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

ruby-changes:23877

From: akr <ko1@a...>
Date: Wed, 6 Jun 2012 00:24:43 +0900 (JST)
Subject: [ruby-changes:23877] akr:r35928 (trunk): * internal.h (rb_exec_arg_init): change return type to void.

akr	2012-06-06 00:24:32 +0900 (Wed, 06 Jun 2012)

  New Revision: 35928

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35928

  Log:
    * internal.h (rb_exec_arg_init): change return type to void.
    
    * process.c (rb_exec_arg_init): don't return a value.
      (rb_exec_arg_prepare): ditto.
      (rb_spawn_process): don't take the prog argument.  extract the 
      information from earg.
      (rb_spawn_internal): follow rb_spawn_process change.
      (rb_f_spawn): ditto.
    
    * io.c (pipe_open): don't take the prog argument.  extract the
      information from eargp.
      (pipe_open_v): follow pipe_open change.
      (pipe_open_s): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/internal.h
    trunk/io.c
    trunk/process.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35927)
+++ ChangeLog	(revision 35928)
@@ -1,3 +1,19 @@
+Wed Jun  6 00:20:37 2012  Tanaka Akira  <akr@f...>
+
+	* internal.h (rb_exec_arg_init): change return type to void.
+
+	* process.c (rb_exec_arg_init): don't return a value.
+	  (rb_exec_arg_prepare): ditto.
+	  (rb_spawn_process): don't take the prog argument.  extract the 
+	  information from earg.
+	  (rb_spawn_internal): follow rb_spawn_process change.
+	  (rb_f_spawn): ditto.
+
+	* io.c (pipe_open): don't take the prog argument.  extract the
+	  information from eargp.
+	  (pipe_open_v): follow pipe_open change.
+	  (pipe_open_s): ditto.
+
 Tue Jun  5 23:51:33 2012  Tanaka Akira  <akr@f...>
 
 	* internal.h (rb_exec_arg): use union to represent command invocation
Index: io.c
===================================================================
--- io.c	(revision 35927)
+++ io.c	(revision 35928)
@@ -5471,8 +5471,9 @@
 #endif
 
 static VALUE
-pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *modestr, int fmode, convconfig_t *convconfig)
+pipe_open(struct rb_exec_arg *eargp, const char *modestr, int fmode, convconfig_t *convconfig)
 {
+    VALUE prog = eargp ? (eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name) : Qfalse ;
     rb_pid_t pid = 0;
     rb_io_t *fptr;
     VALUE port;
@@ -5730,10 +5731,9 @@
 static VALUE
 pipe_open_v(int argc, VALUE *argv, const char *modestr, int fmode, convconfig_t *convconfig)
 {
-    VALUE prog;
     struct rb_exec_arg earg;
-    prog = rb_exec_arg_init(argc, argv, FALSE, &earg);
-    return pipe_open(&earg, prog, modestr, fmode, convconfig);
+    rb_exec_arg_init(argc, argv, FALSE, &earg);
+    return pipe_open(&earg, modestr, fmode, convconfig);
 }
 
 static VALUE
@@ -5749,11 +5749,11 @@
 	rb_raise(rb_eNotImpError,
 		 "fork() function is unimplemented on this machine");
 #endif
-        return pipe_open(0, 0, modestr, fmode, convconfig);
+        return pipe_open(NULL, modestr, fmode, convconfig);
     }
 
     rb_exec_arg_init(argc, argv, TRUE, &earg);
-    return pipe_open(&earg, prog, modestr, fmode, convconfig);
+    return pipe_open(&earg, modestr, fmode, convconfig);
 }
 
 /*
Index: process.c
===================================================================
--- process.c	(revision 35927)
+++ process.c	(revision 35928)
@@ -1846,14 +1846,13 @@
     }
 }
 
-VALUE
+void
 rb_exec_arg_init(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e)
 {
     VALUE prog;
     VALUE env = Qnil, opthash = Qnil;
     prog = rb_exec_getargs(&argc, &argv, accept_shell, &env, &opthash);
     rb_exec_fillarg(prog, argc, argv, env, opthash, e);
-    return prog;
 }
 
 static int
@@ -3113,21 +3112,21 @@
     rb_waitpid(pid, &status, 0);
 }
 
-static VALUE
+static void
 rb_exec_arg_prepare(struct rb_exec_arg *earg, int argc, VALUE *argv, int default_close_others)
 {
-    VALUE prog = rb_exec_arg_init(argc, argv, TRUE, earg);
+    rb_exec_arg_init(argc, argv, TRUE, earg);
     if (NIL_P(rb_ary_entry(earg->options, EXEC_OPTION_CLOSE_OTHERS))) {
         VALUE v = default_close_others ? Qtrue : Qfalse;
         rb_exec_arg_addopt(earg, ID2SYM(rb_intern("close_others")), v);
     }
     rb_exec_arg_fixup(earg);
-    return prog;
 }
 
 static rb_pid_t
-rb_spawn_process(struct rb_exec_arg *earg, VALUE prog, char *errmsg, size_t errmsg_buflen)
+rb_spawn_process(struct rb_exec_arg *earg, char *errmsg, size_t errmsg_buflen)
 {
+    VALUE prog;
     rb_pid_t pid;
 #if !USE_SPAWNV
     int status;
@@ -3136,6 +3135,8 @@
     struct rb_exec_arg sarg;
 #endif
 
+    prog = earg->use_shell ? earg->invoke.sh.shell_script : earg->invoke.cmd.command_name;
+
 #if defined HAVE_FORK && !USE_SPAWNV
     pid = rb_fork_err(&status, rb_exec_atfork, earg, earg->redirect_fds, errmsg, errmsg_buflen);
 #else
@@ -3179,8 +3180,8 @@
                   char *errmsg, size_t errmsg_buflen)
 {
     struct rb_exec_arg earg;
-    VALUE prog = rb_exec_arg_prepare(&earg, argc, argv, default_close_others);
-    return rb_spawn_process(&earg, prog, errmsg, errmsg_buflen);
+    rb_exec_arg_prepare(&earg, argc, argv, default_close_others);
+    return rb_spawn_process(&earg, errmsg, errmsg_buflen);
 }
 
 rb_pid_t
@@ -3513,7 +3514,8 @@
     char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' };
     struct rb_exec_arg earg;
 
-    pid = rb_spawn_process(&earg, rb_exec_arg_prepare(&earg, argc, argv, TRUE), errmsg, sizeof(errmsg));
+    rb_exec_arg_prepare(&earg, argc, argv, TRUE);
+    pid = rb_spawn_process(&earg, errmsg, sizeof(errmsg));
     if (pid == -1) {
 	const char *prog = errmsg;
 	if (!prog[0]) {
Index: internal.h
===================================================================
--- internal.h	(revision 35927)
+++ internal.h	(revision 35928)
@@ -185,7 +185,7 @@
 #define ARGVSTR2ARGC(argv_str) (RSTRING_LEN(argv_str) / sizeof(char *) - 2)
 #define ARGVSTR2ARGV(argv_str) ((char **)RSTRING_PTR(argv_str) + 1)
 
-VALUE rb_exec_arg_init(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e);
+void 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);
 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);

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

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