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