0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

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)
This commit is contained in:
Bram Moolenaar 2014-08-29 17:45:32 +02:00
parent 52a7246f01
commit c40bdee42a
2 changed files with 24 additions and 3 deletions

View File

@ -1906,6 +1906,8 @@ executable_exists(char *name, char_u **path)
{ {
char *dum; char *dum;
char fname[_MAX_PATH]; char fname[_MAX_PATH];
char *curpath, *newpath;
long n;
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) 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 *p = enc_to_utf16(name, NULL);
WCHAR fnamew[_MAX_PATH]; WCHAR fnamew[_MAX_PATH];
WCHAR *dumw; WCHAR *dumw;
long n; WCHAR *wcurpath, *wnewpath;
if (p != NULL) 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); vim_free(p);
if (n > 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) if (n > 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
{ {
@ -1933,7 +1943,16 @@ executable_exists(char *name, char_u **path)
} }
} }
#endif #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; return FALSE;
if (mch_isdir(fname)) if (mch_isdir(fname))
return FALSE; return FALSE;

View File

@ -741,6 +741,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
428,
/**/ /**/
427, 427,
/**/ /**/