Re: Bug: cscope interface should use absolute paths

46 views
Skip to first unread message

A. S. Budden

unread,
Jun 3, 2013, 4:16:07 AM6/3/13
to vim...@googlegroups.com, A. S. Budden
On 1 June 2013 15:13, ChengYi Lin <t0963...@gmail.com> wrote:
> give cscope full path
> $ find `pwd` | cscope -i -

This indeed makes it work. That was what I was trying to show in my
example code. However, I think this should be done by Vim
automatically when using the "cs add" command.

>
>
> On Friday, May 31, 2013 3:41:05 PM UTC+8, A. S. Budden wrote:
>> Forwarding to vim-dev as requested by Bram... any cscope/vim experts here?
>>
>> Al
>>
>> ---------- Forwarded message ----------
>> From: Bram Moolenaar
>> Date: 22 May 2013 22:02
>> Subject: Re: Bug: cscope interface should use absolute paths
>> To: A. S. Budden
>>
>> Al -
>>
>> > 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
>> >
>> > bugreport.txt attached as per the instructions in the documentation.
>>
>> I think this was discussed before. Can you please send this to the
>> vim_dev list? I haven't done much on cscope myself. Hopefully someone
>> else knows.
>>
>> - Bram
>
> --
> --
> 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 a topic in the Google Groups "vim_dev" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_dev/Anwyht9Ohww/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to vim_dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
http://www.cgtk.co.uk

Gary Johnson

unread,
Jun 3, 2013, 10:53:34 AM6/3/13
to vim...@googlegroups.com
On 2013-06-03, A. S. Budden wrote:
> On 1 June 2013 15:13, ChengYi Lin wrote:
> > give cscope full path
> > $ find `pwd` | cscope -i -
>
> This indeed makes it work. That was what I was trying to show in my
> example code.

But that is solving a different problem than the one described in
the forwarded message.

The forwarded message describes a problem with using relative path
names for the name of the database file. The command above, using
find, addresses the problem of relative path names _in_ the database
file.

> However, I think this should be done by Vim automatically when
> using the "cs add" command.

The ":cs add" command does provide a solution for the problem of
relative path names _in_ the database file. That's what the
pre-path argument is for.

However, the ":cs add" command can't very well know what that
argument should be "automatically" because it is the path to the
directory in which cscope was run when it built the database, which
is not necessarily the directory in which vim is being run when the
":cs add" command is executed.

Regards,
Gary

A. S. Budden

unread,
Jun 3, 2013, 11:16:24 AM6/3/13
to vim...@googlegroups.com
On 3 June 2013 15:53, Gary Johnson <gary...@spocom.com> wrote:
> On 2013-06-03, A. S. Budden wrote:
>> On 1 June 2013 15:13, ChengYi Lin wrote:
>> > give cscope full path
>> > $ find `pwd` | cscope -i -
>>
>> This indeed makes it work. That was what I was trying to show in my
>> example code.
>
> But that is solving a different problem than the one described in
> the forwarded message.

Yes, sorry: re-reading my email it wasn't very explicit.

> The forwarded message describes a problem with using relative path
> names for the name of the database file. The command above, using
> find, addresses the problem of relative path names _in_ the database
> file.

Correct.

>> However, I think this should be done by Vim automatically when
>> using the "cs add" command.
>
> The ":cs add" command does provide a solution for the problem of
> relative path names _in_ the database file. That's what the
> pre-path argument is for.

Yes, but as you said above, this is a different one to the one I
described in my bug report to Bram.

> However, the ":cs add" command can't very well know what that
> argument should be "automatically" because it is the path to the
> directory in which cscope was run when it built the database, which
> is not necessarily the directory in which vim is being run when the
> ":cs add" command is executed.

cs add can't know the second argument automatically (hence the need
for the pre-path argument), but it can know the location of the cscope
database automatically as it will either be provided as a complete
path or will be relative to the current working directory. From my
understanding (as I described in the original post), the fix would be
to make cs add filename do an implicit fnamemodify(filename, ':p').
However, I looked at the cs_add_common code in if_cscope.c and it
scared me enough that I didn't feel sufficiently qualified to write a
patch to that effect: hence submitting it as a bug report instead.

Al

Gary Johnson

unread,
Jun 3, 2013, 11:28:04 AM6/3/13
to vim...@googlegroups.com
You started two threads on this topic. Did you see Christian's
patch in the other thread?

Regards,
Gary

A. S. Budden

unread,
Jun 3, 2013, 11:54:41 AM6/3/13
to vim...@googlegroups.com
I didn't, no: sorry. I hadn't realised there were two threads - I was
having problems signing up as a result of being logged in to two
Google Accounts simultaneously and I thought that one hadn't worked at
all. I'll read the other post.

Thank you.

Al
Reply all
Reply to author
Forward
0 new messages