diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-03-12 18:38:02 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-03-12 18:38:02 +0100 |
commit | 47ffb905f363571072faefbd417938e7ff351a9f (patch) | |
tree | e5b758ca24a59efa72246dd742e9d508c3add5f7 /src | |
parent | abb4d5f73fd97d8f3c3e32311959929820e74b54 (diff) |
patch 8.0.0450: v:progpath is not reliably setv8.0.0450
Problem: v:progpath is not reliably set.
Solution: Read /proc/self/exe if possible. (idea by Michal Grochmal)
Also fixes missing #if.
Diffstat (limited to 'src')
-rw-r--r-- | src/config.h.in | 3 | ||||
-rw-r--r-- | src/main.c | 15 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 18 insertions, 2 deletions
diff --git a/src/config.h.in b/src/config.h.in index 49ed596f47..a9bcf1ef33 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -446,6 +446,9 @@ /* Define if fcntl()'s F_SETFD command knows about FD_CLOEXEC */ #undef HAVE_FD_CLOEXEC +/* Define if /proc/self/exe can be read */ +#undef HAVE_PROC_SELF_EXE + /* Define if you want Cygwin to use the WIN32 clipboard, not compatible with X11*/ #undef FEAT_CYGWIN_WIN32_CLIPBOARD diff --git a/src/main.c b/src/main.c index f96bca99d8..aa5a1a20c3 100644 --- a/src/main.c +++ b/src/main.c @@ -3539,16 +3539,27 @@ set_progpath(char_u *argv0) { char_u *val = argv0; +# ifdef HAVE_PROC_SELF_EXE + char buf[PATH_MAX + 1]; + ssize_t len; + + len = readlink("/proc/self/exe", buf, PATH_MAX); + if (len > 0) + { + buf[len] = NUL; + val = (char_u *)buf; + } +# else /* 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 +# ifdef WIN32 char_u *path = NULL; if (mch_can_exe(argv0, &path, FALSE) && path != NULL) val = path; -# else +# else char_u buf[MAXPATHL]; if (!mch_isFullName(argv0)) diff --git a/src/version.c b/src/version.c index 54df7061c7..257cba1211 100644 --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 450, +/**/ 449, /**/ 448, |