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

ruby-changes:10524

From: akr <ko1@a...>
Date: Thu, 5 Feb 2009 20:35:32 +0900 (JST)
Subject: [ruby-changes:10524] Ruby:r22078 (trunk): * include/ruby/intern.h (rb_run_exec_options_err): renamed from

akr	2009-02-05 20:33:19 +0900 (Thu, 05 Feb 2009)

  New Revision: 22078

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

  Log:
    * include/ruby/intern.h (rb_run_exec_options_err): renamed from
      rb_run_exec_options.
      (rb_exec_err): renamed from rb_exec.
      (rb_fork_err): renamed from rb_fork.
      (rb_spawn_err): renamed from rb_spawn.
      (rb_run_exec_options): declared with 1.9.1 compatible signature.
      (rb_exec): ditto.
      (rb_fork): ditto.
      (rb_spawn): ditto.
    * process.c (rb_run_exec_options_err): renamed from
      rb_run_exec_options.
      (rb_exec_err): renamed from rb_exec.
      (rb_fork_err): renamed from rb_fork.
      (rb_spawn_err): renamed from rb_spawn.
      (rb_run_exec_options): defined.
      (rb_exec): ditto.
      (rb_fork): ditto.
      (rb_spawn): ditto.
    
    * io.c: follow above change.
    
    * ext/pty/pty.c: follow above change.
    
      [ruby-dev:37893]

  Modified files:
    trunk/ChangeLog
    trunk/ext/pty/pty.c
    trunk/include/ruby/intern.h
    trunk/io.c
    trunk/process.c

Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 22077)
+++ include/ruby/intern.h	(revision 22078)
@@ -491,13 +491,17 @@
 VALUE 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, char*, size_t);
-int rb_exec(const struct rb_exec_arg*, char*, size_t);
-rb_pid_t rb_fork(int*, int (*)(void*, char*, size_t), void*, VALUE, char*, size_t);
+int rb_run_exec_options(const struct rb_exec_arg *e, struct rb_exec_arg *s);
+int rb_run_exec_options_err(const struct rb_exec_arg *e, struct rb_exec_arg *s, char*, size_t);
+int rb_exec(const struct rb_exec_arg*);
+int rb_exec_err(const struct rb_exec_arg*, char*, size_t);
+rb_pid_t rb_fork(int*, int (*)(void*), void*, VALUE);
+rb_pid_t rb_fork_err(int*, int (*)(void*, char*, size_t), void*, VALUE, char*, size_t);
 VALUE rb_f_exec(int,VALUE*);
 rb_pid_t rb_waitpid(rb_pid_t pid, int *status, int flags);
 void rb_syswait(rb_pid_t pid);
-rb_pid_t rb_spawn(int, VALUE*, char*, size_t);
+rb_pid_t rb_spawn(int, VALUE*);
+rb_pid_t rb_spawn_err(int, VALUE*, char*, size_t);
 VALUE rb_proc_times(VALUE);
 VALUE rb_detach_process(rb_pid_t pid);
 /* range.c */
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 22077)
+++ ChangeLog	(revision 22078)
@@ -1,3 +1,31 @@
+Thu Feb  5 20:28:27 2009  Tanaka Akira  <akr@f...>
+
+	* include/ruby/intern.h (rb_run_exec_options_err): renamed from
+	  rb_run_exec_options.
+	  (rb_exec_err): renamed from rb_exec.
+	  (rb_fork_err): renamed from rb_fork.
+	  (rb_spawn_err): renamed from rb_spawn.
+	  (rb_run_exec_options): declared with 1.9.1 compatible signature.
+	  (rb_exec): ditto.
+	  (rb_fork): ditto.
+	  (rb_spawn): ditto.
+
+	* process.c (rb_run_exec_options_err): renamed from
+	  rb_run_exec_options.
+	  (rb_exec_err): renamed from rb_exec.
+	  (rb_fork_err): renamed from rb_fork.
+	  (rb_spawn_err): renamed from rb_spawn.
+	  (rb_run_exec_options): defined.
+	  (rb_exec): ditto.
+	  (rb_fork): ditto.
+	  (rb_spawn): ditto.
+
+	* io.c: follow above change.
+
+	* ext/pty/pty.c: follow above change.
+
+	  [ruby-dev:37893]
+
 Thu Feb  5 19:58:40 2009  Tanaka Akira  <akr@f...>
 
 	* ext/socket: AddrInfo is renamed to Addrinfo.  [ruby-dev:37876]
Index: io.c
===================================================================
--- io.c	(revision 22077)
+++ io.c	(revision 22078)
@@ -4489,7 +4489,7 @@
     struct popen_arg *p = (struct popen_arg*)pp;
 
     rb_thread_atfork_before_exec();
