Mercurial > vim
diff src/os_win32.c @ 3902:d24d309c365f v7.3.707
updated for version 7.3.707
Problem: Problems loading a library for a file name with non-latin
characters.
Solution: Use wide system functions when possible. (Ken Takata)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 21 Oct 2012 21:38:45 +0200 |
parents | 48af86560945 |
children | e6d8b44065bc |
line wrap: on
line diff
--- a/src/os_win32.c +++ b/src/os_win32.c @@ -287,27 +287,40 @@ unescape_shellxquote(char_u *p, char_u * HINSTANCE vimLoadLib(char *name) { - HINSTANCE dll = NULL; - TCHAR old_dir[MAXPATHL]; + HINSTANCE dll = NULL; + char old_dir[MAXPATHL]; /* NOTE: Do not use mch_dirname() and mch_chdir() here, they may call * vimLoadLib() recursively, which causes a stack overflow. */ if (exe_path == NULL) get_exe_name(); - if (exe_path != NULL && GetCurrentDirectory(MAXPATHL, old_dir) != 0) + if (exe_path != NULL) { - /* Change directory to where the executable is, both to make sure we - * find a .dll there and to avoid looking for a .dll in the current - * directory. */ - SetCurrentDirectory(exe_path); - dll = LoadLibrary(name); - SetCurrentDirectory(old_dir); - } - else - { - /* We are not able to change directory to where the executable is, try - * to load library anyway. */ - dll = LoadLibrary(name); +#ifdef FEAT_MBYTE + WCHAR old_dirw[MAXPATHL]; + + if (GetCurrentDirectoryW(MAXPATHL, old_dirw) != 0) + { + /* Change directory to where the executable is, both to make + * sure we find a .dll there and to avoid looking for a .dll + * in the current directory. */ + SetCurrentDirectory(exe_path); + dll = LoadLibrary(name); + SetCurrentDirectoryW(old_dirw); + return dll; + } + /* Retry with non-wide function (for Windows 98). */ + if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) +#endif + if (GetCurrentDirectory(MAXPATHL, old_dir) != 0) + { + /* Change directory to where the executable is, both to make + * sure we find a .dll there and to avoid looking for a .dll + * in the current directory. */ + SetCurrentDirectory(exe_path); + dll = LoadLibrary(name); + SetCurrentDirectory(old_dir); + } } return dll; }