From c40bdee42a58c48e00c76886289904849e8c4c3c Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 29 Aug 2014 17:45:32 +0200 Subject: [PATCH] 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) --- src/os_win32.c | 25 ++++++++++++++++++++++--- src/version.c | 2 ++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/os_win32.c b/src/os_win32.c index 0c896efc3..dd5714158 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -1906,6 +1906,8 @@ executable_exists(char *name, char_u **path) { 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 **path) 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 **path) } } #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 index d43534a11..17add4334 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 428, /**/ 427, /**/ -- 2.50.1