summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-27 01:14:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-27 01:14:30 +0000
commite8d486e119ac254cf2438d2b5bd9de2ec5af8ebc (patch)
tree4de32880216a4fc4fe244bd4093eed2ec2b497f1 /win32
parent9b6bafef387de68aa9a31f39470e660b6524443d (diff)
* process.c (rb_proc_exec): strip trailing spaces. [ruby-dev:24143]
* win32/win32.c (CreateChild): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 1f4b5472fe..4203ca2aba 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -936,18 +936,29 @@ CreateChild(const char *cmd, const char *prog, SECURITY_ATTRIBUTES *psa,
}
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 {
@@ -958,9 +969,17 @@ CreateChild(const char *cmd, const char *prog, SECURITY_ATTRIBUTES *psa,
p = dln_find_exe(cmd, NULL);
break;
}
- if (strchr(".:*?\"/\\", *prog)) break;
+ if (strchr(".:*?\"/\\", *prog)) {
+ if (cmd[len]) {
+ char *tmp = ALLOCA_N(char, len + 1);
+ memcpy(tmp, cmd, len);
+ tmp[len] = 0;
+ cmd = tmp;
+ }
+ break;
+ }
if (ISSPACE(*prog) || strchr("<>|", *prog)) {
- int len = prog - cmd;
+ len = prog - cmd;
p = ALLOCA_N(char, len + 1);
memcpy(p, cmd, len);
p[len] = 0;