Windows: Improve readablity of getenv() encoding

getenv() did use the expected codepage as an implicit parameter of the macro.
This is mis-leading since include/ruby/win32.h has a different definition.
Using the "cp" variable explicit (like the other function calls) makes it
more readable and consistent.
This commit is contained in:
Lars Kanis 2020-11-26 11:15:37 +01:00 коммит произвёл Nobuyoshi Nakada
Родитель 95edb3ec10
Коммит 14453a256d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7CD2805BFA3770C6
1 изменённых файлов: 3 добавлений и 4 удалений

Просмотреть файл

@ -74,7 +74,6 @@ static char *w32_getenv(const char *name, UINT cp);
#define DLN_FIND_EXTRA_ARG_DECL ,UINT cp
#define DLN_FIND_EXTRA_ARG ,cp
#define rb_w32_stati128(path, st) w32_stati128(path, st, cp, FALSE)
#define getenv(name) w32_getenv(name, cp)
#undef CharNext
#define CharNext(p) CharNextExA(cp, (p), 0)
#define dln_find_exe_r rb_w32_udln_find_exe_r
@ -1362,7 +1361,7 @@ w32_spawn(int mode, const char *cmd, const char *prog, UINT cp)
int redir = -1;
int nt;
while (ISSPACE(*cmd)) cmd++;
if ((shell = getenv("RUBYSHELL")) && (redir = has_redirection(cmd, cp))) {
if ((shell = w32_getenv("RUBYSHELL", cp)) && (redir = has_redirection(cmd, cp))) {
size_t shell_len = strlen(shell);
char *tmp = ALLOCV(v, shell_len + strlen(cmd) + sizeof(" -c ") + 2);
memcpy(tmp, shell, shell_len + 1);
@ -1370,7 +1369,7 @@ w32_spawn(int mode, const char *cmd, const char *prog, UINT cp)
sprintf(tmp + shell_len, " -c \"%s\"", cmd);
cmd = tmp;
}
else if ((shell = getenv("COMSPEC")) &&
else if ((shell = w32_getenv("COMSPEC", cp)) &&
(nt = !is_command_com(shell),
(redir < 0 ? has_redirection(cmd, cp) : redir) ||
is_internal_cmd(cmd, nt))) {
@ -1491,7 +1490,7 @@ w32_aspawn_flags(int mode, const char *prog, char *const *argv, DWORD flags, UIN
if (check_spawn_mode(mode)) return -1;
if (!prog) prog = argv[0];
if ((shell = getenv("COMSPEC")) &&
if ((shell = w32_getenv("COMSPEC", cp)) &&
internal_cmd_match(prog, tmpnt = !is_command_com(shell))) {
ntcmd = tmpnt;
prog = shell;