diff options
author | Bram Moolenaar <Bram@vim.org> | 2014-08-29 17:45:32 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2014-08-29 17:45:32 +0200 |
commit | c40bdee42a58c48e00c76886289904849e8c4c3c (patch) | |
tree | c0199fe171deff52dbaea97987b70193079c6968 | |
parent | 52a7246f015be40e54007c0c3a1d9e37dc14045a (diff) | |
download | vim-c40bdee42a58c48e00c76886289904849e8c4c3c.zip |
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)
-rw-r--r-- | src/os_win32.c | 25 | ||||
-rw-r--r-- | 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 @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 428, +/**/ 427, /**/ 426, |