Karsten Hopp 0caad8
To: vim_dev@googlegroups.com
Karsten Hopp 0caad8
Subject: Patch 7.4.066
Karsten Hopp 0caad8
Fcc: outbox
Karsten Hopp 0caad8
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 0caad8
Mime-Version: 1.0
Karsten Hopp 0caad8
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 0caad8
Content-Transfer-Encoding: 8bit
Karsten Hopp 0caad8
------------
Karsten Hopp 0caad8
Karsten Hopp 0caad8
Patch 7.4.066
Karsten Hopp 0caad8
Problem:    MS-Windows: When there is a colon in the file name (sub-stream
Karsten Hopp 0caad8
            feature) the swap file name is wrong.
Karsten Hopp 0caad8
Solution:   Change the colon to "%". (Yasuhiro Matsumoto)
Karsten Hopp 0caad8
Files:      src/fileio.c, src/memline.c, src/misc1.c, src/proto/misc1.pro
Karsten Hopp 0caad8
Karsten Hopp 0caad8
Karsten Hopp 0caad8
*** ../vim-7.4.065/src/memline.c	2013-05-06 04:01:02.000000000 +0200
Karsten Hopp 0caad8
--- src/memline.c	2013-11-04 02:52:44.000000000 +0100
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 4014,4019 ****
Karsten Hopp 0caad8
--- 4014,4026 ----
Karsten Hopp 0caad8
      else
Karsten Hopp 0caad8
  	retval = concat_fnames(dname, tail, TRUE);
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
+ #ifdef WIN3264
Karsten Hopp 0caad8
+     if (retval != NULL)
Karsten Hopp 0caad8
+ 	for (t = gettail(retval); *t != NUL; mb_ptr_adv(t))
Karsten Hopp 0caad8
+ 	    if (*t == ':')
Karsten Hopp 0caad8
+ 		*t = '%';
Karsten Hopp 0caad8
+ #endif
Karsten Hopp 0caad8
+ 
Karsten Hopp 0caad8
      return retval;
Karsten Hopp 0caad8
  }
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 4137,4148 ****
Karsten Hopp 0caad8
  #ifndef SHORT_FNAME
Karsten Hopp 0caad8
      int		r;
Karsten Hopp 0caad8
  #endif
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
  #if !defined(SHORT_FNAME) \
Karsten Hopp 0caad8
! 		     && ((!defined(UNIX) && !defined(OS2)) || defined(ARCHIE))
Karsten Hopp 0caad8
  # define CREATE_DUMMY_FILE
Karsten Hopp 0caad8
      FILE	*dummyfd = NULL;
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
      /*
Karsten Hopp 0caad8
       * If we start editing a new file, e.g. "test.doc", which resides on an
Karsten Hopp 0caad8
       * MSDOS compatible filesystem, it is possible that the file
Karsten Hopp 0caad8
--- 4144,4172 ----
Karsten Hopp 0caad8
  #ifndef SHORT_FNAME
Karsten Hopp 0caad8
      int		r;
Karsten Hopp 0caad8
  #endif
Karsten Hopp 0caad8
+     char_u	*buf_fname = buf->b_fname;
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
  #if !defined(SHORT_FNAME) \
Karsten Hopp 0caad8
! 		&& ((!defined(UNIX) && !defined(OS2)) || defined(ARCHIE))
Karsten Hopp 0caad8
  # define CREATE_DUMMY_FILE
Karsten Hopp 0caad8
      FILE	*dummyfd = NULL;
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
+ # ifdef WIN3264
Karsten Hopp 0caad8
+     if (buf_fname != NULL && !mch_isFullName(buf_fname)
Karsten Hopp 0caad8
+ 				       && vim_strchr(gettail(buf_fname), ':'))
Karsten Hopp 0caad8
+     {
Karsten Hopp 0caad8
+ 	char_u *t;
Karsten Hopp 0caad8
+ 
Karsten Hopp 0caad8
+ 	buf_fname = vim_strsave(buf_fname);
Karsten Hopp 0caad8
+ 	if (buf_fname == NULL)
Karsten Hopp 0caad8
+ 	    buf_fname = buf->b_fname;
Karsten Hopp 0caad8
+ 	else
Karsten Hopp 0caad8
+ 	    for (t = gettail(buf_fname); *t != NUL; mb_ptr_adv(t))
Karsten Hopp 0caad8
+ 		if (*t == ':')
Karsten Hopp 0caad8
+ 		    *t = '%';
Karsten Hopp 0caad8
+     }
Karsten Hopp 0caad8
+ # endif
Karsten Hopp 0caad8
+ 
Karsten Hopp 0caad8
      /*
Karsten Hopp 0caad8
       * If we start editing a new file, e.g. "test.doc", which resides on an
Karsten Hopp 0caad8
       * MSDOS compatible filesystem, it is possible that the file
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 4150,4158 ****
Karsten Hopp 0caad8
       * this problem we temporarily create "test.doc".  Don't do this when the
Karsten Hopp 0caad8
       * check below for a 8.3 file name is used.
Karsten Hopp 0caad8
       */
