diff src/GvimExt/gvimext.cpp @ 8180:1e48ffa2d697 v7.4.1383

commit https://github.com/vim/vim/commit/271273c39f2150ecdaa67fe1a2a8e9cdc63db545 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 21 20:30:22 2016 +0100 patch 7.4.1383 Problem: GvimExt only loads the old libintl.dll. Solution: Also try loading libint-8.dll. (Ken Takata, closes https://github.com/vim/vim/issues/608)
author Christian Brabandt <cb@256bit.org>
date Sun, 21 Feb 2016 20:45:03 +0100
parents 81cb471657e0
children aca41efd888c
line wrap: on
line diff
--- a/src/GvimExt/gvimext.cpp
+++ b/src/GvimExt/gvimext.cpp
@@ -158,6 +158,7 @@ HBITMAP IconToBitmap(HICON hIcon, HBRUSH
 # define VIMPACKAGE "vim"
 # ifndef GETTEXT_DLL
 #  define GETTEXT_DLL "libintl.dll"
+#  define GETTEXT_DLL_ALT "libintl-8.dll"
 # endif
 
 // Dummy functions
@@ -194,21 +195,36 @@ dyn_libintl_init(char *dir)
 	{(char *)"bindtextdomain",	(FARPROC*)&dyn_libintl_bindtextdomain},
 	{NULL, NULL}
     };
+    DWORD	len, len2;
+    LPWSTR	buf = NULL;
+    LPWSTR	buf2 = NULL;
 
     // No need to initialize twice.
     if (hLibintlDLL)
 	return 1;
 
-    // Load gettext library, first try the Vim runtime directory, then search
-    // the path.
-    strcat(dir, GETTEXT_DLL);
-    hLibintlDLL = LoadLibrary(dir);
+    // Load gettext library from the Vim runtime directory.
+    // Add the directory to $PATH temporarily.
+    len = GetEnvironmentVariableW(L"PATH", NULL, 0);
+    len2 = MAX_PATH + 1 + len;
+    buf = (LPWSTR)malloc(len * sizeof(WCHAR));
+    buf2 = (LPWSTR)malloc(len2 * sizeof(WCHAR));
+    if (buf != NULL && buf2 != NULL)
+    {
+	GetEnvironmentVariableW(L"PATH", buf, len);
+	_snwprintf(buf2, len2, L"%S;%s", dir, buf);
+	SetEnvironmentVariableW(L"PATH", buf2);
+	hLibintlDLL = LoadLibrary(GETTEXT_DLL);
+#ifdef GETTEXT_DLL_ALT
+	if (!hLibintlDLL)
+	    hLibintlDLL = LoadLibrary(GETTEXT_DLL_ALT);
+#endif
+	SetEnvironmentVariableW(L"PATH", buf);
+    }
+    free(buf);
+    free(buf2);
     if (!hLibintlDLL)
-    {
-	hLibintlDLL = LoadLibrary(GETTEXT_DLL);
-	if (!hLibintlDLL)
-	    return 0;
-    }
+	return 0;
 
     // Get the addresses of the functions we need.
     for (i = 0; libintl_entry[i].name != NULL