#!/bin/sh

process () {
sed \
 -e '1s/^/\\SourceFile'{$1}/ \
 -e '/^.PE/ {
i\
.PE\
\\Setlineno
=
d
}' $1
}

from=$1

case $from in
  *.tex) ;;
  *.ltx) 
     to=`basename $from .ltx`.tex
     process $from | gpic -t > $to 
     ;;
esac
