#!/bin/sh
#
# vrtags: generate tags file for VRML objects and DEF's
#
# tags::tagname<tab>filename<tab>search<newline>
#
# Note, that search pattern cannot contain [.*]
# (makes vi claim, tag is `out of date')
# and, that the sort order is significant.
#
if [ $# -eq 1 ] ;then
  file="$1"
  egrep -n "(^# Object[ 	]|DEF[ 	])" $* | \
  sed -ne 's/^\([^:]*\):\(# Object[ 	]*\"\)\([^ 	"]*\).*/\3	'$dir$file'	\/^\2\3\"\//p' \
      -e 's/^\([^:]*\):\(.*DEF[ 	]*\)\([^ 	]*\).*/\3	'$dir$file'	\/\2\3\//p' | sort -d
else
  egrep -n "(^# Object[ 	]|DEF[ 	])" $* | \
  sed -ne 's/^\([^:]*\):\([^:]*\):\(# Object[ 	]*\"\)\([^ 	"]*\).*/\4	\1	\/^\3\4\"\//p' \
      -e 's/^\([^:]*\):\([^:]*\):.*\(DEF[ 	]*\)\([^ 	"]*\).*/\4	\1	\/\3\4\//p' | sort -d
fi
exit 0
