Patch 8.0.0416
Problem:    Setting v:progpath is not quite right.
Solution:   On MS-Windows add the extension. On Unix use the full path for a
            relative directory. (partly by James McCoy, closes #1531)
Files:      src/main.c, src/os_win32.c, src/os_unix.c


*** ../vim-8.0.0415/src/main.c  2017-03-04 19:11:08.434790994 +0100
--- src/main.c  2017-03-05 14:13:11.212545322 +0100
***************
*** 3533,3553 ****
  set_progpath(char_u *argv0)
  {
      char_u *val = argv0;
      char_u buf[MAXPATHL];
  
      /* A relative path containing a "/" will become invalid when using ":cd",
       * turn it into a full path.
       * On MS-Windows "vim.exe" is found in the current directory, thus also do
       * it when there is no path and the file exists. */
!     if ( !mch_isFullName(argv0)
  # ifdef WIN32
!           && mch_can_exe(argv0, NULL, TRUE)
  # else
!           && gettail(argv0) != argv0
  # endif
!           && vim_FullName(argv0, buf, MAXPATHL, TRUE) != FAIL)
!       val = buf;
      set_vim_var_string(VV_PROGPATH, val, -1);
  }
  
  #endif /* NO_VIM_MAIN */
--- 3533,3563 ----
  set_progpath(char_u *argv0)
  {
      char_u *val = argv0;
+ #ifdef WIN32
+     char_u *path = NULL;
+ #else
      char_u buf[MAXPATHL];
+ #endif
  
      /* A relative path containing a "/" will become invalid when using ":cd",
       * turn it into a full path.
       * On MS-Windows "vim.exe" is found in the current directory, thus also do
       * it when there is no path and the file exists. */
!     if (!mch_isFullName(argv0))
!     {
  # ifdef WIN32
!       if (mch_can_exe(argv0, &path, FALSE) && path != NULL)
!           val = path;
  # else
!       if (gettail(argv0) != argv0
!                          && vim_FullName(argv0, buf, MAXPATHL, TRUE) != FAIL)
!           val = buf;
  # endif
!     }
      set_vim_var_string(VV_PROGPATH, val, -1);
+ #ifdef WIN32
+     vim_free(path);
+ #endif
  }
  
  #endif /* NO_VIM_MAIN */
*** ../vim-8.0.0415/src/os_win32.c      2017-03-01 20:32:40.143105301 +0100
--- src/os_win32.c      2017-03-05 14:02:09.309516465 +0100
***************
*** 1902,1918 ****
  #endif
  
  /*
!  * Return TRUE if "name" is in $PATH.
   * TODO: Should somehow check if it's really executable.
   */
      static int
! executable_exists(char *name, char_u **path)
  {
      char      *dum;
      char      fname[_MAX_PATH];
      char      *curpath, *newpath;
      long      n;
  
  #ifdef FEAT_MBYTE
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
      {
--- 1902,1932 ----
  #endif
  
  /*
!  * If "use_path" is TRUE: Return TRUE if "name" is in $PATH.
!  * If "use_path" is FALSE: Return TRUE if "name" exists.
!  * When returning TRUE and "path" is not NULL save the path and set "*path" to
!  * the allocated memory.
   * TODO: Should somehow check if it's really executable.
   */
      static int
! executable_exists(char *name, char_u **path, int use_path)
  {
      char      *dum;
      char      fname[_MAX_PATH];
      char      *curpath, *newpath;
      long      n;
  
+     if (!use_path)
+     {
+       if (mch_getperm(name) != -1 && !mch_isdir(name))
+       {
+           if (path != NULL)
+               *path = vim_strsave((char_u *)name);
+           return TRUE;
+       }
+       return FALSE;
+     }
+ 
  #ifdef FEAT_MBYTE
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
      {
***************
*** 2038,2044 ****
            vimrun_path = (char *)vim_strsave(vimrun_location);
            s_dont_use_vimrun = FALSE;
        }
!       else if (executable_exists("vimrun.exe", NULL))
            s_dont_use_vimrun = FALSE;
  
        /* Don't give the warning for a missing vimrun.exe right now, but only
--- 2052,2058 ----
            vimrun_path = (char *)vim_strsave(vimrun_location);
            s_dont_use_vimrun = FALSE;
        }
!       else if (executable_exists("vimrun.exe", NULL, TRUE))
            s_dont_use_vimrun = FALSE;
  
        /* Don't give the warning for a missing vimrun.exe right now, but only
***************
*** 2052,2058 ****
       * If "finstr.exe" doesn't exist, use "grep -n" for 'grepprg'.
       * Otherwise the default "findstr /n" is used.
       */
!     if (!executable_exists("findstr.exe", NULL))
        set_option_value((char_u *)"grepprg", 0, (char_u *)"grep -n", 0);
  
  #ifdef FEAT_CLIPBOARD
--- 2066,2072 ----
       * If "finstr.exe" doesn't exist, use "grep -n" for 'grepprg'.
       * Otherwise the default "findstr /n" is used.
       */
!     if (!executable_exists("findstr.exe", NULL, TRUE))
        set_option_value((char_u *)"grepprg", 0, (char_u *)"grep -n", 0);
  
  #ifdef FEAT_CLIPBOARD
***************
*** 3358,3366 ****
  }
  
  /*
!  * Return 1 if "name" can be executed, 0 if not.
   * If "use_path" is FALSE only check if "name" is executable.
!  * Return -1 if unknown.
   */
      int
  mch_can_exe(char_u *name, char_u **path, int use_path)
--- 3372,3381 ----
  }
  
  /*
!  * Return TRUE if "name" can be executed, FALSE if not.
   * If "use_path" is FALSE only check if "name" is executable.
!  * When returning TRUE and "path" is not NULL save the path and set "*path" to
!  * the allocated memory.
   */
      int
  mch_can_exe(char_u *name, char_u **path, int use_path)
***************
*** 3371,3387 ****
  
      if (len >= _MAX_PATH)     /* safety check */
        return FALSE;
-     if (!use_path)
-     {
-       /* TODO: check if file is really executable. */
-       return mch_getperm(name) != -1 && !mch_isdir(name);
-     }
  
      /* If there already is an extension try using the name directly.  Also do
       * this with a Unix-shell like 'shell'. */
      if (vim_strchr(gettail(name), '.') != NULL
                               || strstr((char *)gettail(p_sh), "sh") != NULL)
!       if (executable_exists((char *)name, path))
            return TRUE;
  
      /*
--- 3386,3397 ----
  
      if (len >= _MAX_PATH)     /* safety check */
        return FALSE;
  
      /* If there already is an extension try using the name directly.  Also do
       * this with a Unix-shell like 'shell'. */
      if (vim_strchr(gettail(name), '.') != NULL
                               || strstr((char *)gettail(p_sh), "sh") != NULL)
!       if (executable_exists((char *)name, path, use_path))
            return TRUE;
  
      /*
***************
*** 3403,3409 ****
        }
        else
            copy_option_part(&p, buf + len, _MAX_PATH - len, ";");
!       if (executable_exists((char *)buf, path))
            return TRUE;
      }
      return FALSE;
--- 3413,3419 ----
        }
        else
            copy_option_part(&p, buf + len, _MAX_PATH - len, ";");
!       if (executable_exists((char *)buf, path, use_path))
            return TRUE;
      }
      return FALSE;
*** ../vim-8.0.0415/src/os_unix.c       2017-03-01 20:32:40.143105301 +0100
--- src/os_unix.c       2017-03-05 14:19:26.093729136 +0100
***************
*** 3103,3109 ****
        {
            if (path != NULL)
            {
!               if (name[0] == '.')
                    *path = FullName_save(name, TRUE);
                else
                    *path = vim_strsave(name);
--- 3103,3109 ----
        {
            if (path != NULL)
            {
!               if (name[0] != '/')
                    *path = FullName_save(name, TRUE);
                else
                    *path = vim_strsave(name);
***************
*** 3142,3148 ****
        {
            if (path != NULL)
            {
!               if (buf[0] == '.')
                    *path = FullName_save(buf, TRUE);
                else
                    *path = vim_strsave(buf);
--- 3142,3148 ----
        {
            if (path != NULL)
            {
!               if (buf[0] != '/')
                    *path = FullName_save(buf, TRUE);
                else
                    *path = vim_strsave(buf);
*** ../vim-8.0.0415/src/version.c       2017-03-05 13:48:04.667867105 +0100
--- src/version.c       2017-03-05 14:21:00.701013738 +0100
***************
*** 766,767 ****
--- 766,769 ----
  {   /* Add new patch number below this line */
+ /**/
+     416,
  /**/

-- 
Q: What is a patch 22?
A: A patch you need to include to make it possible to include patches.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui