]> granicus.if.org Git - vim/commitdiff
patch 8.2.3543: swapname has double slash when 'directory' ends in it v8.2.3543
authorBram Moolenaar <Bram@vim.org>
Tue, 19 Oct 2021 21:12:25 +0000 (22:12 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 19 Oct 2021 21:12:25 +0000 (22:12 +0100)
Problem:    Swapname has double slash when 'directory' ends in double slash.
            (Shane Smith)
Solution:   Remove the superfluous slash. (closes #8876)

src/memline.c
src/testdir/test_swap.vim
src/version.c

index bfbf4e28074de64deff45bd082bb24d5a35fa112..f54a970cc6a2f1f24e201bc74acd4f637debbc5e 100644 (file)
@@ -2064,7 +2064,9 @@ recover_names(
 /*
  * Need _very_ long file names.
  * Append the full path to name with path separators made into percent
- * signs, to dir. An unnamed buffer is handled as "" (<currentdir>/"")
+ * signs, to "dir". An unnamed buffer is handled as "" (<currentdir>/"")
+ * The last character in "dir" must be an extra slash or backslash, it is
+ * removed.
  */
     char_u *
 make_percent_swname(char_u *dir, char_u *name)
@@ -2081,6 +2083,8 @@ make_percent_swname(char_u *dir, char_u *name)
            for (d = s; *d != NUL; MB_PTR_ADV(d))
                if (vim_ispathsep(*d))
                    *d = '%';
+
+           dir[STRLEN(dir) - 1] = NUL;  // remove one trailing slash
            d = concat_fnames(dir, s, TRUE);
            vim_free(s);
        }
index 72d204ae013d6c37665f7af6c2c2bc18e20066c8..143a9af19c4b39ae97269299f7dfb4b0bfc882af 100644 (file)
@@ -410,7 +410,7 @@ func Test_swap_symlink()
 
   " Check that this also works when 'directory' ends with '//'
   edit Xtestlink
-  call assert_match('Xtestfile\.swp$', s:swapname())
+  call assert_match('Xswapdir[/\\]%.*testdir%Xtestfile\.swp$', s:swapname())
   bwipe!
 
   set dir&
index f449532913f1844f911b58e3e6542844187f75c8..c3f1fd6ab06ee589baeb6dbfb5f84a7e03889b84 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3543,
 /**/
     3542,
 /**/