diff options
author | Bram Moolenaar <Bram@vim.org> | 2012-10-21 21:38:45 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2012-10-21 21:38:45 +0200 |
commit | 17aa8cc255d313ac33eca4f2727ed2a6b8bdd8ef (patch) | |
tree | 81447e8fc49a88711bfde1efdec56830586d608a /src | |
parent | a9a2d8f4d0d8bfd10fdcf468e6614e196d39ffd0 (diff) |
updated for version 7.3.707v7.3.707
Problem: Problems loading a library for a file name with non-latin
characters.
Solution: Use wide system functions when possible. (Ken Takata)
Diffstat (limited to 'src')
-rw-r--r-- | src/os_win32.c | 43 | ||||
-rw-r--r-- | src/os_win32.h | 2 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 31 insertions, 16 deletions
diff --git a/src/os_win32.c b/src/os_win32.c index 006a361448..96e115ca2f 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -287,27 +287,40 @@ unescape_shellxquote(char_u *p, char_u *escaped) 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; } diff --git a/src/os_win32.h b/src/os_win32.h index 5303d6ddcc..c155fb23fa 100644 --- a/src/os_win32.h +++ b/src/os_win32.h @@ -108,7 +108,7 @@ */ #define CMDBUFFSIZE 1024 /* size of the command processing buffer */ -/* _MAX_PATH is only 256 (stdlib.h), but we want more for the 'path' option, +/* _MAX_PATH is only 260 (stdlib.h), but we want more for the 'path' option, * thus use a larger number. */ #define MAXPATHL 1024 diff --git a/src/version.c b/src/version.c index 321dfdfd58..4631c72045 100644 --- a/src/version.c +++ b/src/version.c @@ -726,6 +726,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 707, +/**/ 706, /**/ 705, |