Mercurial > vim
changeset 12148:315919a95b4d v8.0.0954
patch 8.0.0954: /proc/self/exe might be a relative path
commit https://github.com/vim/vim/commit/bc906e445c77eb4fb5ef97465a45b46499bba111
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 17 17:21:05 2017 +0200
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 https://github.com/vim/vim/issues/1983)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 17 Aug 2017 17:30:04 +0200 |
parents | 0d67653a0e9e |
children | f819c1e17fb9 |
files | src/main.c src/version.c |
diffstat | 2 files changed, 20 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main.c +++ b/src/main.c @@ -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]; - - if (!mch_isFullName(argv0)) +# else + char_u buf[MAXPATHL + 1]; +# ifdef PROC_EXE_LINK + char linkbuf[MAXPATHL + 1]; + ssize_t len; + + len = readlink(PROC_EXE_LINK, linkbuf, MAXPATHL); + if (len > 0) { - if (gettail(argv0) != argv0 - && vim_FullName(argv0, buf, MAXPATHL, TRUE) != FAIL) + 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 # endif set_vim_var_string(VV_PROGPATH, val, -1);