Skip to content

Commit 69574ad

Browse files
committed
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)
1 parent 7a977df commit 69574ad

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

src/os_win32.c

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -287,27 +287,40 @@ unescape_shellxquote(char_u *p, char_u *escaped)
287287
HINSTANCE
288288
vimLoadLib(char *name)
289289
{
290-
HINSTANCE dll = NULL;
291-
TCHAR old_dir[MAXPATHL];
290+
HINSTANCE dll = NULL;
291+
char old_dir[MAXPATHL];
292292

293293
/* NOTE: Do not use mch_dirname() and mch_chdir() here, they may call
294294
* vimLoadLib() recursively, which causes a stack overflow. */
295295
if (exe_path == NULL)
296296
get_exe_name();
297-
if (exe_path != NULL && GetCurrentDirectory(MAXPATHL, old_dir) != 0)
297+
if (exe_path != NULL)
298298
{
299-
/* Change directory to where the executable is, both to make sure we
300-
* find a .dll there and to avoid looking for a .dll in the current
301-
* directory. */
302-
SetCurrentDirectory(exe_path);
303-
dll = LoadLibrary(name);
304-
SetCurrentDirectory(old_dir);
305-
}
306-
else
307-
{
308-
/* We are not able to change directory to where the executable is, try
309-
* to load library anyway. */
310-
dll = LoadLibrary(name);
299+
#ifdef FEAT_MBYTE
300+
WCHAR old_dirw[MAXPATHL];
301+
302+
if (GetCurrentDirectoryW(MAXPATHL, old_dirw) != 0)
303+
{
304+
/* Change directory to where the executable is, both to make
305+
* sure we find a .dll there and to avoid looking for a .dll
306+
* in the current directory. */
307+
SetCurrentDirectory(exe_path);
308+
dll = LoadLibrary(name);
309+
SetCurrentDirectoryW(old_dirw);
310+
return dll;
311+
}
312+
/* Retry with non-wide function (for Windows 98). */
313+
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
314+
#endif
315+
if (GetCurrentDirectory(MAXPATHL, old_dir) != 0)
316+
{
317+
/* Change directory to where the executable is, both to make
318+
* sure we find a .dll there and to avoid looking for a .dll
319+
* in the current directory. */
320+
SetCurrentDirectory(exe_path);
321+
dll = LoadLibrary(name);
322+
SetCurrentDirectory(old_dir);
323+
}
311324
}
312325
return dll;
313326
}

src/os_win32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
*/
109109
#define CMDBUFFSIZE 1024 /* size of the command processing buffer */
110110

111-
/* _MAX_PATH is only 256 (stdlib.h), but we want more for the 'path' option,
111+
/* _MAX_PATH is only 260 (stdlib.h), but we want more for the 'path' option,
112112
* thus use a larger number. */
113113
#define MAXPATHL 1024
114114

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,8 @@ static char *(features[]) =
725725

726726
static int included_patches[] =
727727
{ /* Add new patch number below this line */
728+
/**/
729+
707,
728730
/**/
729731
706,
730732
/**/

0 commit comments

Comments
 (0)