From 14453a256d58b11b06d432e2a4388d95aac298d6 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Thu, 26 Nov 2020 11:15:37 +0100 Subject: 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. --- win32/win32.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'win32') diff --git a/win32/win32.c b/win32/win32.c index b7759b82bf..602fba4d22 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -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; -- cgit v1.2.3