| 1 |
#!/bin/sh |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
if [ "$1" == "-h" -o "$1" == "help" -o "$1" == "--help" -o "$1" == "-help" ] |
|---|
| 5 |
then |
|---|
| 6 |
echo "Usage: woctags [dir|files] [options to 'find']" |
|---|
| 7 |
echo "" |
|---|
| 8 |
echo "Note : By default, 'find' searches recursively the current" |
|---|
| 9 |
echo " directory. To disable this behaviour use -maxdepth 1" |
|---|
| 10 |
echo "" |
|---|
| 11 |
echo "If the WOC_FILE_LIST enviroment variable has been defined, woctags.sh" |
|---|
| 12 |
echo "will examine only the files listed in the \$WOC_FILE_LIST file." |
|---|
| 13 |
exit 1 |
|---|
| 14 |
fi |
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
exclude_files='~$|\<tags\.woc$|\<tags$|\<TAGS$|\<tags\.rev\.woc$|\<cscope.out$|\<CVS/$' |
|---|
| 18 |
|
|---|
| 19 |
echo "[*] (re)Making .woc/ directory" |
|---|
| 20 |
if [ -d .woc/ ] |
|---|
| 21 |
then |
|---|
| 22 |
rm -f .woc/*.bz2 |
|---|
| 23 |
else |
|---|
| 24 |
mkdir .woc/ |
|---|
| 25 |
fi |
|---|
| 26 |
echo "[*] Generating WoC tags files" |
|---|
| 27 |
if [ ! -z "$WOC_FILE_LIST" ] |
|---|
| 28 |
then |
|---|
| 29 |
echo "[*] Loading files list from $WOC_FILE_LIST" |
|---|
| 30 |
tfile=$WOC_FILE_LIST |
|---|
| 31 |
else |
|---|
| 32 |
tfile=`tempfile` |
|---|
| 33 |
find $@ | grep -Ev "$exclude_files" > $tfile |
|---|
| 34 |
fi |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
exuberant-ctags -f tags.woc --langdef=woc --language-force=woc \ |
|---|
| 39 |
--regex-woc='/\|\{(.+)\}\|/\1/d,definition/' \ |
|---|
| 40 |
--tag-relative -L $tfile |
|---|
| 41 |
exuberant-ctags -f tags.rev.woc --langdef=woc --language-force=woc \ |
|---|
| 42 |
--regex-woc='/\{-(.+)(:[^:]*)-\}/\1/r,reference/' \ |
|---|
| 43 |
--regex-woc='/\{-([^:]+)-\}/\1/r,reference/' \ |
|---|
| 44 |
--tag-relative -L $tfile |
|---|
| 45 |
|
|---|
| 46 |
if [ -z "$WOC_FILE_LIST" ]; then |
|---|
| 47 |
rm -f $tfile |
|---|
| 48 |
fi |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
echo "[*] Compressing tags files" |
|---|
| 52 |
for i in index.woc tags.woc tags.rev.woc tags TAGS cscope.out |
|---|
| 53 |
do |
|---|
| 54 |
if [ -r "$i" ]; then |
|---|
| 55 |
bzip2 -fk $i |
|---|
| 56 |
mv $i.bz2 .woc/ |
|---|
| 57 |
fi |
|---|
| 58 |
done |
|---|
| 59 |
if [ ! -f tags -a ! -f TAGS -a ! -f cscope.out ] |
|---|
| 60 |
then |
|---|
| 61 |
echo "[!] No tags file found. Did you run ctags or cscope, before" |
|---|
| 62 |
echo " launching $0 ?" |
|---|
| 63 |
exit 0 |
|---|
| 64 |
fi |
|---|