Karsten Hopp 0caad8
!     if (!(buf->b_p_sn || buf->b_shortname) && buf->b_fname != NULL
Karsten Hopp 0caad8
! 					     && mch_getperm(buf->b_fname) < 0)
Karsten Hopp 0caad8
! 	dummyfd = mch_fopen((char *)buf->b_fname, "w");
Karsten Hopp 0caad8
  #endif
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
      /*
Karsten Hopp 0caad8
--- 4174,4182 ----
Karsten Hopp 0caad8
       * this problem we temporarily create "test.doc".  Don't do this when the
Karsten Hopp 0caad8
       * check below for a 8.3 file name is used.
Karsten Hopp 0caad8
       */
Karsten Hopp 0caad8
!     if (!(buf->b_p_sn || buf->b_shortname) && buf_fname != NULL
Karsten Hopp 0caad8
! 					     && mch_getperm(buf_fname) < 0)
Karsten Hopp 0caad8
! 	dummyfd = mch_fopen((char *)buf_fname, "w");
Karsten Hopp 0caad8
  #endif
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
      /*
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 4171,4177 ****
Karsten Hopp 0caad8
      if (dir_name == NULL)	    /* out of memory */
Karsten Hopp 0caad8
  	fname = NULL;
Karsten Hopp 0caad8
      else
Karsten Hopp 0caad8
! 	fname = makeswapname(buf->b_fname, buf->b_ffname, buf, dir_name);
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
      for (;;)
