Blame SOURCES/7.4.066

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