Karsten Hopp 17c029
To: vim-dev@vim.org
Karsten Hopp 17c029
Subject: patch 7.0.208
Karsten Hopp 17c029
Fcc: outbox
Karsten Hopp 17c029
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 17c029
Mime-Version: 1.0
Karsten Hopp 17c029
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 17c029
Content-Transfer-Encoding: 8bit
Karsten Hopp 17c029
------------
Karsten Hopp 17c029
Karsten Hopp 17c029
Patch 7.0.208 (after 7.0.171 and 7.0.180)
Karsten Hopp 17c029
Problem:    VMS: changes to path handling cause more trouble than they solve.
Karsten Hopp 17c029
Solution:   Revert changes.
Karsten Hopp 17c029
Files:	    src/buffer.c, src/memline.c, src/os_unix.c
Karsten Hopp 17c029
Karsten Hopp 17c029
Karsten Hopp 17c029
*** ../vim-7.0.207/src/buffer.c	Tue Nov 28 17:44:51 2006
Karsten Hopp 17c029
--- src/buffer.c	Mon Mar  5 21:34:41 2007
Karsten Hopp 17c029
***************
Karsten Hopp 17c029
*** 4145,4157 ****
Karsten Hopp 17c029
      /*
Karsten Hopp 17c029
       * Force expanding the path always for Unix, because symbolic links may
Karsten Hopp 17c029
       * mess up the full path name, even though it starts with a '/'.
Karsten Hopp 17c029
-      * Also expand always for VMS, it may have alternate paths that need to be
Karsten Hopp 17c029
-      * resolved.
Karsten Hopp 17c029
       * Also expand when there is ".." in the file name, try to remove it,
Karsten Hopp 17c029
       * because "c:/src/../README" is equal to "c:/README".
Karsten Hopp 17c029
       * For MS-Windows also expand names like "longna~1" to "longname".
Karsten Hopp 17c029
       */
Karsten Hopp 17c029
! #if defined(UNIX) || defined(VMS)
Karsten Hopp 17c029
      return FullName_save(fname, TRUE);
Karsten Hopp 17c029
  #else
