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

ruby-changes:9404

From: usa <ko1@a...>
Date: Tue, 23 Dec 2008 16:51:11 +0900 (JST)
Subject: [ruby-changes:9404] Ruby:r20942 (trunk): * win32/win32.c (rb_w32_spawn): support normal commands with arguments.

usa	2008-12-23 16:50:57 +0900 (Tue, 23 Dec 2008)

  New Revision: 20942

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

  Log:
    * win32/win32.c (rb_w32_spawn): support normal commands with arguments.

  Modified files:
    trunk/ChangeLog
    trunk/win32/win32.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 20941)
+++ ChangeLog	(revision 20942)
@@ -1,3 +1,7 @@
+Tue Dec 23 16:49:48 2008  NAKAMURA Usaku  <usa@r...>
+
+	* win32/win32.c (rb_w32_spawn): support normal commands with arguments.
+
 Tue Dec 23 16:22:41 2008  Tanaka Akira  <akr@f...>
 
 	* io.c (rb_io_inspect): show fd number if there is no pathname.
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 20941)
+++ win32/win32.c	(revision 20942)
@@ -900,35 +900,36 @@
     }
     else {
 	int redir = -1;
-	int len = 0;
 	int nt;
 	while (ISSPACE(*cmd)) cmd++;
-	for (prog = cmd; *prog; prog = CharNext(prog)) {
-	    if (ISSPACE(*prog)) {
-		len = prog - cmd;
-		do ++prog; while (ISSPACE(*prog));
-		if (!*prog--) break;
-	    }
-	    else {
-		len = 0;
-	    }
-	}
-	if (!len) len = strlen(cmd);
 	if ((shell = getenv("RUBYSHELL")) && (redir = has_redirection(cmd))) {
-	    char *tmp = ALLOCA_N(char, strlen(shell) + len + sizeof(" -c ") + 2);
-	    sprintf(tmp, "%s -c \"%.*s\"", shell, len, cmd);
+	    char *tmp = ALLOCA_N(char, strlen(shell) + strlen(cmd) + sizeof(" -c ") + 2);
+	    sprintf(tmp, "%s -c \"%s\"", shell, cmd);
 	    cmd = tmp;
 	}
 	else if ((shell = getenv("COMSPEC")) &&
 		 (nt = !is_command_com(shell),
 		  (redir < 0 ? has_redirection(cmd) : redir) ||
 		  is_internal_cmd(cmd, nt))) {
-	    char *tmp = ALLOCA_N(char, strlen(shell) + len + sizeof(" /c ")
+	    char *tmp = ALLOCA_N(char, strlen(shell) + strlen(cmd) + sizeof(" /c ")
 				 + (nt ? 2 : 0));
-	    sprintf(tmp, nt ? "%s /c \"%.*s\"" : "%s /c %.*s", shell, len, cmd);
+	    sprintf(tmp, nt ? "%s /c \"%s\"" : "%s /c %s", shell, cmd);
 	    cmd = tmp;
 	}
 	else {
+	    int len = 0;
+	    for (prog = cmd; *prog; prog = CharNext(prog)) {
+		if (ISSPACE(*prog)) {
+		    len = prog - cmd;
+		    do ++prog; while (ISSPACE(*prog));
+		    break;
+		}
+		else {
+		    len = 0;
+		}
+	    }
+	    if (!len) len = strlen(cmd);
+
 	    shell = NULL;
 	    prog = cmd;
 	    for (;;) {
@@ -941,7 +942,6 @@
 			STRNDUPA(p, cmd, len);
 		    }
 		    p = dln_find_exe_r(p ? p : cmd, NULL, fbuf, sizeof(fbuf));
-		    cmd += len;
 		    break;
 		}
 		if (ISSPACE(*prog) || strchr("<>|", *prog)) {

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

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