summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <bram@zimbu.org>2010-05-14 17:52:42 +0200
committerBram Moolenaar <bram@zimbu.org>2010-05-14 17:52:42 +0200
commitd2dcb2a92833f9bbf0402fa1587583f7d72984d3 (patch)
tree88872f4f0291c0227a7a964975d015049b8a3793
parent92583102ab4b0e6e3c590d6de5888aecbaad3fc3 (diff)
downloadvim-d2dcb2a92833f9bbf0402fa1587583f7d72984d3.tar.gz
updated for version 7.2.427v7.2.427v7-2-427
Problem: The swapfile is created using the destination of a symlink, but recovery doesn't follow symlinks. Solution: When recovering, resolve symlinks. (James Vega)
-rw-r--r--src/memline.c36
-rw-r--r--src/version.c2
2 files changed, 23 insertions, 15 deletions
diff --git a/src/memline.c b/src/memline.c
index 102b61e3..74f94ed4 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -245,6 +245,9 @@ static char_u *make_percent_swname __ARGS((char_u *dir, char_u *name));
#ifdef FEAT_BYTEOFF
static void ml_updatechunk __ARGS((buf_T *buf, long line, long len, int updtype));
#endif
+#ifdef HAVE_READLINK
+static int resolve_symlink __ARGS((char_u *fname, char_u *buf));
+#endif
/*
* Open a new memline for "buf".
@@ -1401,10 +1404,19 @@ recover_names(fname, list, nr)
int i;
char_u *dirp;
char_u *dir_name;
+ char_u *fname_res = *fname;
+#ifdef HAVE_READLINK
+ char_u fname_buf[MAXPATHL];
+
+ /* Expand symlink in the file name, because the swap file is created with
+ * the actual file instead of with the symlink. */
+ if (resolve_symlink(*fname, fname_buf) == OK)
+ fname_res = fname_buf;
+#endif
if (list)
{
- /* use msg() to start the scrolling properly */
+ /* use msg() to start the scrolling properly */
msg((char_u *)_("Swap files found:"));
msg_putchar('\n');
}
@@ -1453,7 +1465,7 @@ recover_names(fname, list, nr)
#endif
}
else
- num_names = recov_file_names(names, *fname, TRUE);
+ num_names = recov_file_names(names, fname_res, TRUE);
}
else /* check directory dir_name */
{
@@ -1490,12 +1502,12 @@ recover_names(fname, list, nr)
if (after_pathsep(dir_name, p) && p[-1] == p[-2])
{
/* Ends with '//', Use Full path for swap name */
- tail = make_percent_swname(dir_name, *fname);
+ tail = make_percent_swname(dir_name, fname_res);
}
else
#endif
{
- tail = gettail(*fname);
+ tail = gettail(fname_res);
tail = concat_fnames(dir_name, tail, TRUE);
}
if (tail == NULL)
@@ -1535,11 +1547,13 @@ recover_names(fname, list, nr)
struct stat st;
char_u *swapname;
+ swapname = modname(fname_res,
#if defined(VMS) || defined(RISCOS)
- swapname = modname(*fname, (char_u *)"_swp", FALSE);
+ (char_u *)"_swp", FALSE
#else
- swapname = modname(*fname, (char_u *)".swp", TRUE);
+ (char_u *)".swp", TRUE
#endif
+ );
if (swapname != NULL)
{
if (mch_stat((char *)swapname, &st) != -1) /* It exists! */
@@ -3508,8 +3522,6 @@ ml_lineadd(buf, count)
}
#ifdef HAVE_READLINK
-static int resolve_symlink __ARGS((char_u *fname, char_u *buf));
-
/*
* Resolve a symlink in the last component of a file name.
* Note that f_resolve() does it for every part of the path, we don't do that
@@ -3601,9 +3613,9 @@ makeswapname(fname, ffname, buf, dir_name)
char_u *dir_name;
{
char_u *r, *s;
+ char_u *fname_res = fname;
#ifdef HAVE_READLINK
char_u fname_buf[MAXPATHL];
- char_u *fname_res;
#endif
#if defined(UNIX) || defined(WIN3264) /* Need _very_ long file names */
@@ -3625,8 +3637,6 @@ makeswapname(fname, ffname, buf, dir_name)
* actual file instead of with the symlink. */
if (resolve_symlink(fname, fname_buf) == OK)
fname_res = fname_buf;
- else
- fname_res = fname;
#endif
r = buf_modname(
@@ -3639,11 +3649,7 @@ makeswapname(fname, ffname, buf, dir_name)
/* Avoid problems if fname has special chars, eg <Wimp$Scrap> */
ffname,
#else
-# ifdef HAVE_READLINK
fname_res,
-# else
- fname,
-# endif
#endif
(char_u *)
#if defined(VMS) || defined(RISCOS)
diff --git a/src/version.c b/src/version.c
index 0572f97a..8d8770ef 100644
--- a/src/version.c
+++ b/src/version.c
@@ -682,6 +682,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 427,
+/**/
426,
/**/
425,