ref: 2b99422480d596ebc26921c87c6bb81a07949f3e
dir: /labels/
#!/bin/rc
rfork e
numfile=NUMBERS
ofis='
'
nifs='
'
ref=''
fn multigrepref {
section=`{cat $numfile}
for (part in $*) {
section=`{echo $section | grep -i $part}
}
ref=`{ echo $section | awk '{ printf "%s", $1 }'}
}
fn getreflookup {
lb=`{echo $* | awk '/\[\[!/ { split($0, a, "!"); printf "%s", a[2]}'}
ifs=' '
sanelb=`{echo $lb}
multigrepref $sanelb
}
fn getref {
ref=`{grep -i -e $1 $numfile | awk '{printf "%s", $1}'}
}
fn getrefinfo {
shift
reft=$1
shift
refstr=$*
}
for (chap in $*) {
ifs=$nifs
for (line in `{cat $chap}) {
if (~ $line *[\[][\[]!*!]]* ) {
getreflookup $line
echo $line | sed s/\[\[!.*!\]\]/$ref/
}
if not {
if (~ $line .LE* ) {
ifs=' '
getrefinfo `{echo $line}
switch($reft) {
case F
type='Figure'
case T
type='Table'
}
refstr=`{echo $refstr | awk '{printf "%s", $0}'}
str=`{echo $refstr | tr -d '()' }
str=`{echo $str | sed -e 's/\\f[^ ]*//g' -e 's/-[^ ]*//g' | awk '{ printf "%s", $0}'}
multigrepref $str
echo .DS C
echo '\fB'$type $ref:'\fP' $refstr
echo .DE
}
if not {
echo $line
}
}
}
ifs=$oifs
}