Karsten Hopp 17c029
      if (!vim_isAbsName(fname) || strstr((char *)fname, "..") != NULL
Karsten Hopp 17c029
--- 4145,4155 ----
Karsten Hopp 17c029
      /*
Karsten Hopp 17c029
       * Force expanding the path always for Unix, because symbolic links may
Karsten Hopp 17c029
       * mess up the full path name, even though it starts with a '/'.
Karsten Hopp 17c029
       * Also expand when there is ".." in the file name, try to remove it,
Karsten Hopp 17c029
       * because "c:/src/../README" is equal to "c:/README".
Karsten Hopp 17c029
       * For MS-Windows also expand names like "longna~1" to "longname".
Karsten Hopp 17c029
       */
Karsten Hopp 17c029
! #ifdef UNIX
Karsten Hopp 17c029
      return FullName_save(fname, TRUE);
Karsten Hopp 17c029
  #else
Karsten Hopp 17c029
      if (!vim_isAbsName(fname) || strstr((char *)fname, "..") != NULL
Karsten Hopp 17c029
*** ../vim-7.0.207/src/memline.c	Tue Feb 13 04:03:05 2007
Karsten Hopp 17c029
--- src/memline.c	Mon Mar  5 21:34:41 2007
Karsten Hopp 17c029
***************
Karsten Hopp 17c029
*** 3592,3600 ****
Karsten Hopp 17c029
  #else
Karsten Hopp 17c029
  	    (buf->b_p_sn || buf->b_shortname),
Karsten Hopp 17c029
  #endif
Karsten Hopp 17c029
! #if defined(VMS) || defined(RISCOS)
Karsten Hopp 17c029
! 	    /* Avoid problems if fname has special chars, eg <Wimp$Scrap>.
Karsten Hopp 17c029
! 	     * For VMS always use full path for swapfile. */
Karsten Hopp 17c029
  	    ffname,
Karsten Hopp 17c029
  #else
Karsten Hopp 17c029
  # ifdef HAVE_READLINK
Karsten Hopp 17c029
--- 3592,3599 ----
Karsten Hopp 17c029
  #else
Karsten Hopp 17c029
  	    (buf->b_p_sn || buf->b_shortname),
Karsten Hopp 17c029
  #endif
Karsten Hopp 17c029
! #ifdef RISCOS
Karsten Hopp 17c029
! 	    /* Avoid problems if fname has special chars, eg <Wimp$Scrap> */
Karsten Hopp 17c029
  	    ffname,
Karsten Hopp 17c029
  #else
Karsten Hopp 17c029
  # ifdef HAVE_READLINK
Karsten Hopp 17c029
*** ../vim-7.0.207/src/os_unix.c	Tue Feb 27 16:51:07 2007
Karsten Hopp 17c029
--- src/os_unix.c	Mon Mar  5 21:40:31 2007
Karsten Hopp 17c029
***************
Karsten Hopp 17c029
*** 2214,2262 ****
Karsten Hopp 17c029
      int		len;
Karsten Hopp 17c029
      int		force;		/* also expand when already absolute path */
Karsten Hopp 17c029
  {
Karsten Hopp 17c029
- #ifdef VMS
Karsten Hopp 17c029
-     /*
Karsten Hopp 17c029
-      * VMS does this in a completely different way.
Karsten Hopp 17c029
-      *
Karsten Hopp 17c029
-      * By default a file found in a complex path is written to the first
Karsten Hopp 17c029
-      * directory in the path and not to the original directory.  This
Karsten Hopp 17c029
-      * behaviour should be avoided for the existing files and we need to find
Karsten Hopp 17c029
-      * the exact path of the edited file.
Karsten Hopp 17c029
-      */
Karsten Hopp 17c029
-     {
Karsten Hopp 17c029
- 	char_u	*fixed_fname = vms_fixfilename(fname);
Karsten Hopp 17c029
- 	int	fd = mch_open((char *)fixed_fname, O_RDONLY | O_EXTRA, 0);
Karsten Hopp 17c029
- 
Karsten Hopp 17c029
- 	if (fd > 0)
Karsten Hopp 17c029
- 	{
Karsten Hopp 17c029
- 	    char nbuf[MAXNAMLEN];
Karsten Hopp 17c029
- 
Karsten Hopp 17c029
- 	    /* File exists, use getname() to get the real name. */
Karsten Hopp 17c029
- 	    if (getname(fd, nbuf))
Karsten Hopp 17c029
- 		vim_strncpy(fixed_fname, (char_u *)nbuf, (size_t)(len - 1));
Karsten Hopp 17c029
- 	    close(fd);
Karsten Hopp 17c029
- 	}
Karsten Hopp 17c029
- 
Karsten Hopp 17c029
- 	if (STRLEN(fixed_fname) >= len)
Karsten Hopp 17c029
- 	    return FAIL;
Karsten Hopp 17c029
- 
Karsten Hopp 17c029
- 	STRCPY(buf, fixed_fname);
Karsten Hopp 17c029
-     }
Karsten Hopp 17c029
- 
Karsten Hopp 17c029
- #else /* not VMS */
Karsten Hopp 17c029
- 
Karsten Hopp 17c029
      int		l;
Karsten Hopp 17c029
! # ifdef OS2
Karsten Hopp 17c029
      int		only_drive;	/* file name is only a drive letter */
Karsten Hopp 17c029
! # endif
Karsten Hopp 17c029
! # ifdef HAVE_FCHDIR
Karsten Hopp 17c029
      int		fd = -1;
Karsten Hopp 17c029
      static int	dont_fchdir = FALSE;	/* TRUE when fchdir() doesn't work */
Karsten Hopp 17c029
! # endif
Karsten Hopp 17c029
      char_u	olddir[MAXPATHL];
Karsten Hopp 17c029
      char_u	*p;
Karsten Hopp 17c029
      int		retval = OK;
Karsten Hopp 17c029
  
Karsten Hopp 17c029
      /* expand it if forced or not an absolute path */
Karsten Hopp 17c029
      if (force || !mch_isFullName(fname))
Karsten Hopp 17c029
      {
Karsten Hopp 17c029
--- 2214,2235 ----
Karsten Hopp 17c029
      int		len;
Karsten Hopp 17c029
      int		force;		/* also expand when already absolute path */
Karsten Hopp 17c029
  {
Karsten Hopp 17c029
      int		l;
Karsten Hopp 17c029
! #ifdef OS2
Karsten Hopp 17c029
      int		only_drive;	/* file name is only a drive letter */
Karsten Hopp 17c029
! #endif
Karsten Hopp 17c029
! #ifdef HAVE_FCHDIR
Karsten Hopp 17c029
      int		fd = -1;
Karsten Hopp 17c029
      static int	dont_fchdir = FALSE;	/* TRUE when fchdir() doesn't work */
Karsten Hopp 17c029
! #endif
Karsten Hopp 17c029
      char_u	olddir[MAXPATHL];
Karsten Hopp 17c029
      char_u	*p;
Karsten Hopp 17c029
      int		retval = OK;
Karsten Hopp 17c029
  
Karsten Hopp 17c029
+ #ifdef VMS
Karsten Hopp 17c029
+     fname = vms_fixfilename(fname);
Karsten Hopp 17c029
+ #endif
Karsten Hopp 17c029
+ 
Karsten Hopp 17c029
      /* expand it if forced or not an absolute path */
Karsten Hopp 17c029
      if (force || !mch_isFullName(fname))
Karsten Hopp 17c029
      {
Karsten Hopp 17c029
***************
Karsten Hopp 17c029
*** 2265,2280 ****
Karsten Hopp 17c029
  	 * and then do the getwd() (and get back to where we were).
Karsten Hopp 17c029
  	 * This will get the correct path name with "../" things.
Karsten Hopp 17c029
  	 */
Karsten Hopp 17c029
! # ifdef OS2
Karsten Hopp 17c029
  	only_drive = 0;
Karsten Hopp 17c029
  	if (((p = vim_strrchr(fname, '/')) != NULL)
Karsten Hopp 17c029
  		|| ((p = vim_strrchr(fname, '\\')) != NULL)
Karsten Hopp 17c029
  		|| (((p = vim_strchr(fname,  ':')) != NULL) && ++only_drive))
Karsten Hopp 17c029
! # else
Karsten Hopp 17c029
  	if ((p = vim_strrchr(fname, '/')) != NULL)
Karsten Hopp 17c029
! # endif
Karsten Hopp 17c029
  	{
Karsten Hopp 17c029
! # ifdef HAVE_FCHDIR
Karsten Hopp 17c029
  	    /*
Karsten Hopp 17c029
  	     * Use fchdir() if possible, it's said to be faster and more
Karsten Hopp 17c029
  	     * reliable.  But on SunOS 4 it might not work.  Check this by
Karsten Hopp 17c029
--- 2238,2253 ----
Karsten Hopp 17c029
  	 * and then do the getwd() (and get back to where we were).
Karsten Hopp 17c029
  	 * This will get the correct path name with "../" things.
Karsten Hopp 17c029
  	 */
Karsten Hopp 17c029
! #ifdef OS2
Karsten Hopp 17c029
  	only_drive = 0;
Karsten Hopp 17c029
  	if (((p = vim_strrchr(fname, '/')) != NULL)
Karsten Hopp 17c029
  		|| ((p = vim_strrchr(fname, '\\')) != NULL)
Karsten Hopp 17c029
  		|| (((p = vim_strchr(fname,  ':')) != NULL) && ++only_drive))
Karsten Hopp 17c029
! #else
Karsten Hopp 17c029
  	if ((p = vim_strrchr(fname, '/')) != NULL)
Karsten Hopp 17c029
! #endif
Karsten Hopp 17c029
  	{
Karsten Hopp 17c029
! #ifdef HAVE_FCHDIR
Karsten Hopp 17c029
  	    /*
Karsten Hopp 17c029
  	     * Use fchdir() if possible, it's said to be faster and more
Karsten Hopp 17c029
  	     * reliable.  But on SunOS 4 it might not work.  Check this by
Karsten Hopp 17c029
***************
Karsten Hopp 17c029
*** 2290,2303 ****
Karsten Hopp 17c029
  		    dont_fchdir = TRUE;	    /* don't try again */
Karsten Hopp 17c029
  		}
Karsten Hopp 17c029
  	    }
Karsten Hopp 17c029
! # endif
Karsten Hopp 17c029
  
Karsten Hopp 17c029
  	    /* Only change directory when we are sure we can return to where
Karsten Hopp 17c029
  	     * we are now.  After doing "su" chdir(".") might not work. */
Karsten Hopp 17c029
  	    if (
Karsten Hopp 17c029
! # ifdef HAVE_FCHDIR
Karsten Hopp 17c029
  		fd < 0 &&
Karsten Hopp 17c029
! # endif
Karsten Hopp 17c029
  			(mch_dirname(olddir, MAXPATHL) == FAIL
Karsten Hopp 17c029
  					   || mch_chdir((char *)olddir) != 0))
Karsten Hopp 17c029
  	    {
Karsten Hopp 17c029
--- 2263,2276 ----
Karsten Hopp 17c029
  		    dont_fchdir = TRUE;	    /* don't try again */
Karsten Hopp 17c029
  		}
Karsten Hopp 17c029
  	    }
Karsten Hopp 17c029
! #endif
Karsten Hopp 17c029
  
Karsten Hopp 17c029
  	    /* Only change directory when we are sure we can return to where
Karsten Hopp 17c029
  	     * we are now.  After doing "su" chdir(".") might not work. */
Karsten Hopp 17c029
  	    if (
Karsten Hopp 17c029
! #ifdef HAVE_FCHDIR
Karsten Hopp 17c029
  		fd < 0 &&
Karsten Hopp 17c029
! #endif
Karsten Hopp 17c029
  			(mch_dirname(olddir, MAXPATHL) == FAIL
Karsten Hopp 17c029
  					   || mch_chdir((char *)olddir) != 0))
Karsten Hopp 17c029
  	    {
Karsten Hopp 17c029
***************
Karsten Hopp 17c029
*** 2306,2312 ****
Karsten Hopp 17c029
  	    }
Karsten Hopp 17c029
  	    else
Karsten Hopp 17c029
  	    {
Karsten Hopp 17c029
! # ifdef OS2
Karsten Hopp 17c029
  		/*
Karsten Hopp 17c029
  		 * compensate for case where ':' from "D:" was the only
Karsten Hopp 17c029
  		 * path separator detected in the file name; the _next_
Karsten Hopp 17c029
--- 2279,2285 ----
Karsten Hopp 17c029
  	    }
Karsten Hopp 17c029
  	    else
Karsten Hopp 17c029
  	    {
Karsten Hopp 17c029
! #ifdef OS2
Karsten Hopp 17c029
  		/*
Karsten Hopp 17c029
  		 * compensate for case where ':' from "D:" was the only
Karsten Hopp 17c029
  		 * path separator detected in the file name; the _next_
Karsten Hopp 17c029
***************
Karsten Hopp 17c029
*** 2314,2320 ****
Karsten Hopp 17c029
  		 */
Karsten Hopp 17c029
  		if (only_drive)
Karsten Hopp 17c029
  		    p++;
Karsten Hopp 17c029
! # endif
Karsten Hopp 17c029
  		/* The directory is copied into buf[], to be able to remove
Karsten Hopp 17c029
  		 * the file name without changing it (could be a string in
Karsten Hopp 17c029
  		 * read-only memory) */
Karsten Hopp 17c029
--- 2287,2293 ----
Karsten Hopp 17c029
  		 */
Karsten Hopp 17c029
  		if (only_drive)
Karsten Hopp 17c029
  		    p++;
Karsten Hopp 17c029
! #endif
Karsten Hopp 17c029
  		/* The directory is copied into buf[], to be able to remove
Karsten Hopp 17c029
  		 * the file name without changing it (could be a string in
Karsten Hopp 17c029
  		 * read-only memory) */
Karsten Hopp 17c029
***************
Karsten Hopp 17c029
*** 2329,2342 ****
Karsten Hopp 17c029
  			fname = p + 1;
Karsten Hopp 17c029
  		    *buf = NUL;
Karsten Hopp 17c029
  		}
Karsten Hopp 17c029
! # ifdef OS2
Karsten Hopp 17c029
  		if (only_drive)
Karsten Hopp 17c029
  		{
Karsten Hopp 17c029
  		    p--;
Karsten Hopp 17c029
  		    if (retval != FAIL)
Karsten Hopp 17c029
  			fname--;
Karsten Hopp 17c029
  		}
Karsten Hopp 17c029
! # endif
Karsten Hopp 17c029
  	    }
Karsten Hopp 17c029
  	}
Karsten Hopp 17c029
  	if (mch_dirname(buf, len) == FAIL)
Karsten Hopp 17c029
--- 2302,2315 ----
Karsten Hopp 17c029
  			fname = p + 1;
Karsten Hopp 17c029
  		    *buf = NUL;
Karsten Hopp 17c029
  		}
Karsten Hopp 17c029
! #ifdef OS2
Karsten Hopp 17c029
  		if (only_drive)
Karsten Hopp 17c029
  		{
Karsten Hopp 17c029
  		    p--;
Karsten Hopp 17c029
  		    if (retval != FAIL)
Karsten Hopp 17c029
  			fname--;
Karsten Hopp 17c029
  		}
Karsten Hopp 17c029
! #endif
Karsten Hopp 17c029
  	    }
Karsten Hopp 17c029
  	}
