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

patch 8.0.0954: /proc/self/exe might be a relative path

Problem:    /proc/self/exe might be a relative path.
Solution:   Make the path a full path. (James McCoy, closes #1983)
This commit is contained in:
Bram Moolenaar 2017-08-17 17:21:05 +02:00
parent f5be7cd016
commit bc906e445c
2 changed files with 19 additions and 18 deletions

View File

@ -3597,36 +3597,35 @@ set_progpath(char_u *argv0)
{
char_u *val = argv0;
# ifdef PROC_EXE_LINK
char buf[MAXPATHL + 1];
ssize_t len;
len = readlink(PROC_EXE_LINK, buf, MAXPATHL);
if (len > 0)
{
buf[len] = NUL;
val = (char_u *)buf;
}
# else
# if defined(WIN32)
/* A relative path containing a "/" will become invalid when using ":cd",
* turn it into a full path.
* On MS-Windows "vim" should be expanded to "vim.exe", thus always do
* this. */
# ifdef WIN32
char_u *path = NULL;
if (mch_can_exe(argv0, &path, FALSE) && path != NULL)
val = path;
# else
char_u buf[MAXPATHL];
# else
char_u buf[MAXPATHL + 1];
# ifdef PROC_EXE_LINK
char linkbuf[MAXPATHL + 1];
ssize_t len;
if (!mch_isFullName(argv0))
len = readlink(PROC_EXE_LINK, linkbuf, MAXPATHL);
if (len > 0)
{
if (gettail(argv0) != argv0
&& vim_FullName(argv0, buf, MAXPATHL, TRUE) != FAIL)
val = buf;
linkbuf[len] = NUL;
val = (char_u *)linkbuf;
}
# endif
if (!mch_isFullName(val))
{
if (gettail(val) != val
&& vim_FullName(val, buf, MAXPATHL, TRUE) != FAIL)
val = buf;
}
# endif
set_vim_var_string(VV_PROGPATH, val, -1);

View File

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