On Fr, 31 Mai 2013, A. S. Budden wrote:
> > When using cscope, the path as provided to the "cs add" command is
> > used. If the working directory changes, this is potentially no longer
> > valid. This causes me a problem as I have a plugin that tries to
> > pause cscope and restart it (so it can regenerate cscope.out without
> > access conflicts). It does this by parsing "cs show" to get the file
> > name(s) and then doing "cs kill" to pause and "cs add" to restart. If
> > the working directory has changed, "cs add" fails.
> >
> > I think the fix is relatively simple: make "cs add filename" do the
> > equivalent of "exe 'cs add' fnamemodify('filename', ':p')", but I
> > don't know how to do that in Vim's code.
> >
> > An example of the issue can easily be produced with the following
> > example (on Windows):
> >
> > * Create c:\proj1\test1.c with a simple function (I used void test1(void) {
> > })
> > * Create c:\proj2\test2.c with another simple function (I used void
> > test2(void) { })
> > * In each directory (c:\proj1 and c:\proj2), run "cscope -b" to create
> > cscope.out
> >
> > First attempt (doesn't work):
> >
> > gvim -u NONE -U NONE
> > :cd c:\proj1
> > :e test1.c
> > :cs add cscope.out
> > :vnew
> > :lcd c:\proj2
> > :e test2.c
> > :cs add cscope.out
> > :cs show
> > # Only shows one entry: cscope.out
> >
> > Second attempt (works):
> >
> > gvim -u NONE -U NONE
> > :cd c:\proj1
> > :e test1.c
> > :cs add c:\proj1\cscope.out
> > :vnew
> > :lcd c:\proj2
> > :e test2.c
> > :cs add c:\proj2\cscope.out
> > :cs show
> > # Shows two entries, one for each project
So you would like to have cscope always store a full path?
I think this patch does it:
iff --git a/src/if_cscope.c b/src/if_cscope.c
--- a/src/if_cscope.c
+++ b/src/if_cscope.c
@@ -539,12 +539,17 @@
char *fname2 = NULL;
char *ppath = NULL;
int i;
+ int len;
+ int usedlen = 0;
+ char_u *fbuf = NULL;
/* get the filename (arg1), expand it, and try to stat it */
if ((fname = (char *)alloc(MAXPATHL + 1)) == NULL)
goto add_err;
expand_env((char_u *)arg1, (char_u *)fname, MAXPATHL);
+ len = (int)STRLEN(fname);
+ (void)modify_fname((char_u *)":p", &usedlen, (char_u **) &fname, &fbuf,
&len);
ret = stat(fname, &statbuf);
if (ret < 0)
{
regards,
Christian
--
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.