iprint.icn: Program to print Icon program

March 26, 2002; Robert J. Alexander
This file is in the public domain.
   The defaults are set up for printing of Icon programs, but
through command line options it can be set up to print programs
in other languages, too (such as C). This program has several
features:

   If a program is written in a consistent style, this program
will attempt to keep whole procedures on the same page. The
default is to identify the end of a print group (i.e. a pro-
cedure) by looking for the string "end" at the beginning of a
line. Through the -g option, alternative strings can be used to
signal end of a group. Using "end" as the group delimiter
(inclusive), comments and declarations prior to the procedure are
grouped with the procedure. Specifying a null group delimiter
string (-g '') suppresses grouping.

   Page creases are skipped over, and form-feeds (^L) embedded in
the file are handled properly. (Form-feeds are treated as spaces
by many C compilers, and signal page ejects in a listing). Page
headings (file name, date, time, page number) are normally
printed unless suppressed by the -h option.

   Options:

     -n   number lines.

     -pN  page length: number of lines per page (default: 60
          lines).

     -tN   tab stop spacing (default: 8).

     -h   suppress page headings.

     -l   add three lines at top of each page for laser printer.

     -gS  end of group string (default: "end").

     -cS  start of comment string (default: "#").

     -xS  end of comment string (default: none).

     -i   ignore FF at start of line.

   Any number of file names specified will be printed, each
starting on a new page.

   For example, to print C source files such as the Icon source
code, use the following options:

   iprint -g ' }' -c '/*' -x '*/' file ...

   Control lines:

   Control lines are special character strings that occur at the
beginnings of lines that signal special action. Control lines
begin with the start of comment string (see options). The control
lines currently recognized are:

   <comment string>eject -- page eject (line containing "eject"
does not print).

   <comment string>title -- define a title line to print at top
of each page. Title text is separated from the <comment
string>title control string by one space and is terminated by
<end of comment string> or end of line, whichever comes first.

   <comment string>subtitle -- define a sub-title line to print
at top of each page. Format is parallel to the "title" control
line, above.

   If a page eject is forced by maximum lines per page being
exceeded (rather than intentional eject via control line, ff, or
grouping), printing of blank lines at the top of the new page is
suppressed. Line numbers will still be printed correctly.

Source code | Program Library Page | Icon Home Page