Karsten Hopp 0caad8
      {
Karsten Hopp 0caad8
--- 4195,4201 ----
Karsten Hopp 0caad8
      if (dir_name == NULL)	    /* out of memory */
Karsten Hopp 0caad8
  	fname = NULL;
Karsten Hopp 0caad8
      else
Karsten Hopp 0caad8
! 	fname = makeswapname(buf_fname, buf->b_ffname, buf, dir_name);
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
      for (;;)
Karsten Hopp 0caad8
      {
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 4204,4210 ****
Karsten Hopp 0caad8
  	     * It either contains two dots, is longer than 8 chars, or starts
Karsten Hopp 0caad8
  	     * with a dot.
Karsten Hopp 0caad8
  	     */
Karsten Hopp 0caad8
! 	    tail = gettail(buf->b_fname);
Karsten Hopp 0caad8
  	    if (       vim_strchr(tail, '.') != NULL
Karsten Hopp 0caad8
  		    || STRLEN(tail) > (size_t)8
Karsten Hopp 0caad8
  		    || *gettail(fname) == '.')
Karsten Hopp 0caad8
--- 4228,4234 ----
Karsten Hopp 0caad8
  	     * It either contains two dots, is longer than 8 chars, or starts
Karsten Hopp 0caad8
  	     * with a dot.
Karsten Hopp 0caad8
  	     */
Karsten Hopp 0caad8
! 	    tail = gettail(buf_fname);
Karsten Hopp 0caad8
  	    if (       vim_strchr(tail, '.') != NULL
Karsten Hopp 0caad8
  		    || STRLEN(tail) > (size_t)8
Karsten Hopp 0caad8
  		    || *gettail(fname) == '.')
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 4273,4279 ****
Karsten Hopp 0caad8
  		    {
Karsten Hopp 0caad8
  			buf->b_shortname = TRUE;
Karsten Hopp 0caad8
  			vim_free(fname);
Karsten Hopp 0caad8
! 			fname = makeswapname(buf->b_fname, buf->b_ffname,
Karsten Hopp 0caad8
  							       buf, dir_name);
Karsten Hopp 0caad8
  			continue;	/* try again with b_shortname set */
Karsten Hopp 0caad8
  		    }
Karsten Hopp 0caad8
--- 4297,4303 ----
Karsten Hopp 0caad8
  		    {
Karsten Hopp 0caad8
  			buf->b_shortname = TRUE;
Karsten Hopp 0caad8
  			vim_free(fname);
Karsten Hopp 0caad8
! 			fname = makeswapname(buf_fname, buf->b_ffname,
Karsten Hopp 0caad8
  							       buf, dir_name);
Karsten Hopp 0caad8
  			continue;	/* try again with b_shortname set */
Karsten Hopp 0caad8
  		    }
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 4344,4350 ****
Karsten Hopp 0caad8
  		{
Karsten Hopp 0caad8
  		    buf->b_shortname = TRUE;
Karsten Hopp 0caad8
  		    vim_free(fname);
Karsten Hopp 0caad8
! 		    fname = makeswapname(buf->b_fname, buf->b_ffname,
Karsten Hopp 0caad8
  							       buf, dir_name);
Karsten Hopp 0caad8
  		    continue;	    /* try again with '.' replaced with '_' */
Karsten Hopp 0caad8
  		}
Karsten Hopp 0caad8
--- 4368,4374 ----
Karsten Hopp 0caad8
  		{
Karsten Hopp 0caad8
  		    buf->b_shortname = TRUE;
Karsten Hopp 0caad8
  		    vim_free(fname);
Karsten Hopp 0caad8
! 		    fname = makeswapname(buf_fname, buf->b_ffname,
Karsten Hopp 0caad8
  							       buf, dir_name);
Karsten Hopp 0caad8
  		    continue;	    /* try again with '.' replaced with '_' */
Karsten Hopp 0caad8
  		}
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 4356,4362 ****
Karsten Hopp 0caad8
  	     * viewing a help file or when the path of the file is different
Karsten Hopp 0caad8
  	     * (happens when all .swp files are in one directory).
Karsten Hopp 0caad8
  	     */
Karsten Hopp 0caad8
! 	    if (!recoverymode && buf->b_fname != NULL
Karsten Hopp 0caad8
  				&& !buf->b_help && !(buf->b_flags & BF_DUMMY))
Karsten Hopp 0caad8
  	    {
Karsten Hopp 0caad8
  		int		fd;
Karsten Hopp 0caad8
--- 4380,4386 ----
Karsten Hopp 0caad8
  	     * viewing a help file or when the path of the file is different
Karsten Hopp 0caad8
  	     * (happens when all .swp files are in one directory).
Karsten Hopp 0caad8
  	     */
Karsten Hopp 0caad8
! 	    if (!recoverymode && buf_fname != NULL
Karsten Hopp 0caad8
  				&& !buf->b_help && !(buf->b_flags & BF_DUMMY))
Karsten Hopp 0caad8
  	    {
Karsten Hopp 0caad8
  		int		fd;
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 4433,4439 ****
Karsten Hopp 0caad8
  		    {
Karsten Hopp 0caad8
  			fclose(dummyfd);
Karsten Hopp 0caad8
  			dummyfd = NULL;
Karsten Hopp 0caad8
! 			mch_remove(buf->b_fname);
Karsten Hopp 0caad8
  			did_use_dummy = TRUE;
Karsten Hopp 0caad8
  		    }
Karsten Hopp 0caad8
  #endif
Karsten Hopp 0caad8
--- 4457,4463 ----
Karsten Hopp 0caad8
  		    {
Karsten Hopp 0caad8
  			fclose(dummyfd);
Karsten Hopp 0caad8
  			dummyfd = NULL;
Karsten Hopp 0caad8
! 			mch_remove(buf_fname);
Karsten Hopp 0caad8
  			did_use_dummy = TRUE;
Karsten Hopp 0caad8
  		    }
Karsten Hopp 0caad8
  #endif
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 4448,4454 ****
Karsten Hopp 0caad8
  		     * user anyway.
Karsten Hopp 0caad8
  		     */
Karsten Hopp 0caad8
  		    if (swap_exists_action != SEA_NONE
Karsten Hopp 0caad8
! 			    && has_autocmd(EVENT_SWAPEXISTS, buf->b_fname, buf))
Karsten Hopp 0caad8
  			choice = do_swapexists(buf, fname);
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
  		    if (choice == 0)
Karsten Hopp 0caad8
--- 4472,4478 ----
Karsten Hopp 0caad8
  		     * user anyway.
Karsten Hopp 0caad8
  		     */
Karsten Hopp 0caad8
  		    if (swap_exists_action != SEA_NONE
Karsten Hopp 0caad8
! 			    && has_autocmd(EVENT_SWAPEXISTS, buf_fname, buf))
Karsten Hopp 0caad8
  			choice = do_swapexists(buf, fname);
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
  		    if (choice == 0)
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 4549,4555 ****
Karsten Hopp 0caad8
  #ifdef CREATE_DUMMY_FILE
Karsten Hopp 0caad8
  		    /* Going to try another name, need the dummy file again. */
Karsten Hopp 0caad8
  		    if (did_use_dummy)
Karsten Hopp 0caad8
! 			dummyfd = mch_fopen((char *)buf->b_fname, "w");
Karsten Hopp 0caad8
  #endif
Karsten Hopp 0caad8
  		}
Karsten Hopp 0caad8
  	    }
Karsten Hopp 0caad8
--- 4573,4579 ----
Karsten Hopp 0caad8
  #ifdef CREATE_DUMMY_FILE
Karsten Hopp 0caad8
  		    /* Going to try another name, need the dummy file again. */
Karsten Hopp 0caad8
  		    if (did_use_dummy)
Karsten Hopp 0caad8
! 			dummyfd = mch_fopen((char *)buf_fname, "w");
Karsten Hopp 0caad8
  #endif
Karsten Hopp 0caad8
  		}
Karsten Hopp 0caad8
  	    }
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 4581,4589 ****
Karsten Hopp 0caad8
      if (dummyfd != NULL)	/* file has been created temporarily */
