Mercurial > vim
comparison src/if_cscope.c @ 2873:eeb1ac4f66d1 v7.3.210
updated for version 7.3.210
Problem: Can't always find the file when using cscope.
Solution: Add the 'cscoperelative' option. (Raghavendra D Prabhu)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 12 Jun 2011 20:42:22 +0200 |
parents | ee48b3da9d53 |
children | c7d942260772 |
comparison
equal
deleted
inserted
replaced
2872:3e0a07715023 | 2873:eeb1ac4f66d1 |
---|---|
2469 * ships with Solaris 2.6), the output never has the prefix prepended. | 2469 * ships with Solaris 2.6), the output never has the prefix prepended. |
2470 * contrast this with my development system (Digital Unix), which does. | 2470 * contrast this with my development system (Digital Unix), which does. |
2471 */ | 2471 */ |
2472 static char * | 2472 static char * |
2473 cs_resolve_file(i, name) | 2473 cs_resolve_file(i, name) |
2474 int i; | 2474 int i; |
2475 char *name; | 2475 char *name; |
2476 { | 2476 { |
2477 char *fullname; | 2477 char *fullname; |
2478 int len; | 2478 int len; |
2479 char_u *csdir = NULL; | |
2479 | 2480 |
2480 /* | 2481 /* |
2481 * ppath is freed when we destroy the cscope connection. | 2482 * Ppath is freed when we destroy the cscope connection. |
2482 * fullname is freed after cs_make_vim_style_matches, after it's been | 2483 * Fullname is freed after cs_make_vim_style_matches, after it's been |
2483 * copied into the tag buffer used by vim | 2484 * copied into the tag buffer used by Vim. |
2484 */ | 2485 */ |
2485 len = (int)(strlen(name) + 2); | 2486 len = (int)(strlen(name) + 2); |
2486 if (csinfo[i].ppath != NULL) | 2487 if (csinfo[i].ppath != NULL) |
2487 len += (int)strlen(csinfo[i].ppath); | 2488 len += (int)strlen(csinfo[i].ppath); |
2489 else if (p_csre && csinfo[i].fname != NULL) | |
2490 { | |
2491 /* If 'cscoperelative' is set and ppath is not set, use cscope.out | |
2492 * path in path resolution. */ | |
2493 csdir = alloc(MAXPATHL); | |
2494 if (csdir != NULL) | |
2495 { | |
2496 vim_strncpy(csdir, (char_u *)csinfo[i].fname, | |
2497 gettail((char_u *)csinfo[i].fname) - 1 - (char_u *)csinfo[i].fname); | |
2498 len += (int)STRLEN(csdir); | |
2499 } | |
2500 } | |
2488 | 2501 |
2489 if ((fullname = (char *)alloc(len)) == NULL) | 2502 if ((fullname = (char *)alloc(len)) == NULL) |
2490 return NULL; | 2503 return NULL; |
2491 | 2504 |
2492 /* | 2505 /* Note/example: this won't work if the cscope output already starts |
2493 * note/example: this won't work if the cscope output already starts | |
2494 * "../.." and the prefix path is also "../..". if something like this | 2506 * "../.." and the prefix path is also "../..". if something like this |
2495 * happens, you are screwed up and need to fix how you're using cscope. | 2507 * happens, you are screwed up and need to fix how you're using cscope. */ |
2496 */ | 2508 if (csinfo[i].ppath != NULL |
2497 if (csinfo[i].ppath != NULL && | 2509 && (strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0) |
2498 (strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0) && | 2510 && (name[0] != '/') |
2499 (name[0] != '/') | |
2500 #ifdef WIN32 | 2511 #ifdef WIN32 |
2501 && name[0] != '\\' && name[1] != ':' | 2512 && name[0] != '\\' && name[1] != ':' |
2502 #endif | 2513 #endif |
2503 ) | 2514 ) |
2504 (void)sprintf(fullname, "%s/%s", csinfo[i].ppath, name); | 2515 (void)sprintf(fullname, "%s/%s", csinfo[i].ppath, name); |
2516 else if (csdir != NULL && csinfo[i].fname != NULL && STRLEN(csdir) > 0) | |
2517 { | |
2518 /* Check for csdir to be non empty to avoid empty path concatenated to | |
2519 * cscope output. TODO: avoid the unnecessary alloc/free of fullname. */ | |
2520 vim_free(fullname); | |
2521 fullname = concat_fnames(csdir, (char_u *)name, TRUE); | |
2522 } | |
2505 else | 2523 else |
2506 (void)sprintf(fullname, "%s", name); | 2524 (void)sprintf(fullname, "%s", name); |
2507 | 2525 |
2526 vim_free(csdir); | |
2508 return fullname; | 2527 return fullname; |
2509 } /* cs_resolve_file */ | 2528 } |
2510 | 2529 |
2511 | 2530 |
2512 /* | 2531 /* |
2513 * PRIVATE: cs_show | 2532 * PRIVATE: cs_show |
2514 * | 2533 * |