On Friday, May 31, 2013 9:27:14 PM UTC+1, Christian Brabandt wrote:
> 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?
Yes!
> 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
Certainly looks promising: what do you think are the chances of getting this
into Vim 7.4? As discussed in my other email in this thread, there are sadly
other problems for my plugin with this (the fact that cs show won't be able to
display long file-names), but this would certainly be a massive improvement on
where we are now. Ideally, it would be good to have a function() interface to
"cs show" to get the details programmatically, but I'd guess that's quite a lot
more work for relatively little benefit.
Thanks for the patch.
Al
--
--
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.