[net.micro.mac] Write2Troff bugs

kc@rna.UUCP (Kaare Christian) (11/20/85)

I have encountered and fixed two minor bugs in Write2Troff, Version 1
dated April 27, 1985. Please excuse this posting if these fixes have
already been posted. The problem is that w2t induces spurrious point
size changes or font changes in some documents.  The problem can be
repeated most easily using a macwrite document that I possess, although
the problem occurs on a variety of documents.  The bugs relate to
a structure member called nformats, which catalogs the number of format
changes in a paragraph.

In the routine processFile (in w2t.c) the individual character positions in a
paragraph are tested against a list of format changes.  Unfortunately no
note was taken of the actual usage of the list, allowing the infamous
C-ism of running off the end of an array. To fix, change line 203 from
			if(td->nformats > 0)
to
			if(--(td->nformats) > 0)
The second problem was also an "off the end" problem.  In the routine
read_text_par a loop is used to convert the format location indices from
68K format to vax format. (big endian, little endian). The loop should
churn once per format item, but unfortunately it churns once per byte of
format items, thereby swapping bytes far past the actual array end. To fix,
change line 649 from
    for ( i = nformats; i-- > 0; formp++ )
to
    for ( i = td.nformats; i-- > 0; formp++ )

For anyone who isn't familiar with Write2Troff, it is a program that
converts a macwrite document into a troff/ascii document.  It is one of
my three favorite Usenet postings from the last year, and it seems to be
somewhat unknown, judging from the number of net requests asking about
it, and judging from my mailbox whenever I mention it on the net.
Perhaps the original authors (Michael Caplinger [mike@rice.arpa], Van
Jacobson [van@lbl-rtsg.arpa]) should consider a repost, even in the
midst of this furor over the excessive activity of the mac netters.  If
people only posted things that they wrote, instead of downloading from
compuserve and then uploading to usenet, the mac traffic would be much
more bearable.  In the absence of a repost, I will of course supply
copies via mail as necessary, as I have after all of my previuos net
mentions of w2t.

Kaare Christian
The Rockefeller Univ.
cmcl2!rna!kc