diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-28 07:30:21 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-28 07:30:21 +0000 |
commit | bcafeef2e753b4f02bea2e73bd5082bb789bea26 (patch) | |
tree | 8ab4e0e171474b77012b336b6d1b1a24a973b625 /win32 | |
parent | 7149859bc35cfe7497a1e98118f22a1628e8703d (diff) |
merge revision(s) 48360,48364: [Backport #10493]
* ext/etc/etc.c (etc_getlogin): set login name encoding properly.
[ruby-core:66163] [Bug #10493]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@48634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r-- | win32/win32.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/win32/win32.c b/win32/win32.c index 1dcad8693a..f85d4ec9d1 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -472,6 +472,16 @@ rb_w32_system_tmpdir(WCHAR *path, UINT len) return p - path + numberof(temp) - 1; } +static UINT filecp(void); +static WCHAR *mbstr_to_wstr(UINT, const char *, int, long *); +static char *wstr_to_mbstr(UINT, const WCHAR *, int, long *); +#define acp_to_wstr(str, plen) mbstr_to_wstr(CP_ACP, str, -1, plen) +#define wstr_to_acp(str, plen) wstr_to_mbstr(CP_ACP, str, -1, plen) +#define filecp_to_wstr(str, plen) mbstr_to_wstr(filecp(), str, -1, plen) +#define wstr_to_filecp(str, plen) wstr_to_mbstr(filecp(), str, -1, plen) +#define utf8_to_wstr(str, plen) mbstr_to_wstr(CP_UTF8, str, -1, plen) +#define wstr_to_utf8(str, plen) wstr_to_mbstr(CP_UTF8, str, -1, plen) + /* License: Ruby's */ static void init_env(void) @@ -518,11 +528,15 @@ init_env(void) if (!GetEnvironmentVariableW(L"USERNAME", env, numberof(env)) && !GetUserNameW(env, (len = numberof(env), &len))) { NTLoginName = "<Unknown>"; - return; } - set_env_val(L"USER"); + else { + set_env_val(L"USER"); + NTLoginName = wstr_to_mbstr(CP_UTF8, env, -1, NULL); + } + } + else { + NTLoginName = wstr_to_mbstr(CP_UTF8, env, -1, NULL); } - NTLoginName = strdup(rb_w32_getenv("USER")); if (!GetEnvironmentVariableW(TMPDIR, env, numberof(env)) && !GetEnvironmentVariableW(L"TMP", env, numberof(env)) && @@ -1165,16 +1179,6 @@ is_batch(const char *cmd) return 0; } -static UINT filecp(void); -static WCHAR *mbstr_to_wstr(UINT, const char *, int, long *); -static char *wstr_to_mbstr(UINT, const WCHAR *, int, long *); -#define acp_to_wstr(str, plen) mbstr_to_wstr(CP_ACP, str, -1, plen) -#define wstr_to_acp(str, plen) wstr_to_mbstr(CP_ACP, str, -1, plen) -#define filecp_to_wstr(str, plen) mbstr_to_wstr(filecp(), str, -1, plen) -#define wstr_to_filecp(str, plen) wstr_to_mbstr(filecp(), str, -1, plen) -#define utf8_to_wstr(str, plen) mbstr_to_wstr(CP_UTF8, str, -1, plen) -#define wstr_to_utf8(str, plen) wstr_to_mbstr(CP_UTF8, str, -1, plen) - /* License: Artistic or GPL */ rb_pid_t rb_w32_spawn(int mode, const char *cmd, const char *prog) |