Project

General

Profile

Feature #1482 ยป 0001-win32.c-use-COMSPEC.patch

nobu (Nobuyoshi Nakada), 10/29/2012 05:39 PM

View differences:

win32/win32.c
char fbuf[MAXPATHLEN];
char *p = NULL;
const char *shell = NULL;
const char *comspec = NULL;
WCHAR *wcmd, *wshell;
rb_pid_t ret;
VALUE v = 0;
......
sprintf(tmp, "%s -c \"%s\"", shell, cmd);
cmd = tmp;
}
else if ((shell = getenv("COMSPEC")) &&
else if ((shell = comspec = getenv("COMSPEC")) &&
(nt = !is_command_com(shell),
(redir < 0 ? has_redirection(cmd) : redir) ||
is_internal_cmd(cmd, nt))) {
char *tmp = ALLOCV(v, strlen(shell) + strlen(cmd) + sizeof(" /c ") + (nt ? 2 : 0));
char *tmp;
com:
tmp = ALLOCV(v, strlen(shell) + strlen(cmd) + sizeof(" /c ") + (nt ? 2 : 0));
sprintf(tmp, nt ? "%s /c \"%s\"" : "%s /c %s", shell, cmd);
cmd = tmp;
}
......
shell = p;
}
if (p) translate_char(p, '/', '\\');
if (is_batch(shell)) {
}
if (is_batch(shell)) {
if (!comspec) comspec = getenv("COMSPEC");
if (comspec) {
if (!dln_find_exe_r(comspec, NULL, fbuf, sizeof(fbuf))) {
errno = ENOENT;
return -1;
}
translate_char(fbuf, '/', '\\');
shell = fbuf;
goto com;
}
else {
int alen = strlen(prog);
cmd = p = ALLOCV(v, len + alen + (quote ? 2 : 0) + 1);
if (quote) *p++ = '"';
    (1-1/1)