@@ -158,6 +158,7 @@ HBITMAP IconToBitmap(HICON hIcon, HBRUSH hBackground, int width, int height)
158158# define VIMPACKAGE " vim"
159159# ifndef GETTEXT_DLL
160160# define GETTEXT_DLL " libintl.dll"
161+ # define GETTEXT_DLL_ALT " libintl-8.dll"
161162# endif
162163
163164// Dummy functions
@@ -194,21 +195,36 @@ dyn_libintl_init(char *dir)
194195 {(char *)" bindtextdomain" , (FARPROC*)&dyn_libintl_bindtextdomain},
195196 {NULL , NULL }
196197 };
198+ DWORD len, len2;
199+ LPWSTR buf = NULL ;
200+ LPWSTR buf2 = NULL ;
197201
198202 // No need to initialize twice.
199203 if (hLibintlDLL)
200204 return 1 ;
201205
202- // Load gettext library, first try the Vim runtime directory, then search
203- // the path.
204- strcat (dir, GETTEXT_DLL);
205- hLibintlDLL = LoadLibrary (dir);
206- if (!hLibintlDLL)
206+ // Load gettext library from the Vim runtime directory.
207+ // Add the directory to $PATH temporarily.
208+ len = GetEnvironmentVariableW (L" PATH" , NULL , 0 );
209+ len2 = MAX_PATH + 1 + len;
210+ buf = (LPWSTR)malloc (len * sizeof (WCHAR));
211+ buf2 = (LPWSTR)malloc (len2 * sizeof (WCHAR));
212+ if (buf != NULL && buf2 != NULL )
207213 {
214+ GetEnvironmentVariableW (L" PATH" , buf, len);
215+ _snwprintf (buf2, len2, L" %S;%s" , dir, buf);
216+ SetEnvironmentVariableW (L" PATH" , buf2);
208217 hLibintlDLL = LoadLibrary (GETTEXT_DLL);
218+ #ifdef GETTEXT_DLL_ALT
209219 if (!hLibintlDLL)
210- return 0 ;
220+ hLibintlDLL = LoadLibrary (GETTEXT_DLL_ALT);
221+ #endif
222+ SetEnvironmentVariableW (L" PATH" , buf);
211223 }
224+ free (buf);
225+ free (buf2);
226+ if (!hLibintlDLL)
227+ return 0 ;
212228
213229 // Get the addresses of the functions we need.
214230 for (i = 0 ; libintl_entry[i].name != NULL
0 commit comments