Karsten Hopp 0caad8
      {
Karsten Hopp 0caad8
  	fclose(dummyfd);
Karsten Hopp 0caad8
! 	mch_remove(buf->b_fname);
Karsten Hopp 0caad8
      }
Karsten Hopp 0caad8
  #endif
Karsten Hopp 0caad8
      return fname;
Karsten Hopp 0caad8
  }
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
--- 4605,4617 ----
Karsten Hopp 0caad8
      if (dummyfd != NULL)	/* file has been created temporarily */
Karsten Hopp 0caad8
      {
Karsten Hopp 0caad8
  	fclose(dummyfd);
Karsten Hopp 0caad8
! 	mch_remove(buf_fname);
Karsten Hopp 0caad8
      }
Karsten Hopp 0caad8
  #endif
Karsten Hopp 0caad8
+ #ifdef WIN3264
Karsten Hopp 0caad8
+     if (buf_fname != buf->b_fname)
Karsten Hopp 0caad8
+ 	vim_free(buf_fname);
Karsten Hopp 0caad8
+ #endif
Karsten Hopp 0caad8
      return fname;
Karsten Hopp 0caad8
  }
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
*** ../vim-7.4.065/src/misc1.c	2013-10-06 17:46:48.000000000 +0200
Karsten Hopp 0caad8
--- src/misc1.c	2013-11-04 02:44:28.000000000 +0100
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 4808,4816 ****
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
      if (fname == NULL)
Karsten Hopp 0caad8
  	return (char_u *)"";
Karsten Hopp 0caad8
!     for (p1 = p2 = fname; *p2; )	/* find last part of path */
Karsten Hopp 0caad8
      {
Karsten Hopp 0caad8
! 	if (vim_ispathsep(*p2))
Karsten Hopp 0caad8
  	    p1 = p2 + 1;
Karsten Hopp 0caad8
  	mb_ptr_adv(p2);
Karsten Hopp 0caad8
      }
Karsten Hopp 0caad8
--- 4808,4816 ----
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
      if (fname == NULL)
Karsten Hopp 0caad8
  	return (char_u *)"";
