comparison src/ex_cmds2.c @ 9112:932f94b2d8c2 v7.4.1840

commit https://github.com/vim/vim/commit/a57024453115592b8847af40ddd965a33898e390 Author: Bram Moolenaar <Bram@vim.org> Date: Tue May 24 19:37:29 2016 +0200 patch 7.4.1840 Problem: When using packages an "after" directory cannot be used. Solution: Add the "after" directory of the package to 'runtimepath' if it exists.
author Christian Brabandt <cb@256bit.org>
date Tue, 24 May 2016 19:45:06 +0200
parents 634a8299bd2c
children c2fe86f2bda1
comparison
equal deleted inserted replaced
9111:adb90b8f299a 9112:932f94b2d8c2
3324 int c; 3324 int c;
3325 char_u *new_rtp; 3325 char_u *new_rtp;
3326 int keep; 3326 int keep;
3327 int oldlen; 3327 int oldlen;
3328 int addlen; 3328 int addlen;
3329 char_u *afterdir;
3330 int afterlen = 0;
3329 char_u *ffname = fix_fname(fname); 3331 char_u *ffname = fix_fname(fname);
3330 3332
3331 if (ffname == NULL) 3333 if (ffname == NULL)
3332 return; 3334 return;
3333 if (cookie != &APP_LOAD && strstr((char *)p_rtp, (char *)ffname) == NULL) 3335 if (cookie != &APP_LOAD && strstr((char *)p_rtp, (char *)ffname) == NULL)
3334 { 3336 {
3335 /* directory not in 'runtimepath', add it */ 3337 /* directory is not yet in 'runtimepath', add it */
3336 p4 = p3 = p2 = p1 = get_past_head(ffname); 3338 p4 = p3 = p2 = p1 = get_past_head(ffname);
3337 for (p = p1; *p; mb_ptr_adv(p)) 3339 for (p = p1; *p; mb_ptr_adv(p))
3338 if (vim_ispathsep_nocolon(*p)) 3340 if (vim_ispathsep_nocolon(*p))
3339 { 3341 {
3340 p4 = p3; p3 = p2; p2 = p1; p1 = p; 3342 p4 = p3; p3 = p2; p2 = p1; p1 = p;
3358 while (*insp != NUL && *insp != ',') 3360 while (*insp != NUL && *insp != ',')
3359 ++insp; 3361 ++insp;
3360 } 3362 }
3361 *p4 = c; 3363 *p4 = c;
3362 3364
3365 /* check if rtp/pack/name/start/name/after exists */
3366 afterdir = concat_fnames(ffname, (char_u *)"after", TRUE);
3367 if (afterdir != NULL && mch_isdir(afterdir))
3368 afterlen = STRLEN(afterdir) + 1; /* add one for comma */
3369
3363 oldlen = (int)STRLEN(p_rtp); 3370 oldlen = (int)STRLEN(p_rtp);
3364 addlen = (int)STRLEN(ffname); 3371 addlen = (int)STRLEN(ffname) + 1; /* add one for comma */
3365 new_rtp = alloc(oldlen + addlen + 2); 3372 new_rtp = alloc(oldlen + addlen + afterlen + 1); /* add one for NUL */
3366 if (new_rtp == NULL) 3373 if (new_rtp == NULL)
3367 goto theend; 3374 goto theend;
3368 keep = (int)(insp - p_rtp); 3375 keep = (int)(insp - p_rtp);
3369 mch_memmove(new_rtp, p_rtp, keep); 3376 mch_memmove(new_rtp, p_rtp, keep);
3370 new_rtp[keep] = ','; 3377 new_rtp[keep] = ',';
3371 mch_memmove(new_rtp + keep + 1, ffname, addlen + 1); 3378 mch_memmove(new_rtp + keep + 1, ffname, addlen);
3372 if (p_rtp[keep] != NUL) 3379 if (p_rtp[keep] != NUL)
3373 mch_memmove(new_rtp + keep + 1 + addlen, p_rtp + keep, 3380 mch_memmove(new_rtp + keep + addlen, p_rtp + keep,
3374 oldlen - keep + 1); 3381 oldlen - keep + 1);
3382 if (afterlen > 0)
3383 {
3384 STRCAT(new_rtp, ",");
3385 STRCAT(new_rtp, afterdir);
3386 }
3375 set_option_value((char_u *)"rtp", 0L, new_rtp, 0); 3387 set_option_value((char_u *)"rtp", 0L, new_rtp, 0);
3376 vim_free(new_rtp); 3388 vim_free(new_rtp);
3389 vim_free(afterdir);
3377 } 3390 }
3378 3391
3379 if (cookie != &APP_ADD_DIR) 3392 if (cookie != &APP_ADD_DIR)
3380 { 3393 {
3381 static char *plugpat = "%s/plugin/**/*.vim"; 3394 static char *plugpat = "%s/plugin/**/*.vim";