Help with man macros

John E Van Deusen III jiii at visdc.UUCP
Mon Aug 14 09:08:10 AEST 1989


In article <16001 at vail.ICO.ISC.COM> rcd at ico.ISC.COM (Dick Dunn) writes:
>
> ...it's probably easier to develop the filter if you use a different
> terminal type--create one of your own which is adapted to produce
> easily-parsed data for the things the filter has to re-hack and which
> minimizes the number of sequences the filter has to handle.
>-- 
>Dick Dunn     rcd at ico.isc.com    uucp: {ncar,nbires}!ico!rcd     (303)449-2870
>   ...Simpler is better.

As was discussed earlier, there really isn't that much that modifying
the nroff driving tables enables you to do.  Although you can accomplish
quite a bit toward making perfect, terminal-specific \(dg and \(bu
special fonts, the italic font is always produced by the sequence  _^Hx,
(where x is the underlined character).  Likewise, the bold font is
always produced by repetitions of x^Hx.  From my experience it is both
possible and desirable to create a filter that can intercept the
specific escape sequences for ALL of the terminal types in use on the
machine.

It is desirable to be able to do this, because nroff does produce other
escape codes that are incompatible with certain printers.  For instance,
the half-line up sequence for the default Teletype 37 is Esc 9.  If that
sequence is sent to a Diablo 630, it will reset the left margin to the
current print position.  Thus, a user forgetting to specify -Tlp when
invoking the man(1) command, with the output directed to lp(1), could
screw up not only his own output, but also everything printed
thereafter.

The trick is for the filter to try to determine the terminal type for
which the nroff output was generated by examining the data stream.
For example, the Teletype 37 output, as supplied with my system, does
not output anything at the start of the data set.  In contrast, the
-T450 data stream begins with an Esc 4.  Thus, a filter can know to
convert Esc 9 to Esc D if there is not an Esc 4 at the beginning of the
data.

Since the filter is device specific, it should be invoked by the
/usr/spool/lp/interface/xxx program, (where xxx is the name of the
printer), because these programs are also bound to a particular device.
A more important function than correctly interpreting nroff escape
sequences is for the filter to protect the printer from random data.
It should definately recognize the escape sequences that do system
resets or change the number of lines per page and exit if those
sequences are encountered in a "normal" data stream.
--
John E Van Deusen III, PO Box 9283, Boise, ID  83707, (208) 343-1865

uunet!visdc!jiii



More information about the Comp.unix.wizards mailing list