#!/bin/sh
#
# vdmindex foo
#
# takes foo.idx and writes out type and function indexes on
# typeidx.idx and fnidx.idx

sed -e 's/\\unhbox \\voidb@x \\kern .06em\\vbox {\\hrule height.2exwidth.3em}\\penalty \\@postUnderPenalty \\hskip 0.1em/_/g' -e 's/@/\\sb /g' -e 's/\\atletter/@/g' \
               $1.idx >/tmp/vdmidx$$
cp /tmp/vdmidx$$ $1.idx
rm -f /tmp/vdmidx$$
egrep '({type-)|({rec-)' $1.idx |
               sed -e 's/{type-/{/' -e 's/{rec-/{/' >typeidx.idx
egrep '({fn-)|({op-)' $1.idx |
               sed  -e 's/{fn-/{/' -e 's/{op-/{/' >fnidx.idx
makeindex typeidx.idx
makeindex fnidx.idx