]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.034 v7.3.034
authorBram Moolenaar <Bram@vim.org>
Sat, 23 Oct 2010 12:02:54 +0000 (14:02 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 23 Oct 2010 12:02:54 +0000 (14:02 +0200)
Problem:    Win32: may be loading .dll from the wrong directory.
Solution:   Go to the Vim executable directory when opening a library.

12 files changed:
src/gui_w32.c
src/if_lua.c
src/if_mzsch.c
src/if_perl.xs
src/if_python.c
src/if_python3.c
src/if_ruby.c
src/mbyte.c
src/os_mswin.c
src/os_win32.c
src/proto/os_win32.pro
src/version.c

index 3a54e817e2ade4af5b6cf5764b92c115e986683b..d1335a22b743270ab3d007e646db600673037632 100644 (file)
@@ -1260,7 +1260,7 @@ gui_mch_prepare(int *argc, char **argv)
 
     /* try and load the user32.dll library and get the entry points for
      * multi-monitor-support. */
-    if ((user32_lib = LoadLibrary("User32.dll")) != NULL)
+    if ((user32_lib = vimLoadLib("User32.dll")) != NULL)
     {
        pMonitorFromWindow = (TMonitorFromWindow)GetProcAddress(user32_lib,
                                                         "MonitorFromWindow");
@@ -4188,7 +4188,7 @@ gui_mch_set_foreground(void)
     static void
 dyn_imm_load(void)
 {
-    hLibImm = LoadLibrary("imm32.dll");
+    hLibImm = vimLoadLib("imm32.dll");
     if (hLibImm == NULL)
        return;
 
index 35ee3002c66bf7e605d3910c4f839efa7a83fb0c..3062de8cf10b5c48397aa5b61d41eaa90ed1e41e 100644 (file)
@@ -49,7 +49,7 @@ static const char LUAVIM_FREE[] = "luaV_free";
 # define symbol_from_dll dlsym
 # define close_dll dlclose
 #else
-# define load_dll LoadLibrary
+# define load_dll vimLoadLib
 # define symbol_from_dll GetProcAddress
 # define close_dll FreeLibrary
 #endif
index f31ea0663b17b8414dc2e250f3caa2feb8c38234..d940fd94be901779d814126844829bbdbd5d4a92 100644 (file)
@@ -556,8 +556,8 @@ mzscheme_runtime_link_init(char *sch_dll, char *gc_dll, int verbose)
 
     if (hMzGC && hMzSch)
        return OK;
-    hMzSch = LoadLibrary(sch_dll);
-    hMzGC = LoadLibrary(gc_dll);
+    hMzSch = vimLoadLib(sch_dll);
+    hMzGC = vimLoadLib(gc_dll);
 
     if (!hMzSch)
     {
index a3dc4fe5b5c83d325a3aae77a7ed00b2f5312ec2..545dc7b66f6898c29ea5a06e8d92860fb7480761 100644 (file)
@@ -106,7 +106,7 @@ typedef int perl_key;
 #define close_dll dlclose
 #else
 #define PERL_PROC FARPROC
-#define load_dll LoadLibrary
+#define load_dll vimLoadLib
 #define symbol_from_dll GetProcAddress
 #define close_dll FreeLibrary
 #endif
index 7b1d6e7b084e82a5d58c05e6a7f177759ee7b8f6..f9bcf5892aa0d765e02e53bddf02664e26f586fb 100644 (file)
@@ -110,7 +110,7 @@ struct PyMethodDef { Py_ssize_t a; };
 #  define close_dll dlclose
 #  define symbol_from_dll dlsym
 # else
-#  define load_dll LoadLibrary
+#  define load_dll vimLoadLib
 #  define close_dll FreeLibrary
 #  define symbol_from_dll GetProcAddress
 # endif
index 4aa7edfd53c8a3ff0ad3fef3daf99dcb78e0928f..e56cdbdabad062c2356d3a4f8f5b23a81df75404 100644 (file)
@@ -88,7 +88,7 @@ static void init_structs(void);
 #  define close_dll dlclose
 #  define symbol_from_dll dlsym
 # else
-#  define load_dll LoadLibrary
+#  define load_dll vimLoadLib
 #  define close_dll FreeLibrary
 #  define symbol_from_dll GetProcAddress
 # endif
index 9ea9a1a52e3adb841e11269a7b9ec326a17cf999..d7df24819d25aeecbbc39aa8ee9f4fe4510e6bd6 100644 (file)
@@ -55,7 +55,7 @@
 # define symbol_from_dll dlsym
 # define close_dll dlclose
 #else
-# define load_dll LoadLibrary
+# define load_dll vimLoadLib
 # define symbol_from_dll GetProcAddress
 # define close_dll FreeLibrary
 #endif
index c7da85af452a64c015fbd04a237f65f083093c81..9c0b1879135565621a9d59a6ff472d0f12105ce3 100644 (file)
@@ -4159,11 +4159,11 @@ iconv_enabled(verbose)
 {
     if (hIconvDLL != 0 && hMsvcrtDLL != 0)
        return TRUE;
-    hIconvDLL = LoadLibrary(DYNAMIC_ICONV_DLL);
+    hIconvDLL = vimLoadLib(DYNAMIC_ICONV_DLL);
     if (hIconvDLL == 0)                /* sometimes it's called libiconv.dll */
-       hIconvDLL = LoadLibrary(DYNAMIC_ICONV_DLL_ALT);
+       hIconvDLL = vimLoadLib(DYNAMIC_ICONV_DLL_ALT);
     if (hIconvDLL != 0)
-       hMsvcrtDLL = LoadLibrary(DYNAMIC_MSVCRT_DLL);
+       hMsvcrtDLL = vimLoadLib(DYNAMIC_MSVCRT_DLL);
     if (hIconvDLL == 0 || hMsvcrtDLL == 0)
     {
        /* Only give the message when 'verbose' is set, otherwise it might be
index 6ee6379e104c1173db3e2fec6cc3937edb80727c..e725e69f07b4acbb0ec2b699aeb78f508e948236 100644 (file)
@@ -817,7 +817,11 @@ mch_libcall(
     BOOL fRunTimeLinkSuccess = FALSE;
 
     // Get a handle to the DLL module.
+# ifdef WIN16
     hinstLib = LoadLibrary(libname);
+# else
+    hinstLib = vimLoadLib(libname);
+# endif
 
     // If the handle is valid, try to get the function address.
     if (hinstLib != NULL)
index 6bfcc2af5282e821887e06d3e0ebf98cae0e5ca1..100c39567e65174e9d258888c67ccd83061edd70 100644 (file)
@@ -206,42 +206,63 @@ static char *vimrun_path = "vimrun ";
 static int suppress_winsize = 1;       /* don't fiddle with console */
 #endif
 
+static char_u *exe_path = NULL;
+
     static void
 get_exe_name(void)
 {
-    char       temp[256];
-    static int did_set_PATH = FALSE;
+    char       temp[MAXPATHL];
+    char_u     *p;
 
     if (exe_name == NULL)
     {
        /* store the name of the executable, may be used for $VIM */
-       GetModuleFileName(NULL, temp, 255);
+       GetModuleFileName(NULL, temp, MAXPATHL - 1);
        if (*temp != NUL)
            exe_name = FullName_save((char_u *)temp, FALSE);
     }
 
-    if (!did_set_PATH && exe_name != NULL)
+    if (exe_path == NULL && exe_name != NULL)
     {
-       char_u      *p;
-       char_u      *newpath;
-
-       /* Append our starting directory to $PATH, so that when doing "!xxd"
-        * it's found in our starting directory.  Needed because SearchPath()
-        * also looks there. */
-       p = mch_getenv("PATH");
-       newpath = alloc((unsigned)(STRLEN(p) + STRLEN(exe_name) + 2));
-       if (newpath != NULL)
+       exe_path = vim_strnsave(exe_name, gettail_sep(exe_name) - exe_name);
+       if (exe_path != NULL)
        {
-           STRCPY(newpath, p);
-           STRCAT(newpath, ";");
-           vim_strncpy(newpath + STRLEN(newpath), exe_name,
-                                           gettail_sep(exe_name) - exe_name);
-           vim_setenv((char_u *)"PATH", newpath);
-           vim_free(newpath);
+           /* Append our starting directory to $PATH, so that when doing
+            * "!xxd" it's found in our starting directory.  Needed because
+            * SearchPath() also looks there. */
+           p = mch_getenv("PATH");
+           if (STRLEN(p) + STRLEN(exe_path) + 2 < MAXPATHL);
+           {
+               STRCPY(temp, p);
+               STRCAT(temp, ";");
+               STRCAT(temp, exe_path);
+               vim_setenv((char_u *)"PATH", temp);
+           }
        }
+    }
+}
 
-       did_set_PATH = TRUE;
+/*
+ * Load library "name".
+ */
+    HINSTANCE
+vimLoadLib(char *name)
+{
+    HINSTANCE dll = NULL;
+    char old_dir[MAXPATHL];
+
+    if (exe_path == NULL)
+       get_exe_name();
+    if (exe_path != NULL && mch_dirname(old_dir, MAXPATHL) == OK)
+    {
+       /* 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);
     }
+    return dll;
 }
 
 #if defined(DYNAMIC_GETTEXT) || defined(PROTO)
@@ -254,7 +275,7 @@ static char *null_libintl_textdomain(const char *);
 static char *null_libintl_bindtextdomain(const char *, const char *);
 static char *null_libintl_bind_textdomain_codeset(const char *, const char *);
 
-static HINSTANCE hLibintlDLL = 0;
+static HINSTANCE hLibintlDLL = NULL;
 char *(*dyn_libintl_gettext)(const char *) = null_libintl_gettext;
 char *(*dyn_libintl_textdomain)(const char *) = null_libintl_textdomain;
 char *(*dyn_libintl_bindtextdomain)(const char *, const char *)
@@ -282,26 +303,16 @@ dyn_libintl_init(char *libname)
     if (hLibintlDLL)
        return 1;
     /* Load gettext library (libintl.dll) */
-    hLibintlDLL = LoadLibrary(libname != NULL ? libname : GETTEXT_DLL);
+    hLibintlDLL = vimLoadLib(libname != NULL ? libname : GETTEXT_DLL);
     if (!hLibintlDLL)
     {
-       char_u      dirname[_MAX_PATH];
-
-       /* Try using the path from gvim.exe to find the .dll there. */
-       get_exe_name();
-       STRCPY(dirname, exe_name);
-       STRCPY(gettail(dirname), GETTEXT_DLL);
-       hLibintlDLL = LoadLibrary((char *)dirname);
-       if (!hLibintlDLL)
+       if (p_verbose > 0)
        {
-           if (p_verbose > 0)
-           {
-               verbose_enter();
-               EMSG2(_(e_loadlib), GETTEXT_DLL);
-               verbose_leave();
-           }
-           return 0;
+           verbose_enter();
+           EMSG2(_(e_loadlib), GETTEXT_DLL);
+           verbose_leave();
        }
+       return 0;
     }
     for (i = 0; libintl_entry[i].name != NULL
                                         && libintl_entry[i].ptr != NULL; ++i)
@@ -430,7 +441,7 @@ PlatformId(void)
             * Seems like a lot of overhead to load/unload ADVAPI32.DLL each
             * time we verify security...
             */
-           advapi_lib = LoadLibrary("ADVAPI32.DLL");
+           advapi_lib = vimLoadLib("ADVAPI32.DLL");
            if (advapi_lib != NULL)
            {
                pSetNamedSecurityInfo = (PSNSECINFO)GetProcAddress(advapi_lib,
index 5ca85c7b44df9e8fb1ebf14ad3dfccfcfd161ada..31aa269ae6e93028fd4d55f0d99365bb7bb45f0f 100644 (file)
@@ -1,4 +1,5 @@
 /* os_win32.c */
+HINSTANCE vimLoadLib __ARGS((char *name));
 int dyn_libintl_init __ARGS((char *libname));
 void dyn_libintl_end __ARGS((void));
 void PlatformId __ARGS((void));
index 3b224776f3ab71823b30eaacb6ea09bb1c639afd..934903ddd9173bc17d73a5d013507732a5f6b55f 100644 (file)
@@ -714,6 +714,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    34,
 /**/
     33,
 /**/