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

ruby-changes:1677

From: ko1@a...
Date: 22 Aug 2007 10:01:36 +0900
Subject: [ruby-changes:1677] shyouhei - Ruby:r13168 (ruby_1_8_6): * win32/win32.c (CreateChild): enclose command line except for

shyouhei	2007-08-22 10:01:26 +0900 (Wed, 22 Aug 2007)

  New Revision: 13168

  Modified files:
    branches/ruby_1_8_6/ChangeLog
    branches/ruby_1_8_6/version.h
    branches/ruby_1_8_6/win32/win32.c

  Log:
    * win32/win32.c (CreateChild): enclose command line except for
      command.com which can not handle quotes.  [ruby-talk:258939]


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/ChangeLog?r1=13168&r2=13167
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/version.h?r1=13168&r2=13167
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/win32/win32.c?r1=13168&r2=13167

Index: ruby_1_8_6/ChangeLog
===================================================================
--- ruby_1_8_6/ChangeLog	(revision 13167)
+++ ruby_1_8_6/ChangeLog	(revision 13168)
@@ -1,3 +1,8 @@
+Wed Aug 22 10:01:08 2007  Nobuyoshi Nakada  <nobu@r...>
+
+	* win32/win32.c (CreateChild): enclose command line except for
+	  command.com which can not handle quotes.  [ruby-talk:258939]
+
 Wed Aug 22 09:58:30 2007  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/mkmf.rb (link_command, cc_command, cpp_command): do not expand
Index: ruby_1_8_6/version.h
===================================================================
--- ruby_1_8_6/version.h	(revision 13167)
+++ ruby_1_8_6/version.h	(revision 13168)
@@ -2,7 +2,7 @@
 #define RUBY_RELEASE_DATE "2007-08-22"
 #define RUBY_VERSION_CODE 186
 #define RUBY_RELEASE_CODE 20070822
-#define RUBY_PATCHLEVEL 58
+#define RUBY_PATCHLEVEL 59
 
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 8
Index: ruby_1_8_6/win32/win32.c
===================================================================
--- ruby_1_8_6/win32/win32.c	(revision 13167)
+++ ruby_1_8_6/win32/win32.c	(revision 13168)
@@ -506,7 +506,7 @@
    -e 'END{$cmds.sort.each{|n,f|puts "    \"\\#{f.to_s(8)}\" #{n.dump} + 1,"}}'
    98cmd ntcmd
  */
-static char *szInternalCmds[] = {
+static const char *const szInternalCmds[] = {
     "\2" "assoc" + 1,
     "\3" "break" + 1,
     "\3" "call" + 1,
@@ -565,16 +565,22 @@
 }
 
 static int
-isInternalCmd(const char *cmd, const char *interp)
+is_command_com(const char *interp)
 {
-    int i, nt = 1;
-    char cmdname[9], *b = cmdname, c, **nm;
+    int i = strlen(interp) - 11;
 
-    i = strlen(interp) - 11;
     if ((i == 0 || i > 0 && isdirsep(interp[i-1])) &&
 	strcasecmp(interp+i, "command.com") == 0) {
-	nt = 0;
+	return 1;
     }
+    return 0;
+}
+
+static int
+is_internal_cmd(const char *cmd, int nt)
+{
+    char cmdname[9], *b = cmdname, c, **nm;
+
     do {
 	if (!(c = *cmd++)) return 0;
     } while (isspace(c));
@@ -942,6 +948,7 @@
     else {
 	int redir = -1;
 	int len = 0;
+	int nt;
 	while (ISSPACE(*cmd)) cmd++;
 	for (prog = cmd; *prog; prog = CharNext(prog)) {
 	    if (ISSPACE(*prog)) {
@@ -960,10 +967,12 @@
 	    cmd = tmp;
 	}
 	else if ((shell = getenv("COMSPEC")) &&
-		 ((redir < 0 ? has_redirection(cmd) : redir) ||
-		  isInternalCmd(cmd, shell))) {
-	    char *tmp = ALLOCA_N(char, strlen(shell) + len + sizeof(" /c "));
-	    sprintf(tmp, "%s /c %.*s", shell, len, cmd);
+		 (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 ")
+				 + (nt ? 2 : 0));
+	    sprintf(tmp, nt ? "%s /c \"%.*s\"" : "%s /c %.*s", shell, len, cmd);
 	    cmd = tmp;
 	}
 	else {

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

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