1
0
forked from aniani/vim

updated for version 7.3.210

Problem:    Can't always find the file when using cscope.
Solution:   Add the 'cscoperelative' option. (Raghavendra D Prabhu)
This commit is contained in:
Bram Moolenaar 2011-06-12 20:42:22 +02:00
parent 536d95f617
commit 2f982e4fab
4 changed files with 56 additions and 16 deletions

View File

@ -270,6 +270,15 @@ setting 'cst', you will always search your cscope databases as well as your
tag files. The default is off. Examples: > tag files. The default is off. Examples: >
:set cst :set cst
:set nocst :set nocst
<
*cscoperelative* *csre*
If 'cscoperelative' set, then in absence of a prefix given to cscope (prefx
is the argument to -P option of cscope), basename of cscope.out location
(usually the project root directory) will be used as the prefix to construt
absolute path.The default is off. Note: This option is only effective when
cscope (cscopeprg) is initialized without a prefix path (-P). Examples: >
:set csre
:set nocsre
< <
*cscopetagorder* *csto* *cscopetagorder* *csto*
The value of 'csto' determines the order in which |:cstag| performs a search. The value of 'csto' determines the order in which |:cstag| performs a search.

View File

@ -2209,6 +2209,16 @@ A jump table for the options with a short description can be found at |Q_op|.
Specifies whether to use quickfix window to show cscope results. Specifies whether to use quickfix window to show cscope results.
See |cscopequickfix|. See |cscopequickfix|.
*'cscoperelative'* *'csre'*
'cscoperelative' 'csre' boolean (default off)
global
{not available when compiled without the |+cscope|
feature}
{not in Vi}
In the absence of a prefix (-P) for cscope. setting this option enables
to use the basename of cscope.out path as the prefix.
See |cscoperelative|.
*'cscopetag'* *'cst'* *'nocscopetag'* *'nocst'* *'cscopetag'* *'cst'* *'nocscopetag'* *'nocst'*
'cscopetag' 'cst' boolean (default off) 'cscopetag' 'cst' boolean (default off)
global global

View File

@ -2471,42 +2471,61 @@ cs_reset(eap)
*/ */
static char * static char *
cs_resolve_file(i, name) cs_resolve_file(i, name)
int i; int i;
char *name; char *name;
{ {
char *fullname; char *fullname;
int len; int len;
char_u *csdir = NULL;
/* /*
* ppath is freed when we destroy the cscope connection. * Ppath is freed when we destroy the cscope connection.
* fullname is freed after cs_make_vim_style_matches, after it's been * Fullname is freed after cs_make_vim_style_matches, after it's been
* copied into the tag buffer used by vim * copied into the tag buffer used by Vim.
*/ */
len = (int)(strlen(name) + 2); len = (int)(strlen(name) + 2);
if (csinfo[i].ppath != NULL) if (csinfo[i].ppath != NULL)
len += (int)strlen(csinfo[i].ppath); 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) if ((fullname = (char *)alloc(len)) == NULL)
return 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 * "../.." and the prefix path is also "../..". if something like this
* happens, you are screwed up and need to fix how you're using cscope. * happens, you are screwed up and need to fix how you're using cscope. */
*/ if (csinfo[i].ppath != NULL
if (csinfo[i].ppath != NULL && && (strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0)
(strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0) && && (name[0] != '/')
(name[0] != '/')
#ifdef WIN32 #ifdef WIN32
&& name[0] != '\\' && name[1] != ':' && name[0] != '\\' && name[1] != ':'
#endif #endif
) )
(void)sprintf(fullname, "%s/%s", csinfo[i].ppath, name); (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 else
(void)sprintf(fullname, "%s", name); (void)sprintf(fullname, "%s", name);
vim_free(csdir);
return fullname; return fullname;
} /* cs_resolve_file */ }
/* /*

View File

@ -709,6 +709,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
210,
/**/ /**/
209, 209,
/**/ /**/