# HG changeset patch # User Bram Moolenaar # Date 1409327132 -7200 # Node ID 1fe61f6d52079f44f61b3e03cf9b0c300f2890d9 # Parent af7e1f8a52d3df71023e3bc789ed7fa5c5aa94cd updated for version 7.4.428 Problem: executable() may return a wrong result on MS-Windows. Solution: Change the way SearchPath() is called. (Yasuhiro Matsumoto, Ken Takata) diff --git a/src/os_win32.c b/src/os_win32.c --- a/src/os_win32.c +++ b/src/os_win32.c @@ -1906,6 +1906,8 @@ executable_exists(char *name, char_u **p { char *dum; char fname[_MAX_PATH]; + char *curpath, *newpath; + long n; #ifdef FEAT_MBYTE if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) @@ -1913,11 +1915,19 @@ executable_exists(char *name, char_u **p WCHAR *p = enc_to_utf16(name, NULL); WCHAR fnamew[_MAX_PATH]; WCHAR *dumw; - long n; + WCHAR *wcurpath, *wnewpath; if (p != NULL) { - n = (long)SearchPathW(NULL, p, NULL, _MAX_PATH, fnamew, &dumw); + wcurpath = _wgetenv(L"PATH"); + wnewpath = (WCHAR*)alloc((unsigned)(wcslen(wcurpath) + 3) + * sizeof(WCHAR)); + if (wnewpath == NULL) + return FALSE; + wcscpy(wnewpath, L".;"); + wcscat(wnewpath, wcurpath); + n = (long)SearchPathW(wnewpath, p, NULL, _MAX_PATH, fnamew, &dumw); + vim_free(wnewpath); vim_free(p); if (n > 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) { @@ -1933,7 +1943,16 @@ executable_exists(char *name, char_u **p } } #endif - if (SearchPath(NULL, name, NULL, _MAX_PATH, fname, &dum) == 0) + + curpath = getenv("PATH"); + newpath = (char*)alloc((unsigned)(STRLEN(curpath) + 3)); + if (newpath == NULL) + return FALSE; + STRCPY(newpath, ".;"); + STRCAT(newpath, curpath); + n = (long)SearchPath(newpath, name, NULL, _MAX_PATH, fname, &dum); + vim_free(newpath); + if (n == 0) return FALSE; if (mch_isdir(fname)) return FALSE; diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 428, +/**/ 427, /**/ 426,