1
0
forked from aniani/vim

updated for version 7.4.066

Problem:    MS-Windows: When there is a colon in the file name (sub-stream
            feature) the swap file name is wrong.
Solution:   Change the colon to "%". (Yasuhiro Matsumoto)
This commit is contained in:
Bram Moolenaar
2013-11-04 02:54:12 +01:00
parent 332a2cadcd
commit 69c3500f96
4 changed files with 62 additions and 16 deletions

View File

@@ -4014,6 +4014,13 @@ get_file_in_dir(fname, dname)
else else
retval = concat_fnames(dname, tail, TRUE); retval = concat_fnames(dname, tail, TRUE);
#ifdef WIN3264
if (retval != NULL)
for (t = gettail(retval); *t != NUL; mb_ptr_adv(t))
if (*t == ':')
*t = '%';
#endif
return retval; return retval;
} }
@@ -4137,12 +4144,29 @@ findswapname(buf, dirp, old_fname)
#ifndef SHORT_FNAME #ifndef SHORT_FNAME
int r; int r;
#endif #endif
char_u *buf_fname = buf->b_fname;
#if !defined(SHORT_FNAME) \ #if !defined(SHORT_FNAME) \
&& ((!defined(UNIX) && !defined(OS2)) || defined(ARCHIE)) && ((!defined(UNIX) && !defined(OS2)) || defined(ARCHIE))
# define CREATE_DUMMY_FILE # define CREATE_DUMMY_FILE
FILE *dummyfd = NULL; FILE *dummyfd = NULL;
# ifdef WIN3264
if (buf_fname != NULL && !mch_isFullName(buf_fname)
&& vim_strchr(gettail(buf_fname), ':'))
{
char_u *t;
buf_fname = vim_strsave(buf_fname);
if (buf_fname == NULL)
buf_fname = buf->b_fname;
else
for (t = gettail(buf_fname); *t != NUL; mb_ptr_adv(t))
if (*t == ':')
*t = '%';
}
# endif
/* /*
* If we start editing a new file, e.g. "test.doc", which resides on an * If we start editing a new file, e.g. "test.doc", which resides on an
* MSDOS compatible filesystem, it is possible that the file * MSDOS compatible filesystem, it is possible that the file
@@ -4150,9 +4174,9 @@ findswapname(buf, dirp, old_fname)
* this problem we temporarily create "test.doc". Don't do this when the * this problem we temporarily create "test.doc". Don't do this when the
* check below for a 8.3 file name is used. * check below for a 8.3 file name is used.
*/ */
if (!(buf->b_p_sn || buf->b_shortname) && buf->b_fname != NULL if (!(buf->b_p_sn || buf->b_shortname) && buf_fname != NULL
&& mch_getperm(buf->b_fname) < 0) && mch_getperm(buf_fname) < 0)
dummyfd = mch_fopen((char *)buf->b_fname, "w"); dummyfd = mch_fopen((char *)buf_fname, "w");
#endif #endif
/* /*
@@ -4171,7 +4195,7 @@ findswapname(buf, dirp, old_fname)
if (dir_name == NULL) /* out of memory */ if (dir_name == NULL) /* out of memory */
fname = NULL; fname = NULL;
else else
fname = makeswapname(buf->b_fname, buf->b_ffname, buf, dir_name); fname = makeswapname(buf_fname, buf->b_ffname, buf, dir_name);
for (;;) for (;;)
{ {
@@ -4204,7 +4228,7 @@ findswapname(buf, dirp, old_fname)
* It either contains two dots, is longer than 8 chars, or starts * It either contains two dots, is longer than 8 chars, or starts
* with a dot. * with a dot.
*/ */
tail = gettail(buf->b_fname); tail = gettail(buf_fname);
if ( vim_strchr(tail, '.') != NULL if ( vim_strchr(tail, '.') != NULL
|| STRLEN(tail) > (size_t)8 || STRLEN(tail) > (size_t)8
|| *gettail(fname) == '.') || *gettail(fname) == '.')
@@ -4273,7 +4297,7 @@ findswapname(buf, dirp, old_fname)
{ {
buf->b_shortname = TRUE; buf->b_shortname = TRUE;
vim_free(fname); vim_free(fname);
fname = makeswapname(buf->b_fname, buf->b_ffname, fname = makeswapname(buf_fname, buf->b_ffname,
buf, dir_name); buf, dir_name);
continue; /* try again with b_shortname set */ continue; /* try again with b_shortname set */
} }
@@ -4344,7 +4368,7 @@ findswapname(buf, dirp, old_fname)
{ {
buf->b_shortname = TRUE; buf->b_shortname = TRUE;
vim_free(fname); vim_free(fname);
fname = makeswapname(buf->b_fname, buf->b_ffname, fname = makeswapname(buf_fname, buf->b_ffname,
buf, dir_name); buf, dir_name);
continue; /* try again with '.' replaced with '_' */ continue; /* try again with '.' replaced with '_' */
} }
@@ -4356,7 +4380,7 @@ findswapname(buf, dirp, old_fname)
* viewing a help file or when the path of the file is different * viewing a help file or when the path of the file is different
* (happens when all .swp files are in one directory). * (happens when all .swp files are in one directory).
*/ */
if (!recoverymode && buf->b_fname != NULL if (!recoverymode && buf_fname != NULL
&& !buf->b_help && !(buf->b_flags & BF_DUMMY)) && !buf->b_help && !(buf->b_flags & BF_DUMMY))
{ {
int fd; int fd;
@@ -4433,7 +4457,7 @@ findswapname(buf, dirp, old_fname)
{ {
fclose(dummyfd); fclose(dummyfd);
dummyfd = NULL; dummyfd = NULL;
mch_remove(buf->b_fname); mch_remove(buf_fname);
did_use_dummy = TRUE; did_use_dummy = TRUE;
} }
#endif #endif
@@ -4448,7 +4472,7 @@ findswapname(buf, dirp, old_fname)
* user anyway. * user anyway.
*/ */
if (swap_exists_action != SEA_NONE if (swap_exists_action != SEA_NONE
&& has_autocmd(EVENT_SWAPEXISTS, buf->b_fname, buf)) && has_autocmd(EVENT_SWAPEXISTS, buf_fname, buf))
choice = do_swapexists(buf, fname); choice = do_swapexists(buf, fname);
if (choice == 0) if (choice == 0)
@@ -4549,7 +4573,7 @@ findswapname(buf, dirp, old_fname)
#ifdef CREATE_DUMMY_FILE #ifdef CREATE_DUMMY_FILE
/* Going to try another name, need the dummy file again. */ /* Going to try another name, need the dummy file again. */
if (did_use_dummy) if (did_use_dummy)
dummyfd = mch_fopen((char *)buf->b_fname, "w"); dummyfd = mch_fopen((char *)buf_fname, "w");
#endif #endif
} }
} }
@@ -4581,8 +4605,12 @@ findswapname(buf, dirp, old_fname)
if (dummyfd != NULL) /* file has been created temporarily */ if (dummyfd != NULL) /* file has been created temporarily */
{ {
fclose(dummyfd); fclose(dummyfd);
mch_remove(buf->b_fname); mch_remove(buf_fname);
} }
#endif
#ifdef WIN3264
if (buf_fname != buf->b_fname)
vim_free(buf_fname);
#endif #endif
return fname; return fname;
} }