Karsten Hopp 0caad8
!     for (p1 = p2 = get_past_head(fname); *p2; )	/* find last part of path */
Karsten Hopp 0caad8
      {
Karsten Hopp 0caad8
! 	if (vim_ispathsep_nocolon(*p2))
Karsten Hopp 0caad8
  	    p1 = p2 + 1;
Karsten Hopp 0caad8
  	mb_ptr_adv(p2);
Karsten Hopp 0caad8
      }
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 4929,4935 ****
Karsten Hopp 0caad8
  }
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
  /*
Karsten Hopp 0caad8
!  * return TRUE if 'c' is a path separator.
Karsten Hopp 0caad8
   */
Karsten Hopp 0caad8
      int
Karsten Hopp 0caad8
  vim_ispathsep(c)
Karsten Hopp 0caad8
--- 4929,4936 ----
Karsten Hopp 0caad8
  }
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
  /*
Karsten Hopp 0caad8
!  * Return TRUE if 'c' is a path separator.
Karsten Hopp 0caad8
!  * Note that for MS-Windows this includes the colon.
Karsten Hopp 0caad8
   */
Karsten Hopp 0caad8
      int
Karsten Hopp 0caad8
  vim_ispathsep(c)
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 4952,4957 ****
Karsten Hopp 0caad8
--- 4953,4972 ----
Karsten Hopp 0caad8
  #endif
Karsten Hopp 0caad8
  }
Karsten Hopp 0caad8
  
Karsten Hopp 0caad8
+ /*
Karsten Hopp 0caad8
+  * Like vim_ispathsep(c), but exclude the colon for MS-Windows.
Karsten Hopp 0caad8
+  */
Karsten Hopp 0caad8
+     int
Karsten Hopp 0caad8
+ vim_ispathsep_nocolon(c)
Karsten Hopp 0caad8
+     int c;
Karsten Hopp 0caad8
+ {
Karsten Hopp 0caad8
+     return vim_ispathsep(c)
Karsten Hopp 0caad8
+ #ifdef BACKSLASH_IN_FILENAME
Karsten Hopp 0caad8
+ 	&& c != ':'
Karsten Hopp 0caad8
+ #endif
Karsten Hopp 0caad8
+ 	;
Karsten Hopp 0caad8
+ }
Karsten Hopp 0caad8
+ 
Karsten Hopp 0caad8
  #if defined(FEAT_SEARCHPATH) || defined(PROTO)
Karsten Hopp 0caad8
  /*
Karsten Hopp 0caad8
   * return TRUE if 'c' is a path list separator.
Karsten Hopp 0caad8
*** ../vim-7.4.065/src/proto/misc1.pro	2013-08-10 13:37:20.000000000 +0200
Karsten Hopp 0caad8
--- src/proto/misc1.pro	2013-11-04 02:44:30.000000000 +0100
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 69,74 ****
Karsten Hopp 0caad8
--- 69,75 ----
Karsten Hopp 0caad8
  char_u *getnextcomp __ARGS((char_u *fname));
Karsten Hopp 0caad8
  char_u *get_past_head __ARGS((char_u *path));
Karsten Hopp 0caad8
  int vim_ispathsep __ARGS((int c));
Karsten Hopp 0caad8
+ int vim_ispathsep_nocolon __ARGS((int c));
Karsten Hopp 0caad8
  int vim_ispathlistsep __ARGS((int c));
Karsten Hopp 0caad8
  void shorten_dir __ARGS((char_u *str));
Karsten Hopp 0caad8
  int dir_of_file_exists __ARGS((char_u *fname));
Karsten Hopp 0caad8
*** ../vim-7.4.065/src/version.c	2013-11-04 02:00:55.000000000 +0100
Karsten Hopp 0caad8
--- src/version.c	2013-11-04 02:50:35.000000000 +0100
Karsten Hopp 0caad8
***************
Karsten Hopp 0caad8
*** 740,741 ****
Karsten Hopp 0caad8
--- 740,743 ----
Karsten Hopp 0caad8
  {   /* Add new patch number below this line */
Karsten Hopp 0caad8
+ /**/
Karsten Hopp 0caad8
+     66,
Karsten Hopp 0caad8
  /**/
Karsten Hopp 0caad8
Karsten Hopp 0caad8
-- 
Karsten Hopp 0caad8
Females are strictly forbidden to appear unshaven in public.
Karsten Hopp 0caad8
		[real standing law in New Mexico, United States of America]
Karsten Hopp 0caad8
Karsten Hopp 0caad8
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 0caad8
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 0caad8
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 0caad8
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///