comparison src/main.c @ 11125:6f52cc87fe15 v8.0.0450

patch 8.0.0450: v:progpath is not reliably set commit https://github.com/vim/vim/commit/47ffb905f363571072faefbd417938e7ff351a9f Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 12 18:38:02 2017 +0100 patch 8.0.0450: v:progpath is not reliably set Problem: v:progpath is not reliably set. Solution: Read /proc/self/exe if possible. (idea by Michal Grochmal) Also fixes missing #if.
author Christian Brabandt <cb@256bit.org>
date Sun, 12 Mar 2017 18:45:05 +0100
parents 778c10516955
children 0895f142cac3
comparison
equal deleted inserted replaced
11124:9516a30abf29 11125:6f52cc87fe15
3537 static void 3537 static void
3538 set_progpath(char_u *argv0) 3538 set_progpath(char_u *argv0)
3539 { 3539 {
3540 char_u *val = argv0; 3540 char_u *val = argv0;
3541 3541
3542 # ifdef HAVE_PROC_SELF_EXE
3543 char buf[PATH_MAX + 1];
3544 ssize_t len;
3545
3546 len = readlink("/proc/self/exe", buf, PATH_MAX);
3547 if (len > 0)
3548 {
3549 buf[len] = NUL;
3550 val = (char_u *)buf;
3551 }
3552 # else
3542 /* A relative path containing a "/" will become invalid when using ":cd", 3553 /* A relative path containing a "/" will become invalid when using ":cd",
3543 * turn it into a full path. 3554 * turn it into a full path.
3544 * On MS-Windows "vim" should be expanded to "vim.exe", thus always do 3555 * On MS-Windows "vim" should be expanded to "vim.exe", thus always do
3545 * this. */ 3556 * this. */
3546 # ifdef WIN32 3557 # ifdef WIN32
3547 char_u *path = NULL; 3558 char_u *path = NULL;
3548 3559
3549 if (mch_can_exe(argv0, &path, FALSE) && path != NULL) 3560 if (mch_can_exe(argv0, &path, FALSE) && path != NULL)
3550 val = path; 3561 val = path;
3551 # else 3562 # else
3552 char_u buf[MAXPATHL]; 3563 char_u buf[MAXPATHL];
3553 3564
3554 if (!mch_isFullName(argv0)) 3565 if (!mch_isFullName(argv0))
3555 { 3566 {
3556 if (gettail(argv0) != argv0 3567 if (gettail(argv0) != argv0