summaryrefslogtreecommitdiff
path: root/src/if_cscope.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2011-06-12 20:42:22 +0200
committerBram Moolenaar <Bram@vim.org>2011-06-12 20:42:22 +0200
commit2f982e4fabf27806d96cedd34d0f1823a3fc52c0 (patch)
tree3d36b24aa262c92e0edaece377ce2d3ed5c46f1b /src/if_cscope.c
parent536d95f6171b75093e7dc2894144a9bd44a85895 (diff)
downloadvim-git-2f982e4fabf27806d96cedd34d0f1823a3fc52c0.tar.gz
updated for version 7.3.210v7.3.210
Problem: Can't always find the file when using cscope. Solution: Add the 'cscoperelative' option. (Raghavendra D Prabhu)
Diffstat (limited to 'src/if_cscope.c')
-rw-r--r--src/if_cscope.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/src/if_cscope.c b/src/if_cscope.c
index a96622684..f9e318dde 100644
--- a/src/if_cscope.c
+++ b/src/if_cscope.c
@@ -2471,42 +2471,61 @@ cs_reset(eap)
*/
static char *
cs_resolve_file(i, name)
- int i;
+ int i;
char *name;
{
- char *fullname;
- int len;
+ char *fullname;
+ int len;
+ char_u *csdir = NULL;
/*
- * ppath is freed when we destroy the cscope connection.
- * fullname is freed after cs_make_vim_style_matches, after it's been
- * copied into the tag buffer used by vim
+ * Ppath is freed when we destroy the cscope connection.
+ * Fullname is freed after cs_make_vim_style_matches, after it's been
+ * copied into the tag buffer used by Vim.
*/
len = (int)(strlen(name) + 2);
if (csinfo[i].ppath != NULL)
len += (int)strlen(csinfo[i].ppath);
+ else if (p_csre && csinfo[i].fname != NULL)
+ {
+ /* If 'cscoperelative' is set and ppath is not set, use cscope.out
+ * path in path resolution. */
+ csdir = alloc(MAXPATHL);
+ if (csdir != NULL)
+ {
+ vim_strncpy(csdir, (char_u *)csinfo[i].fname,
+ gettail((char_u *)csinfo[i].fname) - 1 - (char_u *)csinfo[i].fname);
+ len += (int)STRLEN(csdir);
+ }
+ }
if ((fullname = (char *)alloc(len)) == NULL)
return NULL;
- /*
- * note/example: this won't work if the cscope output already starts
+ /* Note/example: this won't work if the cscope output already starts
* "../.." and the prefix path is also "../..". if something like this
- * happens, you are screwed up and need to fix how you're using cscope.
- */
- if (csinfo[i].ppath != NULL &&
- (strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0) &&
- (name[0] != '/')
+ * happens, you are screwed up and need to fix how you're using cscope. */
+ if (csinfo[i].ppath != NULL
+ && (strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0)
+ && (name[0] != '/')
#ifdef WIN32
- && name[0] != '\\' && name[1] != ':'
+ && name[0] != '\\' && name[1] != ':'
#endif
- )
+ )
(void)sprintf(fullname, "%s/%s", csinfo[i].ppath, name);
+ else if (csdir != NULL && csinfo[i].fname != NULL && STRLEN(csdir) > 0)
+ {
+ /* Check for csdir to be non empty to avoid empty path concatenated to
+ * cscope output. TODO: avoid the unnecessary alloc/free of fullname. */
+ vim_free(fullname);
+ fullname = concat_fnames(csdir, (char_u *)name, TRUE);
+ }
else
(void)sprintf(fullname, "%s", name);
+ vim_free(csdir);
return fullname;
-} /* cs_resolve_file */
+}
/*