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

ruby-changes:23977

From: akr <ko1@a...>
Date: Mon, 11 Jun 2012 06:32:23 +0900 (JST)
Subject: [ruby-changes:23977] akr:r36028 (trunk): * process.c (rb_proc_exec_n): revert the function removed at r35889.

akr	2012-06-11 06:31:49 +0900 (Mon, 11 Jun 2012)

  New Revision: 36028

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

  Log:
    * process.c (rb_proc_exec_n): revert the function removed at r35889.

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

Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 36027)
+++ include/ruby/intern.h	(revision 36028)
@@ -607,6 +607,7 @@
     VALUE envp_buf;
     VALUE dup2_tmpbuf;
 };
+int rb_proc_exec_n(int, VALUE*, const char*);
 int rb_proc_exec(const char*);
 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);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36027)
+++ ChangeLog	(revision 36028)
@@ -1,3 +1,7 @@
+Mon Jun 11 06:31:33 2012  Tanaka Akira  <akr@f...>
+
+	* process.c (rb_proc_exec_n): revert the function removed at r35889.
+
 Mon Jun 11 06:20:50 2012  NARUSE, Yui  <naruse@r...>
 
 	* thread_pthread.c (rb_thread_create_timer_thread): assign return
Index: process.c
===================================================================
--- process.c	(revision 36027)
+++ process.c	(revision 36028)
@@ -1147,6 +1147,54 @@
 #endif
 }
 
+/* deprecated */
+static int
+proc_exec_v(char **argv, const char *prog)
+{
+    char fbuf[MAXPATHLEN];
+
+    if (!prog)
+        prog = argv[0];
+    prog = dln_find_exe_r(prog, 0, fbuf, sizeof(fbuf));
+    if (!prog) {
+        errno = ENOENT;
+        return -1;
+    }
+    before_exec();
+    execv(prog, argv);
+    preserving_errno(try_with_sh(prog, argv, 0); after_exec());
+    return -1;
+}
+
+/* deprecated */
+int
+rb_proc_exec_n(int argc, VALUE *argv, const char *prog)
+{
+#define ARGV_COUNT(n) ((n)+1)
+#define ARGV_SIZE(n) (sizeof(char*) * ARGV_COUNT(n))
+#define ALLOC_ARGV(n, v) ALLOCV_N(char*, (v), ARGV_COUNT(n))
+
+    char **args;
+    int i;
+    int ret = -1;
+    VALUE v;
+
+    args = ALLOC_ARGV(argc+1, v);
+    for (i=0; i<argc; i++) {
+	args[i] = RSTRING_PTR(argv[i]);
+    }
+    args[i] = 0;
+    if (args[0]) {
+	ret = proc_exec_v(args, prog);
+    }
+    ALLOCV_END(v);
+    return ret;
+
+#undef ARGV_COUNT
+#undef ARGV_SIZE
+#undef ALLOC_ARGV
+}
+
 /* This function should be async-signal-safe.  Actually it is. */
 static int
 proc_exec_sh(const char *str, VALUE envp_str)

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

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