-    return rb_exec(p->execp, errmsg, errmsg_len);
+    return rb_exec_err(p->execp, errmsg, errmsg_len);
 }
 #endif
 
@@ -4575,11 +4575,11 @@
     }
     if (eargp) {
         rb_exec_arg_fixup(arg.execp);
-	pid = rb_fork(&status, popen_exec, &arg, arg.execp->redirect_fds, errmsg, sizeof(errmsg));
+	pid = rb_fork_err(&status, popen_exec, &arg, arg.execp->redirect_fds, errmsg, sizeof(errmsg));
     }
     else {
 	fflush(stdin);		/* is it really needed? */
-	pid = rb_fork(&status, 0, 0, Qnil, NULL, 0);
+	pid = rb_fork(&status, 0, 0, Qnil);
 	if (pid == 0) {		/* child */
 	    popen_redirect(&arg);
 	    rb_io_synchronized(RFILE(orig_stdout)->fptr);
@@ -4663,7 +4663,7 @@
     }
     if (eargp) {
 	rb_exec_arg_fixup(eargp);
-	rb_run_exec_options(eargp, &sarg, NULL, 0);
+	rb_run_exec_options(eargp, &sarg);
     }
     while ((pid = (args ?
 		   rb_w32_aspawn(P_NOWAIT, 0, args) :
@@ -4678,13 +4678,13 @@
 	    break;
 	  default:
 	    if (eargp)
-		rb_run_exec_options(&sarg, NULL, NULL, 0);
+		rb_run_exec_options(&sarg, NULL);
 	    rb_sys_fail(cmd);
 	    break;
 	}
     }
     if (eargp)
-	rb_run_exec_options(&sarg, NULL, NULL, 0);
+	rb_run_exec_options(&sarg, NULL);
     if ((fmode & FMODE_READABLE) && (fmode & FMODE_WRITABLE)) {
         close(pair[1]);
         fd = pair[0];
@@ -4706,11 +4706,11 @@
     }
     if (eargp) {
 	rb_exec_arg_fixup(eargp);
-	rb_run_exec_options(eargp, &sarg, NULL, 0);
+	rb_run_exec_options(eargp, &sarg);
     }
     fp = popen(cmd, modestr);
     if (eargp)
-	rb_run_exec_options(&sarg, NULL, NULL, 0);
+	rb_run_exec_options(&sarg, NULL);
     if (!fp) rb_sys_fail(RSTRING_PTR(prog));
     fd = fileno(fp);
 #endif
Index: process.c
===================================================================
--- process.c	(revision 22077)
+++ process.c	(revision 22078)
@@ -1764,7 +1764,7 @@
         rb_exec_arg_addopt(&earg, ID2SYM(rb_intern("close_others")), Qfalse);
     rb_exec_arg_fixup(&earg);
 
-    rb_exec(&earg, errmsg, sizeof(errmsg));
+    rb_exec_err(&earg, errmsg, sizeof(errmsg));
     if (errmsg[0])
         rb_sys_fail(errmsg);
     rb_sys_fail(earg.prog);
@@ -2189,7 +2189,7 @@
 #endif
 
 int
-rb_run_exec_options(const struct rb_exec_arg *e, struct rb_exec_arg *s, char *errmsg, size_t errmsg_buflen)
+rb_run_exec_options_err(const struct rb_exec_arg *e, struct rb_exec_arg *s, char *errmsg, size_t errmsg_buflen)
 {
     VALUE options = e->options;
     VALUE soptions = Qnil;
@@ -2304,13 +2304,19 @@
 }
 
 int
-rb_exec(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen)
+rb_run_exec_options(const struct rb_exec_arg *e, struct rb_exec_arg *s)
 {
+    return rb_run_exec_options_err(e, s, NULL, 0);
+}
+
+int
+rb_exec_err(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen)
+{
     int argc = e->argc;
     VALUE *argv = e->argv;
     const char *prog = e->prog;
 
-    if (rb_run_exec_options(e, NULL, errmsg, errmsg_buflen) < 0) {
+    if (rb_run_exec_options_err(e, NULL, errmsg, errmsg_buflen) < 0) {
         return -1;
     }
 
@@ -2329,12 +2335,18 @@
     return -1;
 }
 
+int
+rb_exec(const struct rb_exec_arg *e)
+{
+    return rb_exec_err(e, NULL, 0);
+}
+
 #ifdef HAVE_FORK
 static int
 rb_exec_atfork(void* arg, char *errmsg, size_t errmsg_buflen)
 {
     rb_thread_atfork_before_exec();
-    return rb_exec(arg, errmsg, errmsg_buflen);
+    return rb_exec_err(arg, errmsg, errmsg_buflen);
 }
 #endif
 
@@ -2417,7 +2429,7 @@
  * +chfunc+ must not raise any exceptions.
  */
 rb_pid_t
-rb_fork(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds,
+rb_fork_err(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds,
         char *errmsg, size_t errmsg_buflen)
 {
     rb_pid_t pid;
@@ -2519,6 +2531,32 @@
 #endif
     return pid;
 }
+
+struct chfunc_wrapper_t {
+    int (*chfunc)(void*);
+    void *arg;
+};
+
+static int
+chfunc_wrapper(void *arg_, char *errmsg, size_t errmsg_buflen)
+{
+    struct chfunc_wrapper_t *arg = arg_;
+    return arg->chfunc(arg->arg);
+}
+
+rb_pid_t
+rb_fork(int *status, int (*chfunc)(void*), void *charg, VALUE fds)
+{
+    if (chfunc) {
+        struct chfunc_wrapper_t warg = { chfunc, charg };
+        return rb_fork_err(status, chfunc_wrapper, &warg, fds, NULL, 0);
+    }
+    else {
+        return rb_fork_err(status, NULL, NULL, fds, NULL, 0);
+    }
+
+}
+
 #endif
 
 /*
@@ -2550,7 +2588,7 @@
 
     rb_secure(2);
 
-    switch (pid = rb_fork(0, 0, 0, Qnil, NULL, 0)) {
+    switch (pid = rb_fork(0, 0, 0, Qnil)) {
       case 0:
 #ifdef linux
 	after_exec();
@@ -2802,10 +2840,10 @@
     rb_exec_arg_fixup(&earg);
 
 #if defined HAVE_FORK
-    status = rb_fork(&status, rb_exec_atfork, &earg, earg.redirect_fds, errmsg, errmsg_buflen);
+    status = rb_fork_err(&status, rb_exec_atfork, &earg, earg.redirect_fds, errmsg, errmsg_buflen);
     if (prog && earg.argc) earg.argv[0] = prog;
 #else
-    if (rb_run_exec_options(&earg, &sarg, errmsg, errmsg_buflen) < 0) {
+    if (rb_run_exec_options_err(&earg, &sarg, errmsg, errmsg_buflen) < 0) {
         return -1;
     }
 
@@ -2829,17 +2867,23 @@
     rb_last_status_set((status & 0xff) << 8, 0);
 # endif
 
-    rb_run_exec_options(&sarg, NULL, errmsg, errmsg_buflen);
+    rb_run_exec_options_err(&sarg, NULL, errmsg, errmsg_buflen);
 #endif
     return status;
 }
 
 rb_pid_t
-rb_spawn(int argc, VALUE *argv, char *errmsg, size_t errmsg_buflen)
+rb_spawn_err(int argc, VALUE *argv, char *errmsg, size_t errmsg_buflen)
 {
     return rb_spawn_internal(argc, argv, Qtrue, errmsg, errmsg_buflen);
 }
 
+rb_pid_t
+rb_spawn(int argc, VALUE *argv)
+{
+    return rb_spawn_internal(argc, argv, Qtrue, NULL, 0);
+}
+
 /*
  *  call-seq:
  *     system([env,] command... [,options])    => true, false or nil
@@ -3130,7 +3174,7 @@
     rb_pid_t pid;
     char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' };
 
-    pid = rb_spawn(argc, argv, errmsg, sizeof(errmsg));
+    pid = rb_spawn_err(argc, argv, errmsg, sizeof(errmsg));
     if (pid == -1) {
         if (errmsg[0] == '\0')
             rb_sys_fail(RSTRING_PTR(argv[0]));
@@ -4471,7 +4515,7 @@
     if (n < 0) rb_sys_fail("daemon");
     return INT2FIX(n);
 #elif defined(HAVE_FORK)
-    switch (rb_fork(0, 0, 0, Qnil, NULL, 0)) {
+    switch (rb_fork(0, 0, 0, Qnil)) {
       case -1:
 	return (-1);
       case 0:
Index: ext/pty/pty.c
===================================================================
--- ext/pty/pty.c	(revision 22077)
+++ ext/pty/pty.c	(revision 22078)
@@ -258,7 +258,7 @@
     carg.slavename = SlaveName;
     carg.argc = argc;
     carg.argv = argv;
-    pid = rb_fork(0, chfunc, &carg, Qnil, NULL, 0);
+    pid = rb_fork(0, chfunc, &carg, Qnil);
 
     if (pid < 0) {
 	close(master);

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

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