Hi,

2012/09/16 Sun 8:12:34 UTC+9 Yukihiro Nakadaira:
> This patch doesn't work for unicode path.

I wrote a patch for that.

Additionally I found a mistake in a comment of os_win32.h.
_MAX_PATH is defined as 260 (not 256) on Windows.

Regards,
Ken Takata

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -r 68fd19007be0 src/os_win32.c
--- a/src/os_win32.c	Tue Sep 11 16:48:42 2012 +0200
+++ b/src/os_win32.c	Sun Sep 16 00:58:47 2012 +0900
@@ -288,18 +288,37 @@
 vimLoadLib(char *name)
 {
     HINSTANCE dll = NULL;
-    char old_dir[MAXPATHL];
+    char old_dir[_MAX_PATH];
 
     if (exe_path == NULL)
 	get_exe_name();
-    if (exe_path != NULL && mch_dirname(old_dir, MAXPATHL) == OK)
+    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. */
-	mch_chdir(exe_path);
-	dll = LoadLibrary(name);
-	mch_chdir(old_dir);
+#ifdef FEAT_MBYTE
+	WCHAR old_dirw[_MAX_PATH];
+
+	if (GetCurrentDirectoryW(_MAX_PATH, 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(_MAX_PATH, 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 -r eb0e0ea05b1c src/os_win32.h
--- a/src/os_win32.h	Tue Sep 11 16:47:51 2012 +0200
+++ b/src/os_win32.h	Sat Sep 15 23:18:08 2012 +0900
@@ -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
 

Raspunde prin e-mail lui