ruby-changes:63787
From: Lars <ko1@a...>
Date: Sat, 28 Nov 2020 17:51:00 +0900 (JST)
Subject: [ruby-changes:63787] 14453a256d (master): Windows: Improve readablity of getenv() encoding
https://git.ruby-lang.org/ruby.git/commit/?id=14453a256d From 14453a256d58b11b06d432e2a4388d95aac298d6 Mon Sep 17 00:00:00 2001 From: Lars Kanis <kanis@c...> 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. diff --git a/win32/win32.c b/win32/win32.c index b7759b8..602fba4 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -74,7 +74,6 @@ static char *w32_getenv(const char *name, UINT cp); https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L74 #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) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L1361 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) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L1369 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 https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L1490 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 v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/