choosing a pager/formatter for source listings, please. (fwd)

Greg Hankins gregh at cc.gatech.edu
Wed Feb 21 17:04:44 EST 1996


ALE'rs:

I have a script which accepts a list of filenames and produces a
printout of those files, sequentially paginated, with some file-specific
and some constant header and footer text on each page.  I use 'groff -mgs'
as a formatter.  I have a few C and C++ files which apparently include
notation which trips the formatter by resembling macros.  (I had used a
'nroff' version under SunOS which may have been less sensitive to this,
but I can't test it just now.)

I would appreciate hearing others' favorite tools for this type of task.
Just for laughs, I attach my script.  (I also want to acknowledge the help
of several people in getting this version to work -- notably, Arnold Robbins
of this list. Thanks, all.)

Thanks -- john mills --

******************** 'list_runoff' script ******************

#!/bin/sh

#! conditionally set parameters
FIRSTPAGE=1
LISTNAMES=''
DOCNAME=''
PROJNAME=''
SECTNAME=''
PRINT_DATE=`date '+%d %b %Y'`

if [ $# -ge 1 ]
then
  LISTNAMES=$1
else
  echo "usage: list_runoff <filelist> [initial page_no]" >&2
  exit
fi

if [ $# -ge 2 ]
then
  FIRSTPAGE=$2
fi
 
#! alphabetize list for correct output pagination
sort -o printorder -f $LISTNAMES

echo printing from \'$LISTNAMES\' with pages starting from $FIRSTPAGE, on $PRINT_DATE >&2

#! print each file's prefix and text to groff
for FILENAME in `cat printorder`
do
  if [ -f $FILENAME ]
  then
    cat - << MARKER|cat - $FILENAME
.nr PS 10
.R
.P1
.nr PO 1.25i
.nr LT 6.5i
.nr LL 6.5i
.nr HM 1.25i
.nr FM 0.5i
.pl 702p
.ds LH \fBFILE:  $FILENAME\fP
.ds CH
.ds RH \fB$DOCNAME\fP
.ds LF \fB$PROJNAME\fP
.ds CF \fB$SECTNAME%\fP
.ds RF \fB$PRINT_DATE\fP
.ND
.LP
.bp
.nf
.CW
MARKER
  fi
done |groff -mgs -n$FIRSTPAGE -Tps |lpr -h

************************************************************






More information about the Ale mailing list