doctype -- synthesize proper command line for troff [comp.unix.questions]

Doug Gwyn gwyn at smoke.BRL.MIL
Tue Dec 12 16:09:05 AEST 1989


Archive-name: doctype
Original-posting-by: gwyn at smoke.BRL.MIL (Doug Gwyn)
Original-subject: Re: software tools question
Reposted-by: emv at math.lsa.umich.edu (Edward Vielmetti)

[This is an experimental alt.sources re-posting from the newsgroup(s)
comp.unix.questions. Comments on this service to emv at math.lsa.umich.edu 
(Edward Vielmetti).]


In article <129057 at sun.Eng.Sun.COM> henry%angel at Sun.COM (Henry McGilton -- Software Products) writes:
>	    grap table1.src | pic | tbl | eqn > table1.fmt

This doesn't quite address the original problem, but since I've found
it handy I thought I'd post it:

#!/usr/5bin/sh
#	doctype -- synthesize proper command line for troff
#	adapted from Kernighan & Pike

#	last edit:	88/09/19	D A Gwyn
#	SCCS ID:	@(#)doctype.sh	1.9

PATH=/usr/5bin:/bin:/usr/bin
if pdp11
then	MACDIR=/usr/lib/tmac
else	MACDIR=/usr/5lib/tmac		# BRL System V emulation
fi

eopt=
macs=
opts=
topt=
for i
do	case "$i" in
	-e)	eopt="$i";		shift;;
	-m*)	macs="$macs $i";	shift;;
	-T*)	topt=" $i";		shift;;
	--)				shift;	break;;
	-)					break;;
	-*)	opts="$opts $i";	shift;;
	*)					break;;
	esac
done

if [ $# -gt 0 ]
then	s="cat $* | "
else	s=
fi

t=`cat $* |
egrep '^\.(EQ|TS|\[|P|G1|IS|SH)' |
sort -u |
awk '
/^\.SH/ { man++ }
/^\.P$/ { mm++ }
/^\.PP/ { ms++ }
/^\.EQ/ { eqn++ }
/^\.TS/ { tbl++ }
/^\.PS/ { pic++ }
/^\.PF/ { pic++ }
/^\.G1/ { grap++ }
/^\.IS/ { ideal++ }
/^\.\[/ { refer++ }
END {
	if (refer > 0)	printf "refer | "
	if (grap > 0)	printf "grap | "
	if (grap > 0 || pic > 0)	printf "_PIC_ | "
	if (ideal > 0)	printf "ideal | "
	if (tbl > 0)	printf "tbl | "
	if (eqn > 0)	printf "_EQN_ | "
	printf "_TROFF_"
	if (grap > 0 || pic > 0)	printf " -mpic"
	if (man > 0)	printf " -man"
	if (mm > 0 && man == 0)	printf " -mm"
	if (ms > 0 && mm == 0 && man == 0)	printf " -ms"
	printf " -\n"
} ' | sed -e s/_PIC_/"pic$topt"/ -e s/_EQN_/"eqn$topt"/ \
	-e s/_TROFF_/"troff$topt$opts$macs"/ -e s%' -m'%" $MACDIR/tmac."%g`

if [ -n "$eopt" ]
then	eval "$s$t"
else	echo $s$t
fi



More information about the Alt.sources mailing list