summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-25 09:53:40 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-25 09:53:40 +0000
commitc3b50d5adaa0c140dc3d681d6c0c4c10dd2e7fe6 (patch)
treee0058542f220853551cd35b85766e29e14d8db08 /win32
parent164b237da1f1787cb1cd9e8d3bec79344b05f7df (diff)
merges r20942 from trunk into ruby_1_9_1.
* win32/win32.c (rb_w32_spawn): support normal commands with arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 9697c8ec60..e111bf87ec 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -900,35 +900,36 @@ rb_w32_spawn(int mode, const char *cmd, const char *prog)
}
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 @@ rb_w32_spawn(int mode, const char *cmd, const char *prog)
STRNDUPA(p, cmd, len);
}
p = dln_find_exe_r(p ? p : cmd, NULL, fbuf, sizeof(fbuf));
- cmd += len;
break;
}
if (ISSPACE(*prog) || strchr("<>|", *prog)) {