Patch 7.2.427

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Patch 7.2.427

Bram Moolenaar

Patch 7.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)
Files:    src/memline.c


*** ../vim-7.2.426/src/memline.c 2010-03-10 14:46:21.000000000 +0100
--- src/memline.c 2010-05-14 17:28:29.000000000 +0200
***************
*** 245,250 ****
--- 245,253 ----
  #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,1410 ****
      int i;
      char_u *dirp;
      char_u *dir_name;
 
      if (list)
      {
!    /* use msg() to start the scrolling properly */
  msg((char_u *)_("Swap files found:"));
  msg_putchar('\n');
      }
--- 1404,1422 ----
      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 */
  msg((char_u *)_("Swap files found:"));
  msg_putchar('\n');
      }
***************
*** 1453,1459 ****
  #endif
     }
     else
! num_names = recov_file_names(names, *fname, TRUE);
  }
  else    /* check directory dir_name */
  {
--- 1465,1471 ----
  #endif
     }
     else
! num_names = recov_file_names(names, fname_res, TRUE);
  }
  else    /* check directory dir_name */
  {
***************
*** 1490,1501 ****
  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);
  }
  else
  #endif
  {
!    tail = gettail(*fname);
     tail = concat_fnames(dir_name, tail, TRUE);
  }
  if (tail == NULL)
--- 1502,1513 ----
  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_res);
  }
  else
  #endif
  {
!    tail = gettail(fname_res);
     tail = concat_fnames(dir_name, tail, TRUE);
  }
  if (tail == NULL)
***************
*** 1535,1545 ****
     struct stat    st;
     char_u    *swapname;
 
  #if defined(VMS) || defined(RISCOS)
!    swapname = modname(*fname, (char_u *)"_swp", FALSE);
  #else
!    swapname = modname(*fname, (char_u *)".swp", TRUE);
  #endif
     if (swapname != NULL)
     {
  if (mch_stat((char *)swapname, &st) != -1)    /* It exists! */
--- 1547,1559 ----
     struct stat    st;
     char_u    *swapname;
 
+    swapname = modname(fname_res,
  #if defined(VMS) || defined(RISCOS)
!       (char_u *)"_swp", FALSE
  #else
!       (char_u *)".swp", TRUE
  #endif
+      );
     if (swapname != NULL)
     {
  if (mch_stat((char *)swapname, &st) != -1)    /* It exists! */
***************
*** 3508,3515 ****
  }
 
  #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
--- 3522,3527 ----
***************
*** 3601,3609 ****
      char_u *dir_name;
  {
      char_u *r, *s;
  #ifdef HAVE_READLINK
      char_u fname_buf[MAXPATHL];
-     char_u *fname_res;
  #endif
 
  #if defined(UNIX) || defined(WIN3264)  /* Need _very_ long file names */
--- 3613,3621 ----
      char_u *dir_name;
  {
      char_u *r, *s;
+     char_u *fname_res = fname;
  #ifdef HAVE_READLINK
      char_u fname_buf[MAXPATHL];
  #endif
 
  #if defined(UNIX) || defined(WIN3264)  /* Need _very_ long file names */
***************
*** 3625,3632 ****
       * 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(
--- 3637,3642 ----
***************
*** 3639,3649 ****
     /* 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)
--- 3649,3655 ----
*** ../vim-7.2.426/src/version.c 2010-05-14 17:32:53.000000000 +0200
--- src/version.c 2010-05-14 17:50:43.000000000 +0200
***************
*** 683,684 ****
--- 683,686 ----
  {   /* Add new patch number below this line */
+ /**/
+     427,
  /**/

--
Change is inevitable, except from a vending machine.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Patch 7.2.427

James Vega-3
On Fri, May 14, 2010 at 11:53 AM, Bram Moolenaar <[hidden email]> wrote:
>
> Patch 7.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)
> Files:      src/memline.c

After this patch, “vim -r” (no arguments) crashes.  Attached patch fixes
it.

--
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <[hidden email]>

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

swapcrash.diff (1018 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Patch 7.2.427

Lech Lorens
On 25-May-2010 James Vega <[hidden email]> wrote:

> On Fri, May 14, 2010 at 11:53 AM, Bram Moolenaar <[hidden email]> wrote:
> >
> > Patch 7.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)
> > Files:      src/memline.c
>
> After this patch, “vim -r” (no arguments) crashes.  Attached patch fixes
> it.
The attached patch seems to fix the problem.

--
Cheers,
Lech

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

crash-427.patch (671 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Patch 7.2.427

Bram Moolenaar
In reply to this post by James Vega-3

James Vega wrote:

> On Fri, May 14, 2010 at 11:53 AM, Bram Moolenaar <[hidden email]> wrote:
> >
> > Patch 7.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)
> > Files: Â  Â  Â src/memline.c
>
> After this patch, “vim -r† (no arguments) crashes.
> Attached patch fixes it.

Thanks.  I just sent out a very similar patch.

--
From "know your smileys":
 :-E Has major dental problems

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Patch 7.2.427

Lech Lorens
In reply to this post by Lech Lorens
On 25-May-2010 Lech Lorens <[hidden email]> wrote:

> On 25-May-2010 James Vega <[hidden email]> wrote:
> > On Fri, May 14, 2010 at 11:53 AM, Bram Moolenaar <[hidden email]> wrote:
> > >
> > > Patch 7.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)
> > > Files:      src/memline.c
> >
> > After this patch, “vim -r” (no arguments) crashes.  Attached patch fixes
> > it.
>
> The attached patch seems to fix the problem.

Duh, what made me stop reading after the first dot?
...

--
Cheers,
Lech

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php