Patch 8.0.0308

44 views
Skip to first unread message

Bram Moolenaar

unread,
Feb 5, 2017, 10:08:19 AM2/5/17
to vim...@googlegroups.com

Patch 8.0.0308
Problem: When using a symbolic link, the package path will not be inserted
at the right position in 'runtimepath'. (Dugan Chen, Norio Takagi)
Solution: Resolve symbolic links when finding the right position in
'runtimepath'. (Hirohito Higashi)
Files: src/ex_cmds2.c, src/testdir/test_packadd.vim


*** ../vim-8.0.0307/src/ex_cmds2.c 2017-01-28 15:58:45.344197275 +0100
--- src/ex_cmds2.c 2017-02-05 15:51:53.705843565 +0100
***************
*** 3509,3514 ****
--- 3509,3517 ----
size_t afterlen = 0;
char_u *ffname = fix_fname(fname);
size_t fname_len;
+ char_u *buf = NULL;
+ char_u *rtp_ffname;
+ int match;

if (ffname == NULL)
return;
***************
*** 3533,3558 ****
/* Find "ffname" in "p_rtp", ignoring '/' vs '\' differences. */
fname_len = STRLEN(ffname);
insp = p_rtp;
! for (;;)
{
! if (vim_fnamencmp(insp, ffname, fname_len) == 0)
! break;
! insp = vim_strchr(insp, ',');
! if (insp == NULL)
break;
- ++insp;
}

! if (insp == NULL)
/* not found, append at the end */
insp = p_rtp + STRLEN(p_rtp);
else
- {
/* append after the matching directory. */
! insp += STRLEN(ffname);
! while (*insp != NUL && *insp != ',')
! ++insp;
! }
*p4 = c;

/* check if rtp/pack/name/start/name/after exists */
--- 3536,3563 ----
/* Find "ffname" in "p_rtp", ignoring '/' vs '\' differences. */
fname_len = STRLEN(ffname);
insp = p_rtp;
! buf = alloc(MAXPATHL);
! if (buf == NULL)
! goto theend;
! while (*insp != NUL)
{
! copy_option_part(&insp, buf, MAXPATHL, ",");
! add_pathsep(buf);
! rtp_ffname = fix_fname(buf);
! if (rtp_ffname == NULL)
! goto theend;
! match = vim_fnamencmp(rtp_ffname, ffname, fname_len) == 0;
! vim_free(rtp_ffname);
! if (match)
break;
}

! if (*insp == NUL)
/* not found, append at the end */
insp = p_rtp + STRLEN(p_rtp);
else
/* append after the matching directory. */
! --insp;
*p4 = c;

/* check if rtp/pack/name/start/name/after exists */
***************
*** 3562,3568 ****

oldlen = STRLEN(p_rtp);
addlen = STRLEN(ffname) + 1; /* add one for comma */
! new_rtp = alloc((int)(oldlen + addlen + afterlen + 1)); /* add one for NUL */
if (new_rtp == NULL)
goto theend;
keep = (int)(insp - p_rtp);
--- 3567,3574 ----

oldlen = STRLEN(p_rtp);
addlen = STRLEN(ffname) + 1; /* add one for comma */
! new_rtp = alloc((int)(oldlen + addlen + afterlen + 1));
! /* add one for NUL */
if (new_rtp == NULL)
goto theend;
keep = (int)(insp - p_rtp);
***************
*** 3616,3621 ****
--- 3622,3628 ----
}

theend:
+ vim_free(buf);
vim_free(ffname);
}

*** ../vim-8.0.0307/src/testdir/test_packadd.vim 2016-05-24 19:30:39.000000000 +0200
--- src/testdir/test_packadd.vim 2017-02-05 16:00:10.802317583 +0100
***************
*** 67,72 ****
--- 67,105 ----
call assert_equal(new_rtp, &rtp)
endfunc

+ func Test_packadd_symlink_dir()
+ if !has('unix')
+ return
+ endif
+ let top2_dir = s:topdir . '/Xdir2'
+ let real_dir = s:topdir . '/Xsym'
+ silent !ln -s real_dir top2_dir
+ let &rtp = top2_dir . ',' . top2_dir . '/after'
+ let &packpath = &rtp
+
+ let s:plugdir = top2_dir . '/pack/mine/opt/mytest'
+ call mkdir(s:plugdir . '/plugin', 'p')
+
+ exe 'split ' . s:plugdir . '/plugin/test.vim'
+ call setline(1, 'let g:plugin_works = 44')
+ wq
+ let g:plugin_works = 0
+
+ packadd mytest
+
+ " Must have been inserted in the middle, not at the end
+ call assert_true(&rtp =~ '/pack/mine/opt/mytest,')
+ call assert_equal(44, g:plugin_works)
+
+ " No change when doing it again.
+ let rtp_before = &rtp
+ packadd mytest
+ call assert_equal(rtp_before, &rtp)
+
+ set rtp&
+ let rtp = &rtp
+ endfunc
+
" Check command-line completion for 'packadd'
func Test_packadd_completion()
let optdir1 = &packpath . '/pack/mine/opt'
*** ../vim-8.0.0307/src/version.c 2017-02-05 15:10:47.747484014 +0100
--- src/version.c 2017-02-05 15:41:48.494171300 +0100
***************
*** 766,767 ****
--- 766,769 ----
{ /* Add new patch number below this line */
+ /**/
+ 308,
/**/

--
Zen Microsystems: we're the om in .commmmmmmmm

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

h_east

unread,
Feb 9, 2017, 8:08:23 PM2/9/17
to vim_dev
Hi Bram and all,

2017-2-6(Mon) 0:08:19 UTC+9 Bram Moolenaar:


> Patch 8.0.0308
> Problem: When using a symbolic link, the package path will not be inserted
> at the right position in 'runtimepath'. (Dugan Chen, Norio Takagi)
> Solution: Resolve symbolic links when finding the right position in
> 'runtimepath'. (Hirohito Higashi)
> Files: src/ex_cmds2.c, src/testdir/test_packadd.vim

...

Sorry,
I forget to delete symbolic link at test_packadd.vim
When you do `ctags -R` after running `make test_packadd`, the following error will be output.

$ ctags -R
ctags: Warning: cannot open source file "testdir/top2_dir" : No such file or directory

Attached patch fix this.

--
Best regards,
Hirohito Higashi (a.k.a. h_east)

test_packadd_forgets_to_delete_symlink.patch

Bram Moolenaar

unread,
Feb 11, 2017, 5:37:12 AM2/11/17
to vim...@googlegroups.com, h_east
Thanks! We should actually prefer to start names with "X", that makes
it easier to cleanup when a test fails.

--
"I've been teaching myself to play the piano for about 5 years and now write
most of my songs on it, mainly because I can never find any paper."
Jeff Lynne, ELO's greatest hits
Reply all
Reply to author
Forward
0 new messages