summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-30 02:30:55 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-30 02:30:55 +0000
commited4f3ae2018a6e0279aaddedf68f8255729ed7d1 (patch)
tree3caabf66ce782c5d1b832d326c7f295b7340537d
parentd18e80bc51dcd92fec05401a1e2afdb6372c586d (diff)
* win32/win32.c (CreateChild): strip trailing spaces. [ruby-dev:24143]
merge from HEAD. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--win32/win32.c26
2 files changed, 25 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 6976360580..6300d41e25 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Aug 30 11:29:35 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (CreateChild): strip trailing spaces. [ruby-dev:24143]
+ merge from HEAD.
+
Sun Aug 29 14:08:56 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tcltklib/tcltklib.c: compile error on bcc32 [ruby-dev:24081]
diff --git a/win32/win32.c b/win32/win32.c
index df16c8dbc9..50753fcf9a 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -923,21 +923,35 @@ CreateChild(char *cmd, char *prog, SECURITY_ATTRIBUTES *psa, HANDLE hInput, HAND
}
else {
int redir = -1;
+ int len = 0;
+ 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) + strlen(cmd) +
- sizeof (" -c ") + 2);
- sprintf(tmp, "%s -c \"%s\"", shell, cmd);
+ char *tmp = ALLOCA_N(char, strlen(shell) + len + sizeof(" -c ") + 2);
+ sprintf(tmp, "%s -c \"%.*s\"", shell, len, cmd);
cmd = tmp;
}
else if ((shell = getenv("COMSPEC")) &&
((redir < 0 ? has_redirection(cmd) : redir) ||
isInternalCmd(cmd, shell))) {
- char *tmp = ALLOCA_N(char, strlen(shell) + strlen(cmd) +
- sizeof (" /c "));
- sprintf(tmp, "%s /c %s", shell, cmd);
+ char *tmp = ALLOCA_N(char, strlen(shell) + len + sizeof(" /c "));
+ sprintf(tmp, "%s /c %.*s", shell, len, cmd);
cmd = tmp;
}
else {
+ char *tmp = ALLOCA_N(char, len + 1);
+ sprintf(tmp, "%.*s", len, cmd);
+ cmd = tmp;
shell = NULL;
}
}