[comp.unix.ultrix] Troff

steve@vorga.umiacs.umd.edu (Steve D. Miller) (07/19/89)

   I have (finally) gotten troff working on the DECstation 3100.  I was
unable to get the new (ASCII) format font width tables from anyone at DEC,
so I decided to port the 4.3BSD troff and to punt the Ultrix troff.  Easier
said than done.  Warning:  description of gross code follows.  Don't read
this if you've eaten in the last hour or so...

   The 4.3BSD troff (and many other troffs, including the Berkeley-style
ditroff I've seen) does something almost criminally gross.  First, it
declares about 6K worth of variables together, assuming that they will be
placed together by the compiler.  There's a total of 71 variables declared
in this section.  Then, when it hits a .ev directive, it changes
environments by:

	1) Take the address of the first variable declared in the list.

	2) Multiply the current environment number (0, 1, or 2) by 6144,
	and lseek() out that far in some file in /tmp.

	3) Write 6K from memory (starting at the address from (1) above)
	into the temp file.

	4) Do another lseek() and read another 6K in from somewhere else
	in the file.

   Although gross, this works fine if your compiler allocates variables in
declaration order.  However, the DECstation C compiler does not do this.
Can you say, "trash lots of random variables?"  I knew you could...

   Also, once the 4.3BSD troff is working, you need font width tables in a
format you can use.  Any font width table produced in the normal way (i.e.,
'cc -o ftR ftR.c'; TranScript does this, by the way) will not be in the
proper format, as the binary produced will be in COFF format.  You will need
to run a converter across your COFF-style tables to turn them into a.out
files, which the BSD troff will then be able to read.

   I have fixes for the 4.3BSD troff to clean up the environment handling to
the point that it works.  I also have a COFF->a.out converter that does
what's needed in this situation.  They're available for anonymous FTP from
fnord.umiacs.umd.edu (128.8.120.3), as pub/trofffix.shar and
pub/psfixfont.c.  If you want them and can't FTP them, let me know, and I'll
try to find time to send them to you.  Please grab these only during the off
hours; I still read my mail on fnord, and it's only a Sun-3/60...  Also note
that the 4.3BSD nroff won't work on DECstations, as DEC not only changed the
terminal description tables, they actually shipped the new-style tables.

   With all these changes applied, we can actually troff to our Imagens
and our PostScript printers from our DECstations.  Whoopee.

   If you get these fixes, please let me know; I'm curious as to how many
people still use troff, and how many really need this to work.  Are we really
that unusual?

	-Steve


Spoken: Steve Miller    Domain: steve@mimsy.umd.edu    UUCP: uunet!mimsy!steve
Phone: +1-301-454-1808  USPS: UMIACS, Univ. of Maryland, College Park, MD 20742

abe@mace.cc.purdue.edu (Vic Abell) (07/19/89)

In article <18615@mimsy.UUCP> steve@umiacs.umd.edu (Steve D. Miller) writes:
>   Also, once the 4.3BSD troff is working, you need font width tables in a
>format you can use.

There are at least two other fixes: 1) convert the troff code to read COFF
format files directly (I did this once and it's not too hard); or 2) use the
troff in DWB 2.0 where the font tables are no longer required in C compiler
output format, but are simple text files.

rusty@garnet.berkeley.edu (07/19/89)

In article <18615@mimsy.UUCP> steve@vorga.umiacs.umd.edu (Steve D. Miller) writes:

   Path: ucbvax!agate!bionet!ames!haven!mimsy!vorga.umiacs.umd.edu!steve
   From: steve@vorga.umiacs.umd.edu (Steve D. Miller)
   Newsgroups: comp.unix.ultrix
   Subject: Troff (finally) working on DECstations
   Date: 18 Jul 89 17:30:24 GMT
   Sender: nobody@mimsy.UUCP
   Reply-To: steve@umiacs.umd.edu (Steve D. Miller)
   Distribution: na
   Organization: UMIACS, Univ. of Maryland, College Park, MD 20742
   Lines: 58

   If you get these fixes, please let me know; I'm curious as to
   how many people still use troff, and how many really need this to
   work.  Are we really that unusual?

As a diehard tex hacker all I can say is "let's hope so".
--

--------------------------------------
	rusty c. wright
	rusty@violet.berkeley.edu ucbvax!violet!rusty

steve@vorga.umiacs.umd.edu (Steve D. Miller) (07/19/89)

   Sure, you can hack troff to read COFF or ASCII format tables, if that's
what you'd prefer.  For my purposes, I'd rather work with the a.out format
tables; some of the software I have to deal with spits out a.out-format
files without doing any compilation, and it just seems more backward-
compatible to me.  No big deal either way.  Hacking troff to read a.out,
COFF, and ASCII formats would also not be too hard (assuming that you know
what the ASCII format looks like...)

   By the way, what do the DWB 2.0 font width tables look like?  I'd guess
that's the format that the DEC-distributed troff uses.

	-Steve

Spoken: Steve Miller    Domain: steve@mimsy.umd.edu    UUCP: uunet!mimsy!steve
Phone: +1-301-454-1808  USPS: UMIACS, Univ. of Maryland, College Park, MD 20742

jlo@elan.elan.com (Jeff Lo) (07/20/89)

In article <2742@mace.cc.purdue.edu> abe@mace.cc.purdue.edu (Vic Abell) writes:
>There are at least two other fixes: 1) convert the troff code to read COFF
>format files directly (I did this once and it's not too hard); or 2) use the
>troff in DWB 2.0 where the font tables are no longer required in C compiler
>output format, but are simple text files.

Well, DWB 2.0 still uses binary format width tables, but they are not
in a.out format.  DWB comes with a table compiler called makedev, which
reads the ASCII format width table source and converts it into the
required binary format.  Also to use the DWB 2.0 troff, you have to get
DWB 2.0, which is unbundled from un*x.  You can either get it from AT&T
in source form (maybe 3B2 binaries too), or from a third party vendor.
If you're interested in a supported third party troff, call or send me mail.
-- 
Jeff Lo, Elan Computer Group, Inc.
jlo@elan.com, ..!{ames,uunet}!elan!jlo
888 Villa Street, Third Floor, Mountain View, CA 94041, 415-964-2200

abe@mace.cc.purdue.edu (Vic Abell) (07/20/89)

In article <578@elan.elan.com> jlo@elan.elan.com (Jeff Lo) writes:
>>In article <2742@mace.cc.purdue.edu> abe@mace.cc.purdue.edu (Vic Abell) writes:
>Well, DWB 2.0 still uses binary format width tables, but they are not
>in a.out format.  DWB comes with a table compiler called makedev


Jeff is correct.  it is the dwb 2.0 nroff that no longer needs to have
its terminal driver tables in a.out format.  They are now ASCII files
and no longer need to be compiled to be acceptable to nroff.  It was my
mistake in confusing the question about font tables of troff with the
terminal driver tables of nroff in the original query.