View File

@@ -4808,9 +4808,9 @@ gettail(fname)
if (fname == NULL) if (fname == NULL)
return (char_u *)""; return (char_u *)"";
for (p1 = p2 = fname; *p2; ) /* find last part of path */ for (p1 = p2 = get_past_head(fname); *p2; ) /* find last part of path */
{ {
if (vim_ispathsep(*p2)) if (vim_ispathsep_nocolon(*p2))
p1 = p2 + 1; p1 = p2 + 1;
mb_ptr_adv(p2); mb_ptr_adv(p2);
} }
@@ -4929,7 +4929,8 @@ get_past_head(path)
} }
/* /*
* return TRUE if 'c' is a path separator. * Return TRUE if 'c' is a path separator.
* Note that for MS-Windows this includes the colon.
*/ */
int int
vim_ispathsep(c) vim_ispathsep(c)
@@ -4952,6 +4953,20 @@ vim_ispathsep(c)
#endif #endif
} }
/*
* Like vim_ispathsep(c), but exclude the colon for MS-Windows.
*/
int
vim_ispathsep_nocolon(c)
int c;
{
return vim_ispathsep(c)
#ifdef BACKSLASH_IN_FILENAME
&& c != ':'
#endif
;
}
#if defined(FEAT_SEARCHPATH) || defined(PROTO) #if defined(FEAT_SEARCHPATH) || defined(PROTO)
/* /*
* return TRUE if 'c' is a path list separator. * return TRUE if 'c' is a path list separator.

View File

@@ -69,6 +69,7 @@ char_u *gettail_sep __ARGS((char_u *fname));
char_u *getnextcomp __ARGS((char_u *fname)); char_u *getnextcomp __ARGS((char_u *fname));
char_u *get_past_head __ARGS((char_u *path)); char_u *get_past_head __ARGS((char_u *path));
int vim_ispathsep __ARGS((int c)); int vim_ispathsep __ARGS((int c));
int vim_ispathsep_nocolon __ARGS((int c));
int vim_ispathlistsep __ARGS((int c)); int vim_ispathlistsep __ARGS((int c));
void shorten_dir __ARGS((char_u *str)); void shorten_dir __ARGS((char_u *str));
int dir_of_file_exists __ARGS((char_u *fname)); int dir_of_file_exists __ARGS((char_u *fname));

View File

@@ -738,6 +738,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
66,
/**/ /**/
65, 65,
/**/ /**/