[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Printing Source Code
- Subject: [ale] Printing Source Code
- From: jmmills at telocity.com (John Mills)
- Date: Tue, 19 Mar 2002 21:45:47 -0500 (EST)
Hello, Chris -
We had to print about 2,000 pages of source listings in Ada, and I (with
much help from this list) ended up with a runoff script I like a lot.
You hand-edit some headers and footers, and other items like the date are
put in automatically (unless you inactivate them). You can work
sectionally: this means you can print a hundred or so pages at a time,
from a partial list of the files to print, so you can re-do a smaller
fileset if the job scr*ws up. I didn't work it that way, but PostScript
output could be captured rather than sent to the printer.
There is a bit of filtering source constructs which get confused with
'nroff' commands - you may want to tune that a bit for the language you're
printing. I remember it as pretty clean for Ada, generally OK for C/C++,
and a "really hurtin' turkey" for LaTex [source].
It is driven by a list of filenames, provided in a file. (It also runs
happily in a pipe, as in:
# ls <dir_path> | list_runoff -
It reads the list, saves it to a temporary file, and can optionally sort
the list before printing those files.
Try a few files and see how it acts.
You'll probably see some improvements once you have the idea: consider it
a starting point and send me back any changes you make for better 'C'
handling or cool features.
On Tue, 19 Mar 2002, Chris Fowler wrote:
> I need to print about 50,000 lines of C source code. I want to print on
> both sides of the paper, punch, and bind.
> I've determined that pr -o 8 -n *.c will number, pagenate, and head each
> page. I'm trying to
> decide what is the best way to print them. I thought about converting to
> DOS (unix2dos) format and taking
> to Kinko's to finish. Has anyone else had to print a pile of source before?
> I've determined that to print all the source that I've
> written over the last 5 months would require 1 ream of paper. That is
> printed front and back. Thankfully I created a standard library otherwise
> that would have been 2 reams of paper.
- John Mills
#! conditionally set parameters
PRINT_DATE=`date '+%d %b %Y'`
if [ $# -ge 1 ]
echo "usage: list_runoff <filelist> [initial page_no]" >&2
if [ $# -ge 2 ]
#! alphabetize list for correct output pagination
sort -o $TEMPFILE -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 $TEMPFILE`
if [ -f $FILENAME ]
cat - << MARKER
.nr PS 10
.nr PO 1.25i
.nr LT 6.5i
.nr LL 6.5i
.nr HM 1.25i
.nr FM 0.5i
.ds LH \fBFILE: $FILENAME\fP
.ds RH \fB$DOCNAME\fP
.ds LF \fB$PROJNAME\fP
.ds CF \fB$SECTNAME%\fP
.ds RF \fB$PRINT_DATE\fP
sed 's/\\/&e/g' < $FILENAME
done |groff -mgs -n$FIRSTPAGE -Tps |lpr
# to supress burst-sheet:
# done |groff -mgs -n$FIRSTPAGE -Tps |lpr -h
if [ -f $TEMPFILE ]
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.