summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-02 07:30:35 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-02 07:30:35 +0000
commit5aad8206044f98b28bc303d5bd7d3e4f935e96ec (patch)
tree4873263f227dc109031fcfcc1db0a54cbf298c57 /win32
parent95ce90a87ed0a058386eea410aeac0aac2ee2dc8 (diff)
* io.c (pipe_open): erred program name should be reported by
exceptions, instead of the first argument. * process.c (rb_spawn): ditto. * process.c (proc_spawn_v): use first argument as program name. * win32/win32.c (rb_w32_aspawn): ditto. * win32/win32.c (CreateChild): search executable file if no program name given. * lib/drb/extservm.rb (invoke_service_command): use Process.spawn. [ruby-dev:23103] * lib/rdoc/ri/ri_display.rb (setup_pager): use IO.popen. [ruby-dev:23086], [ruby-dev:23103] * lib/rdoc/diagram.rb (convert_to_png): ditto. * lib/rdoc/generators/chm_generator.rb (compile_project): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 5a346fe1c0..573eb294ec 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -842,6 +842,7 @@ rb_w32_aspawn(int mode, const char *prog, char *const *argv)
int len = rb_w32_argv_size(argv);
char *cmd = ALLOCA_N(char, len);
+ if (!prog) prog = argv[0];
return rb_w32_spawn(mode, rb_w32_join_argv(cmd, argv), prog);
}
@@ -855,6 +856,7 @@ CreateChild(const char *cmd, const char *prog, SECURITY_ATTRIBUTES *psa, HANDLE
SECURITY_ATTRIBUTES sa;
const char *shell;
struct ChildRecord *child;
+ char *p = NULL;
if (!cmd && !prog) {
errno = EFAULT;
@@ -902,18 +904,9 @@ CreateChild(const char *cmd, const char *prog, SECURITY_ATTRIBUTES *psa, HANDLE
dwCreationFlags = (NORMAL_PRIORITY_CLASS);
if (prog) {
- char *p = dln_find_exe(prog, NULL);
- if (!p) {
+ if (!(p = dln_find_exe(prog, NULL))) {
shell = prog;
}
- else {
- shell = p;
- while (*p) {
- if ((unsigned char)*p == '/')
- *p = '\\';
- p = CharNext(p);
- }
- }
}
else {
int redir = -1;
@@ -933,6 +926,31 @@ CreateChild(const char *cmd, const char *prog, SECURITY_ATTRIBUTES *psa, HANDLE
}
else {
shell = NULL;
+ prog = cmd;
+ for (;;) {
+ if (!*prog) {
+ p = dln_find_exe(cmd, NULL);
+ break;
+ }
+ if (strchr(".:*?\"/\\", *prog)) break;
+ if (ISSPACE(*prog) || strchr("<>|", *prog)) {
+ int len = prog - cmd;
+ p = ALLOCA_N(char, len + 1);
+ memcpy(p, cmd, len);
+ p[len] = 0;
+ p = dln_find_exe(p, NULL);
+ break;
+ }
+ prog++;
+ }
+ }
+ }
+ if (p) {
+ shell = p;
+ while (*p) {
+ if ((unsigned char)*p == '/')
+ *p = '\\';
+ p = CharNext(p);
}
}