Use cscope to index your code

If you are using cscope with Emacs, you may have noticed that, in cscope-15.6/contrib/xcscope, there is an utility named cscope-indexer. While I think its usage is not as easy as of ctags-exuberant.

So, I created my own indexer:

#!/bin/bash

LIST_FILE='cscope.files'
DATABASE_FILE='cscope.out'

if [ $# == 0 ]; then
        echo ""
        echo "  cscope-indexer: please sepcify the folders you want to index!"
        echo "  E.g., cscope-indexer . ../include ../lib"
        echo ""
        exit
fi

rm $LIST_FILE $DATABASE_FILE &>/dev/null

for i in $@; do
        find $i -type f -o -type l | \
                egrep -i '\.([chly](xx|pp)*|cc|hh)$' | \
                sed -e '/\/CVS\//d' -e '/\/RCS\//d' -e 's/^\.\///' | \
                sort >> $LIST_FILE
done

cscope -b -i $LIST_FILE -f $DATABASE_FILE