2

I want to be familiar with cscope. So i read a Blog which gives a simple example and followed it step by step.

But I failed to complete it successfully.

When I typed :cs find g InFile_Open , it jumped into another file which is expected, but nothing shows was unexpected.

Seemed like that it create a new file. enter image description here

And it supposed to show me the file 7zFile.c which holds the only definition of InFile_Open symbol as described by that blog. Like this enter image description here

And the same thing happened when i typed

:cs find g PrintError

It supposed to show me a list of definition and asked me to choose one

Cscope tag: PrintError
  #   line  filename / context / line
  1    261  C/Util/7z/7zMain.c <<PrintError>>
            void PrintError(char *sz)
  2     33  C/Util/Lzma/LzmaUtil.c <<PrintError>>
            int PrintError(char *buffer, const char *message)
  3     86  CPP/7zip/UI/Client7z/Client7z.cpp <<PrintError>>
            static void PrintError(const char *message, const FString &name)
  4     94  CPP/7zip/UI/Client7z/Client7z.cpp <<PrintError>>
            static void PrintError(const AString &s)
Type number and <Enter> (empty cancels):

But it jumped directly into the corresponding file ,leaving me no choice, but show nothing just like above.

Besides, I hit ctrl + t for going back to previous file , but vim showed me

E73: tag stack empty 

How can I fix this?

P.S. (cscope version:15.8b and my cscope settings for vim)

if has("cscope")
        set csprg=/usr/local/bin/cscope
        set csto=0
        set cscopetag
        set cst
        set nocsverb
        " add any database in current directory
        if filereadable("cscope.out")
            cs add cscope.out
        " else add database pointed to by environment
        elseif $CSCOPE_DB != ""
            cs add $CSCOPE_DB
        endif
        set csverb

        nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
        nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
        nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>

         nmap <C-@>s :scs find s <C-R>=expand("<cword>")<CR><CR>
         nmap <C-@>g :scs find g <C-R>=expand("<cword>")<CR><CR>
         nmap <C-@>c :scs find c <C-R>=expand("<cword>")<CR><CR>
         nmap <C-@>t :scs find t <C-R>=expand("<cword>")<CR><CR>
         nmap <C-@>e :scs find e <C-R>=expand("<cword>")<CR><CR>
         nmap <C-@>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
         nmap <C-@>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
         nmap <C-@>d :scs find d <C-R>=expand("<cword>")<CR><CR>

        nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@><C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@><C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@><C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@><C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@><C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>
        nmap <C-@><C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
        nmap <C-@><C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>


endif
MMMMMCCLXXVII
  • 571
  • 1
  • 8
  • 23
  • 1st obvious problem: `7zFile.c` is 284 lines long but the file in your first screenshot is only 10 lines long. 2nd problem: `7zFile.c` doesn't contain `#include` or `#include`. Using the same sources and the same commands as in the article I get the expected results. Does it work as expected from the cscope TUI? – romainl May 30 '15 at 08:53
  • That's why i said it seemed like create a new file. Cause what we see in the screenshot , it's my vim's default setting when create c file. – MMMMMCCLXXVII May 30 '15 at 08:56
  • Vim doesn't insert a default template when creating a new C file. Some plugin is responsible for that: disable it to see if it changes anything. – romainl May 30 '15 at 09:00
  • @romainl No such plugin,at least in my vim setting. Inserting default template is `autocmd BufNewFile *.py,*.cc,*.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()"` 's responsibility. And I tried to uncomment it , but didn't change anything. – MMMMMCCLXXVII May 30 '15 at 09:09

0 Answers0