diff options
author | ZyX <kp-pav@yandex.ru> | 2017-04-10 19:12:56 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-04-10 19:12:56 +0300 |
commit | 22fb9d8d25f5354bb878b953ba49b439961c8476 (patch) | |
tree | d3c21e80d09f7b1cf1a7c525643c2e20fb5a925e /src/nvim/os | |
parent | acc52a953b99f78435c34337b8ca9b6716a057a1 (diff) | |
parent | 9aface8c4d1edd25d4fed3e099e3c2c02b0a282a (diff) | |
download | rneovim-22fb9d8d25f5354bb878b953ba49b439961c8476.tar.gz rneovim-22fb9d8d25f5354bb878b953ba49b439961c8476.tar.bz2 rneovim-22fb9d8d25f5354bb878b953ba49b439961c8476.zip |
Merge branch 'master' into 1476-changes
Diffstat (limited to 'src/nvim/os')
-rw-r--r-- | src/nvim/os/env.c | 24 | ||||
-rw-r--r-- | src/nvim/os/fs.c | 2 |
2 files changed, 21 insertions, 5 deletions
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 839e0d1b51..12c2da6152 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -118,7 +118,6 @@ char *os_getenvname_at_index(size_t index) return name; } - /// Get the process ID of the Neovim process. /// /// @return the process ID. @@ -145,10 +144,27 @@ void os_get_hostname(char *hostname, size_t size) } else { xstrlcpy(hostname, vutsname.nodename, size); } +#elif defined(WIN32) + WCHAR host_utf16[MAX_COMPUTERNAME_LENGTH + 1]; + DWORD host_wsize = sizeof(host_utf16) / sizeof(host_utf16[0]); + if (GetComputerNameW(host_utf16, &host_wsize) == 0) { + *hostname = '\0'; + DWORD err = GetLastError(); + EMSG2("GetComputerNameW failed: %d", err); + return; + } + host_utf16[host_wsize] = '\0'; + + char *host_utf8; + int conversion_result = utf16_to_utf8(host_utf16, &host_utf8); + if (conversion_result != 0) { + EMSG2("utf16_to_utf8 failed: %d", conversion_result); + return; + } + xstrlcpy(hostname, host_utf8, size); + xfree(host_utf8); #else - // TODO(unknown): Implement this for windows. - // See the implementation used in vim: - // https://code.google.com/p/vim/source/browse/src/os_win32.c?r=6b69d8dde19e32909f4ee3a6337e6a2ecfbb6f72#2899 + EMSG("os_get_hostname failed: missing uname()"); *hostname = '\0'; #endif } diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 3833a43f5f..c33e1140e8 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -1009,7 +1009,7 @@ char *os_resolve_shortcut(const char *fname) WCHAR *p; const int conversion_result = utf8_to_utf16(fname, &p); if (conversion_result != 0) { - EMSG2("utf8_to_utf16 failed: %s", uv_strerror(conversion_result)); + EMSG2("utf8_to_utf16 failed: %d", conversion_result); } if (p != NULL) { |