Karsten Hopp 17c029
  	if (mch_dirname(buf, len) == FAIL)
Karsten Hopp 17c029
***************
Karsten Hopp 17c029
*** 2346,2359 ****
Karsten Hopp 17c029
  	}
Karsten Hopp 17c029
  	if (p != NULL)
Karsten Hopp 17c029
  	{
Karsten Hopp 17c029
! # ifdef HAVE_FCHDIR
Karsten Hopp 17c029
  	    if (fd >= 0)
Karsten Hopp 17c029
  	    {
Karsten Hopp 17c029
  		l = fchdir(fd);
Karsten Hopp 17c029
  		close(fd);
Karsten Hopp 17c029
  	    }
Karsten Hopp 17c029
  	    else
Karsten Hopp 17c029
! # endif
Karsten Hopp 17c029
  		l = mch_chdir((char *)olddir);
Karsten Hopp 17c029
  	    if (l != 0)
Karsten Hopp 17c029
  		EMSG(_(e_prev_dir));
Karsten Hopp 17c029
--- 2319,2332 ----
Karsten Hopp 17c029
  	}
Karsten Hopp 17c029
  	if (p != NULL)
Karsten Hopp 17c029
  	{
Karsten Hopp 17c029
! #ifdef HAVE_FCHDIR
Karsten Hopp 17c029
  	    if (fd >= 0)
Karsten Hopp 17c029
  	    {
Karsten Hopp 17c029
  		l = fchdir(fd);
Karsten Hopp 17c029
  		close(fd);
Karsten Hopp 17c029
  	    }
Karsten Hopp 17c029
  	    else
Karsten Hopp 17c029
! #endif
Karsten Hopp 17c029
  		l = mch_chdir((char *)olddir);
Karsten Hopp 17c029
  	    if (l != 0)
Karsten Hopp 17c029
  		EMSG(_(e_prev_dir));
Karsten Hopp 17c029
***************
Karsten Hopp 17c029
*** 2362,2373 ****
Karsten Hopp 17c029
--- 2335,2348 ----
Karsten Hopp 17c029
  	l = STRLEN(buf);
Karsten Hopp 17c029
  	if (l >= len)
Karsten Hopp 17c029
  	    retval = FAIL;
Karsten Hopp 17c029
+ #ifndef VMS
Karsten Hopp 17c029
  	else
Karsten Hopp 17c029
  	{
Karsten Hopp 17c029
  	    if (l > 0 && buf[l - 1] != '/' && *fname != NUL
Karsten Hopp 17c029
  						   && STRCMP(fname, ".") != 0)
Karsten Hopp 17c029
  		STRCAT(buf, "/");
Karsten Hopp 17c029
  	}
Karsten Hopp 17c029
+ #endif
Karsten Hopp 17c029
      }
