v08i048: roff (simple script to include filters & macros in document text)

Brandon S. Allbery - comp.sources.misc allbery at uunet.UU.NET
Sun Sep 24 07:04:58 AEST 1989


Posting-number: Volume 8, Issue 48
Submitted-by: brian at decwrl.dec.com@apt.UUCP
Archive-name: roff_bl

This script allows you to include a comment at the beginning of your
troff documents which tells this script what filters and macros to
run the document through before sending it to troff.

<>  Brian Litzinger @ APT Technology Inc., San Jose, CA
<>  UUCP:  {apple,sun,pyramid}!daver!apt!brian    brian at apt.UUCP
<>  VOICE: 408 370 9077      FAX: 408 370 9291

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  README Portability roff
# Wrapped by brian at apt on Wed Sep 20 13:15:36 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1420 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
Xroff is a script that allows you to encode the filters that a troff
Xfile must be passed through along with which macro packages to use
Xin the document file.
X
XTo use roff you simply add a roff command line as the first line of
Xyour document file.  Then when you wish to print out the document
Xyou can simply enter
X
X    roff filename
X
Xroff will generate the correct command stream to print the file.
X
Xthe roff command line is basically a line of text that is passed to
Xeval(1).  Its format is as follows:
X
X\" exec tbl | pic | eroff -mm
X
Xthe '\"' is a troff/nroff comment delimeter.  The 'exec' helps identify
Xthis line as a roff command line.
X
Xthe rest of the line is the filters, packages, and macros that the
Xdocument file should be passed through.  Other examples are:
X
X\" exec eroff
X
X\" exec tbl | eroff -mm -mapt
X
XIf you look at the roff script you will notice that we strip off the
Xfirst line of the document file (the roff command line) before we
Xpipe the document through the rest of the filters.  At first glance
Xone might think this isn't necessary, but the mm macros are in my
Xopinion broke, or at least the ones we have are.  If the very first
Xphysical line of the document isn't .PH "''''" you get the header.
XEven if the first line is simply a comment, like the roff command line.
X
XYou might also notice a reference to '$F'.  This is necessary for us
Xto be compatible with an older roff command line format.
END_OF_FILE
if test 1420 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'Portability' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Portability'\"
else
echo shar: Extracting \"'Portability'\" \(266 characters\)
sed "s/^X//" >'Portability' <<'END_OF_FILE'
XPortability Concerns:
X
Xroff uses head(1).  I've heard some UNIXes don't have head. sigh...
X
Xwe use eroff, you will probably want to change the second line of
Xroff from eroff to troff, and change the examples appropriately.
X
Xroff was written on a System V system.  
X
END_OF_FILE
if test 266 -ne `wc -c <'Portability'`; then
    echo shar: \"'Portability'\" unpacked with wrong size!
fi
# end of 'Portability'
fi
if test -f 'roff' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'roff'\"
else
echo shar: Extracting \"'roff'\" \(599 characters\)
sed "s/^X//" >'roff' <<'END_OF_FILE'
X# roff by Brian E. Litzinger
XTROFF=eroff
XTMP=/tmp/roff$$
Xfor file in $*
Xdo
X    case $file in
X	-*)
X	    args="$args $file"
X	;;
X	*)
X	    command_line="`head -1 $file`"
X	    b="`echo $command_line | cut -c1-8`"
X	    if [ "$b" != '\" exec ' ] ; then
X		echo "$file not roff format file!"
X		exit 2
X	    fi
X	    command="`echo $command_line | cut -c9- `"
X	    d="sed -e '1d' $file |"
X	    for i in $command ; do
X		if [ "$i" = '$F' ] ; then
X		    true
X		else
X		    if [ "$i" = "$TROFF" ] ; then
X			d="$d $i $args"
X		    else
X			d="$d $i"
X		    fi
X		fi
X	    done
X	    #echo $d
X	    eval $d
X	;;
X    esac
Xdone
END_OF_FILE
if test 599 -ne `wc -c <'roff'`; then
    echo shar: \"'roff'\" unpacked with wrong size!
fi
chmod +x 'roff'
# end of 'roff'
fi
echo shar: End of shell archive.
exit 0



More information about the Comp.sources.misc mailing list