Hi,

On 07/12/07 05:38, Aubrey Li wrote:
> Hi list,
> 
> Does anyone have successful experience about vim + cscope to browse
> solaris source code?
> Unfortunate, I encountered the following error,
> --------
> [EMAIL PROTECTED]
> /export/home/aubrey/work/onnv-gate/usr/src/uts
> [EMAIL PROTECTED] -l cscope.*
> -rw-r--r--   1 aubrey   aubrey    157421 Jul 13 09:23 cscope.files
> -rw-r--r--   1 aubrey   aubrey   8896902 Jul 13 09:24 cscope.in.out
> -rw-r--r--   1 aubrey   aubrey   77068303 Jul 13 09:24 cscope.out
> -rw-r--r--   1 aubrey   aubrey   58314408 Jul 13 09:24 cscope.po.out
> [EMAIL PROTECTED] i86pc/dboot/dboot_elfload.c
> Error detected while processing 
> /export/home/aubrey/.vim/plugin/cscope_maps.vim:
> line   42:
> cs_read_prompt EOF: Not a directory
> E609: Cscope error: cscope: cannot read list size from file cscope.out

The ON 'xref' utility builds the database in cscope-fast format, so I'm guessing
the above may be a case of picking up the old cscope program.  When I remove
the cscopeprg directive below I get a related error:

Error detected while processing /home/gavinm/.vimrc:
line  213:
cs_read_prompt EOF: No such file or directory

I have the following in my .vimrc which appears to make it all work (has
been this way for some time and I can't remember how it all hangs
together!):

if has("cscope")
         set cscopeprg=/home/gavinm/bin/cscope-vim
        ..
        (more of this below)
        ..
endif

The nominated cscopeprg looks like this:

----- cut -----

#!/bin/ksh
#
# Hackery to make vim and cscope work together for cscope.out
#
# If invoked with -f "/foo/cscope.out" drop those arguments as
# cscope then can't find the quick indexes
#
# Copied from peteh

firstarg="$1"
dirarg="${4#-P}"
echo $dirarg >&2

shift

if [[ $1 == "-f" && ${2##*/} == "cscope.out" ]]; then
         shift; shift
fi

cd $dirarg
exec /share/onnv-tools/onbld/bin/$(uname -p)/cscope-fast "$firstarg" ${1+"$@"}

----- cut -----

So you may be able to use that substituting /opt/onbld/bin/i386/cscope-fast in 
the
last line.

For the full gory detail here's the relevant bit of .vimrc:

if has("cscope")
         set cscopeprg=/home/gavinm/bin/cscope-vim
         set cscopetag
         set cscopepathcomp=3
         set nocscopeverbose
         set cscopetagorder=0
         "
         " Short cut keys
         "
         " s - symbol
         " g - definition
         " d - functions called by this function
         " c - functions calling this function
         " t - find this text string
         " e - find this egrep pattern
         " f - find this file
         "
         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>

         " Using 'CTRL-spacebar' then a search type makes the vim window
         " split horizontally, with search result displayed in
         " the new window.

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

         "
         " Any cscope database specified in CSCOPE_DB?
         "
         let $CSCOPE_DB_FOUND = "N"
         if $CSCOPE_DB == ""
                 "
                 " Find any database in current directory or above
                 "
                 let $CSCOPE_DB_DIR = getcwd()
                 while $CSCOPE_DB_DIR != "/" && $CSCOPE_DB_DIR != "/home"
                         let $CSCOPE_DB = $CSCOPE_DB_DIR . "/cscope.out"
                         if filereadable($CSCOPE_DB)
                                 let $CSCOPE_DB_FOUND="Y"
                                 break
                         endif
                         let $CSCOPE_DB = $CSCOPE_DB_DIR . "/cscope-fast.out"
                         if filereadable($CSCOPE_DB)
                                 let $CSCOPE_DB_FOUND="Y"
                                 break
                         endif
                         let $CSCOPE_DB = $CSCOPE_DB_DIR . "/cscope-fast"
                         if filereadable($CSCOPE_DB)
                                 let $CSCOPE_DB_FOUND="Y"
                                 break
                         endif
                         let $CSCOPE_DB_DIR = fnamemodify($CSCOPE_DB_DIR, ":h")
                 endwhile

                 "
                 " If that found nothing and this looks like an ON workspace
                 " then try usr/src
                 "
                 if $CSCOPE_DB_FOUND == "N" && $CODEMGR_WS != "" && 
filereadable(
$CODEMGR_WS . "/usr/src/Makefile.master")
                         let $CSCOPE_DB = $CODEMGR_WS .  "/usr/src/cscope.out"
                         if filereadable($CSCOPE_DB)
                                 let $CSCOPE_DB_DIR = $CODEMGR_WS . "/usr/src"
                                 let $CSCOPE_DB_FOUND="Y"
                         endif
                 endif
         else
                 let $CSCOPE_DB_FOUND="Y"
                 let $CSCOPE_DB_DIR = fnamemodify($CSCOPE_DB, ":p:h")
         endif

         "
         " Add database pointed to by environment if set
         "
         if $CSCOPE_DB_FOUND == "Y"
                 cscope add $CSCOPE_DB $CSCOPE_DB_DIR -q
         endif
         set cscopeverbose
endif

Gavin

_______________________________________________
opensolaris-discuss mailing list
opensolaris-discuss@opensolaris.org

Reply via email to