Compare commits

...

2 Commits

Author SHA1 Message Date
Bram Moolenaar
2f9e575583 patch 8.0.0308: 'runtimepath' not update correctly when using symbolic link
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)
2017-02-05 16:07:54 +01:00
Bram Moolenaar
955f198fc5 patch 8.0.0307: asan detects a memory error when EXITFREE is defined
Problem:    Asan detects a memory error when EXITFREE is defined. (Dominique
            Pelle)
Solution:   In getvcol() check for ml_get_buf() returning an empty string.
            Also skip adjusting the scroll position.  Set "exiting" in
            mch_exit() for all systems.
2017-02-05 15:10:51 +01:00
8 changed files with 71 additions and 15 deletions

View File

@@ -1296,6 +1296,10 @@ getvcol(
posptr = NULL; /* continue until the NUL */
else
{
/* Special check for an empty line, which can happen on exit, when
* ml_get_buf() always returns an empty string. */
if (*ptr == NUL)
pos->col = 0;
posptr = ptr + pos->col;
#ifdef FEAT_MBYTE
if (has_mbyte)

View File

@@ -3509,6 +3509,9 @@ add_pack_plugin(char_u *fname, void *cookie)
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,26 +3536,28 @@ add_pack_plugin(char_u *fname, void *cookie)
/* Find "ffname" in "p_rtp", ignoring '/' vs '\' differences. */
fname_len = STRLEN(ffname);
insp = p_rtp;
for (;;)
buf = alloc(MAXPATHL);
if (buf == NULL)
goto theend;
while (*insp != NUL)
{
if (vim_fnamencmp(insp, ffname, fname_len) == 0)
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;
insp = vim_strchr(insp, ',');
if (insp == NULL)
break;
++insp;
}
if (insp == NULL)
if (*insp == NUL)
/* 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;
}
--insp;
*p4 = c;
/* check if rtp/pack/name/start/name/after exists */
@@ -3562,7 +3567,8 @@ add_pack_plugin(char_u *fname, void *cookie)
oldlen = STRLEN(p_rtp);
addlen = STRLEN(ffname) + 1; /* add one for comma */
new_rtp = alloc((int)(oldlen + addlen + afterlen + 1)); /* add one for NUL */
new_rtp = alloc((int)(oldlen + addlen + afterlen + 1));
/* add one for NUL */
if (new_rtp == NULL)
goto theend;
keep = (int)(insp - p_rtp);
@@ -3616,6 +3622,7 @@ add_pack_plugin(char_u *fname, void *cookie)
}
theend:
vim_free(buf);
vim_free(ffname);
}

View File

@@ -889,6 +889,8 @@ mch_early_init(void)
void
mch_exit(int r)
{
exiting = TRUE;
if (raw_in) /* put terminal in 'normal' mode */
{
settmode(TMODE_COOK);

View File

@@ -201,6 +201,8 @@ int _stricoll(char *a, char *b)
void
mch_exit(int r)
{
exiting = TRUE;
display_errors();
ml_close_all(TRUE); /* remove all memfiles */

View File

@@ -2538,8 +2538,9 @@ mch_init(void)
void
mch_exit(int r)
{
stoptermcap();
exiting = TRUE;
stoptermcap();
if (g_fWindInitCalled)
settmode(TMODE_COOK);

View File

@@ -67,6 +67,39 @@ func Test_packadd_noload()
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'

View File

@@ -764,6 +764,10 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
308,
/**/
307,
/**/
306,
/**/

View File

@@ -5708,6 +5708,9 @@ win_new_height(win_T *wp, int height)
wp->w_height = height;
wp->w_skipcol = 0;
/* There is no point in adjusting the scroll position when exiting. Some
* values might be invalid. */
if (!exiting)
scroll_to_fraction(wp, prev_height);
}