Karsten Hopp 17c029
  
Karsten Hopp 17c029
      /* Catch file names which are too long. */
Karsten Hopp 17c029
***************
Karsten Hopp 17c029
*** 2377,2384 ****
Karsten Hopp 17c029
      /* Do not append ".", "/dir/." is equal to "/dir". */
Karsten Hopp 17c029
      if (STRCMP(fname, ".") != 0)
Karsten Hopp 17c029
  	STRCAT(buf, fname);
Karsten Hopp 17c029
- 
Karsten Hopp 17c029
- #endif /* VMS */
Karsten Hopp 17c029
  
Karsten Hopp 17c029
      return OK;
Karsten Hopp 17c029
  }
Karsten Hopp 17c029
--- 2352,2357 ----
Karsten Hopp 17c029
*** ../vim-7.0.207/src/version.c	Sun Mar  4 21:25:44 2007
Karsten Hopp 17c029
--- src/version.c	Tue Mar  6 20:22:52 2007
Karsten Hopp 17c029
***************
Karsten Hopp 17c029
*** 668,669 ****
Karsten Hopp 17c029
--- 668,671 ----
Karsten Hopp 17c029
  {   /* Add new patch number below this line */
Karsten Hopp 17c029
+ /**/
Karsten Hopp 17c029
+     208,
Karsten Hopp 17c029
  /**/
Karsten Hopp 17c029
Karsten Hopp 17c029
-- 
Karsten Hopp 17c029
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 17c029
262. Your computer has it's own phone line - but your daughter doesn't.
Karsten Hopp 17c029
Karsten Hopp 17c029
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 17c029
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 17c029
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 17c029
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///