3 # fix.pl 17-Nov-93 Craig Milo Rogers at USC/ISI
5 # The style guide for RFCs calls for pages to be delimited by the
6 # sequence <last-non-blank-line><formfeed-line><first-non-blank-line>.
7 # Unfortunately, NROFF is reluctant to produce output that conforms to
8 # this convention. This script fixes RFC-style documents by searching
9 # for the token "FORMFEED[Page", replacing "FORMFEED" with spaces,
10 # appending a formfeed line, and deleting white space up to the next
11 # non-white space character.
13 # There is one difference between this script's output and that of
14 # the "fix.sh" and "pg" programs it replaces: this script includes a
15 # newline after the formfeed after the last page in a file, whereas the
16 # earlier programs left a bare formfeed as the last character in the
17 # file. To obtain bare formfeeds, uncomment the second substitution
18 # command below. To strip the final formfeed, uncomment the third
19 # substitution command below.
21 # This script is intended to run as a filter, as in:
23 # nroff -ms input-file | fix.pl > output-file
25 # When porting this script, please observe the following points:
27 # 1) ISI keeps perl in "/local/bin/perl"; your system may keep it
29 # 2) On systems with a CRLF end-of-line convention, the "0s below
30 # may have to be replaced with "^[70s.
32 $* = 1; # Enable multiline patterns.
33 undef $/; # Read whole files in a single
36 while (<>) { # Read the entire input file.
37 s/FORMFEED(\[Page\s+\d+\])\s+/ \1\n\f\n/g;
38 s/\f\n$/\f/; # Want bare formfeed at end?
39 print; # Print the resultant file.