#! /bin/csh
# --------------------------------------------------------------------------- #
# quickfix to get [tn]roff output without thinking                            #
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# dispatches on argv[0] for psroff or nroff; uses all known preprocessors in  #
# optimal order; provides \(LM and \(FN macros on a per file basis; assumes   #
# the -me package; if interrupted, leaves assembled text in /tmp              #
# --------------------------------------------------------------------------- #

onintr interrupt

set flags=()
set macropkg=-me
switch (`basename $0`)
  case setup:
	set fmtr="nroff $macropkg"
	breaksw
  case psetup:
	set fmtr="psroff $macropkg"
	breaksw
endsw
set output=/tmp/$$
/bin/rm -f $output
touch $output
echo .ds HD ~ >> $output			# HomeDirectory
echo ".ds RO \*(HD/who/rolo" >> $output		# ROlodex subdir

foreach x ($argv)
	switch ($x)
 	  case -*:
		set flags=($flags $x)
		shift
 		breaksw
 	  case *:
		echo .ds LM `lastmod $x` >> $output	# LastModified
		echo .ds FN $x >> $output		# FileName
		echo .ds TF $output >> $output		# TempFile
		cat $x >> $output
		shift
		breaksw
	endsw
end

(eval "(soelim $output | pic | tbl | eqn | $fmtr $flags)")

/bin/rm -f $output
exit 0

interrupt:
	echo Procedure aborted, no $fmtr run.
	exit 1
