summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
authorLars Kanis <kanis@comcard.de>2020-11-26 11:15:37 +0100
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-11-28 17:49:47 +0900
commit14453a256d58b11b06d432e2a4388d95aac298d6 (patch)
treec45f21260e91b61efc2e41a0d848942994a4a24b /win32/win32.c
parent95edb3ec107c89a04d2a7e2395841cc228e91a81 (diff)
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.
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c7
1 files changed, 3 insertions, 4 deletions
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;