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