[alt.sources] Psroff 2.0 Patch 6

clewis@ecicrl.UUCP (Chris Lewis) (12/15/90)

Archive-name: psroff2.0/patch.06
Submitted-by: clewis@ecicrl.uucp (Chris Lewis)

    This is official patch 06 for Psroff 2.0.
    Please apply it by:
	cd <psroff source directory>
	patch -N -p < <this file>
    Then, rebuild and reinstall.

Psroff now supports DEC's RISC/Ultrix unique, one-of-a-kind, undocumented
and unsupported troff.

The most important change is the support for RISC/Ultrix systems which
have a ASCII format for width tables (ASCIIWIDTHS in defs.h).  See
the README for more details.

Second, if ASCIIWIDTHS undef'd and HEADERSIZE > 0, the width tables will be
created with a copy of the header and trailer found in /usr/lib/font/ftR
(just in case).  The only other functionality change is that in psroff -
until now if specified a macro package for which there was no adapter
file in LIBDIR/adapters, or specified no macros at all, troff wasn't
told to reload the width tables and define ".fp" etc.  Does now.

Thank Russ Evans (e_gs18@va.nmh.ac.uk) for helping me bash away at
getting RISC/Ultrix stuff going.

./TROUBLE		comments re: ASCIIWIDTHS
./man/troff2ps.1.S	poor english...
./lib/psrofflib.S	comments re: ASCIIWIDTHS
./README		ditto, some english fixes, comment regarding HPLJ III.
./debug.c		redundant code removal
./widths/Makefile	bug fixes.
./widths/dit2catwid.c	ASCIIWIDTHS
./utils/dumpft.c	ASCIIWIDTHS
./defs.h		ASCIIWIDTHS
./troff2.c		Experimental method of emitting new characters.
./utils.c		ASCIIWIDTHS (for optimizer)
./psroff.S		include cmn.pre even if no macro package specified
./adapters/Makefile	forgot to install tmac.e (whoops)
./audit.S		comments regarding ASCIIWIDTHS

*** /tmp/PATCHold/./TROUBLE	Sat Dec 15 00:02:05 1990
--- ./TROUBLE	Sat Dec 15 00:02:10 1990
***************
*** 1,4 ****
! 		Psroff 2.0 Trouble Shooting.... 2.2 90/10/30
  
  		(psroff 1.0 users can use this to a certain extent)
  
--- 1,4 ----
! 		Psroff 2.0 Trouble Shooting.... 2.3 90/12/14
  
  		(psroff 1.0 users can use this to a certain extent)
  
***************
*** 59,65 ****
  	  of your original troff installation.  Is ftR 224 bytes long?
  	  If so, HEADERSIZE should be zero.  If not (eg: Ultrix, possibly
  	  older BSD's, some older Xenix, V7), you will have to specify
! 	  HEADERSIZE.  Ultrix wants 32.  (should be the size of an
  	  a.out header structure - od -c may give you some hints).
  	  Another way to tell is to run "file" on /usr/lib/font/ftR.
  	  Does it say "data"?  Then it probably needs HEADERSIZE 0.
--- 59,65 ----
  	  of your original troff installation.  Is ftR 224 bytes long?
  	  If so, HEADERSIZE should be zero.  If not (eg: Ultrix, possibly
  	  older BSD's, some older Xenix, V7), you will have to specify
! 	  HEADERSIZE.  VAX/Ultrix wants 32.  (should be the size of an
  	  a.out header structure - od -c may give you some hints).
  	  Another way to tell is to run "file" on /usr/lib/font/ftR.
  	  Does it say "data"?  Then it probably needs HEADERSIZE 0.
***************
*** 71,76 ****
--- 71,82 ----
  	  really needs this, but this is a way of getting the size
  	  right without having to guess/write a program to find the
  	  a.out.h size.
+ 
+ 	  RISC/Ultrix uses an ASCII format width table.  You can
+ 	  tell this if the following command:
+ 		echo ".fp 1 R" | troff -t > /dev/null
+ 	  says something about non-ascii /usr/lib/font/ftR.  If
+ 	  it does, define ASCIIWIDTHS.
  
  NOTE for PSROFF 1.0 users:
  
*** /tmp/PATCHold/./man/troff2ps.1.S	Sat Dec 15 00:02:53 1990
--- ./man/troff2ps.1.S	Sat Dec 15 00:03:00 1990
***************
*** 1,4 ****
! .\"Copyright 1988 by Chris Lewis 2.2 90/10/24
  .TH TROFF2PS 1 local
  .SH NAME
  troff2ps, troff2lj, troff2xx \- convert troff output to Postscript, HP etc.
--- 1,4 ----
! .\"Copyright 1988 by Chris Lewis 2.4 90/12/04
  .TH TROFF2PS 1 local
  .SH NAME
  troff2ps, troff2lj, troff2xx \- convert troff output to Postscript, HP etc.
***************
*** 119,125 ****
  .B -Z
  and
  .B -W
! options controller the optimizer.
  If the
  .B -Z
  option is specified, the backends attempt to coalesce strings of
--- 119,125 ----
  .B -Z
  and
  .B -W
! options control the optimizer.
  If the
  .B -Z
  option is specified, the backends attempt to coalesce strings of
***************
*** 297,303 ****
  etc.
  .SH BUGS
  Due to the nature by which special sequences are transmitted by
! troff (stderr, forced into stdin by
  .IR psroff ),
  normal troff errors will not be seen and may generate a few
  "invalid opcode" messages from troff2ps or garble on output.
--- 297,304 ----
  etc.
  .SH BUGS
  Due to the nature by which special sequences are transmitted by
! troff (troff's stderr is merged with its stdout and is piped into
! troff2ps's stdin by
  .IR psroff ),
  normal troff errors will not be seen and may generate a few
  "invalid opcode" messages from troff2ps or garble on output.
***************
*** 304,310 ****
  Normally the document will be truncated if this occurs.
  If this happens, run
  .I psroff
! with the ``-F'' option.
  .P
  Unfortunately, there is no way at present for the ".sR" macro to
  change fonts within a line - for some pretty bizarre reasons if you ask
--- 305,312 ----
  Normally the document will be truncated if this occurs.
  If this happens, run
  .I psroff
! with the ``-F'' option which will show you troff's stderr without
! generating any output.
  .P
  Unfortunately, there is no way at present for the ".sR" macro to
  change fonts within a line - for some pretty bizarre reasons if you ask
*** /tmp/PATCHold/./lib/psrofflib.S	Sat Dec 15 00:03:41 1990
--- ./lib/psrofflib.S	Sat Dec 15 00:03:44 1990
***************
*** 1,4 ****
! #	2.2 90/08/10
  #	This file controls psroff, you can insert additional printer
  #	types here.  These are eval'd *late* in processing, so that
  #	you can insert $copies etc.
--- 1,4 ----
! #	2.4 90/12/14
  #	This file controls psroff, you can insert additional printer
  #	types here.  These are eval'd *late* in processing, so that
  #	you can insert $copies etc.
***************
*** 55,67 ****
  
  troff=''
  trofftype='-T$width'
- 
  #	Uncomment the following if you're a Sun or Ultrix -F troff.
  #	Check your manual pages.  (Though some support -F without mentioning
! #	it in their manual pages).  The default is "-T" (Xenix and some others)
  #trofftype='-F%%FONTDIR%%/$width/ftXX'
  
  #	psroff generating postscript directly.
  ps	width=ps t2arg=-Tps lparg='| $LIBDIR/psxlate | rlp -d$ptr -n$copies'
  ps	ptr='gate!AppleLaser'
  #	Example optimizer entry.
--- 55,73 ----
  
  troff=''
  trofftype='-T$width'
  #	Uncomment the following if you're a Sun or Ultrix -F troff.
  #	Check your manual pages.  (Though some support -F without mentioning
! #	it in their manual pages).  The default is "-T" (Xenix and a few others)
! #	Most BSD-derived troffs use -F, including those needing ASCIIWIDTHS
! #	turned on.
  #trofftype='-F%%FONTDIR%%/$width/ftXX'
  
  #	psroff generating postscript directly.
+ #	The clause "| $LIBDIR/psxlate" is there only to reverse the pages
+ #	for some Postscript printers (eg: the ones that print the first
+ #	page face up and then drop the second page face up on top of the
+ #	first), most more recent Postscript printers don't need this so
+ #	you can remove the psxlate call alltogether.
  ps	width=ps t2arg=-Tps lparg='| $LIBDIR/psxlate | rlp -d$ptr -n$copies'
  ps	ptr='gate!AppleLaser'
  #	Example optimizer entry.
***************
*** 72,78 ****
  tps	lparg='| $LIBDIR/psxlate | rlp -d$ptr -n$copies' ptr='gate!AppleLaser'
  
  #	System V'ish LJ printing to printer called laser.
! #	(Does your lp filter script support -og? (8 bit, no filtering))
  
  lj	width=lj t2arg=-Tlj lparg='| lp -d$ptr -og -n$copies' ptr=laser
  
--- 78,84 ----
  tps	lparg='| $LIBDIR/psxlate | rlp -d$ptr -n$copies' ptr='gate!AppleLaser'
  
  #	System V'ish LJ printing to printer called laser.
! #	(Your lp filter script should support -og (8 bit, no filtering))
  
  lj	width=lj t2arg=-Tlj lparg='| lp -d$ptr -og -n$copies' ptr=laser
  
*** /tmp/PATCHold/./README	Sat Dec 15 00:04:18 1990
--- ./README	Sat Dec 15 00:04:26 1990
***************
*** 1,4 ****
! 		PSROFF RELEASE 2.0 PL5 README 2.3 90/11/16
  
  			May 14, 1990
  			Chris Lewis
--- 1,4 ----
! 		PSROFF RELEASE 2.0 PL5 README 2.4 90/12/14
  
  			May 14, 1990
  			Chris Lewis
***************
*** 362,367 ****
--- 362,381 ----
  	  In any event, if you have problems and wish to ask me for help,
  	  I will be requiring that you mail me a copy of the output
  	  of "make check".
+ 	  
+ 	  If you're running on RISC Ultrix ignore any HEADERSIZE or
+ 	  trofftype messages.  The reason for this is that RISC
+ 	  Ultrix comes with width tables that cannot be read
+ 	  by the RISC Ultrix troff, and make check will be fooled.
+ 	  define ASCIIWIDTHS in defs.h in this case.  trofftype
+ 	  in psrofflib should be the -F variant in this case.
+ 
+ 	  Psroff builds width table files that *can* be used by
+ 	  RISC/Ultrix troff.  You can tell if you need ASCIIWIDTHS
+ 	  defined if:
+ 	    echo ".fp 1 R" | troff -t > /dev/null
+ 	  says something nasty about non-numeric character in file,
+ 	  "may be non-ASCII".
  
  	- type "make unpackljfonts"  This will uudecode the font
  	  files I've supplied and remove the .UU files.  This
***************
*** 394,401 ****
  	  pertain to you.  Take special note of HEADERSIZE.  Take a look
  	  at /usr/lib/font/ftR.  Is it 224 bytes long?  If so, HEADERSIZE
  	  should be 0.  Otherwise you will probably have to set it to the
! 	  size of your a.out.h structure.  Ultrix and Sun appear to always
! 	  be HEADERSIZE = 32.
  
  	  With Laserjet driving:
  
--- 408,415 ----
  	  pertain to you.  Take special note of HEADERSIZE.  Take a look
  	  at /usr/lib/font/ftR.  Is it 224 bytes long?  If so, HEADERSIZE
  	  should be 0.  Otherwise you will probably have to set it to the
! 	  size of your a.out.h structure.  VAX Ultrix and Sun appear to always
! 	  be HEADERSIZE = 32.  See remark about RISC Ultrix above.
  
  	  With Laserjet driving:
  
***************
*** 440,449 ****
  	  check out your troff manual page!  Suns and Ultrix want
  	  trofftype='-F/usr/lib/font/$width/ftXX'.
  
! 	- If you're going to be driving HP Laserjets:
  
! 	  If you have PK fonts from TeX, ensure that PKFONTS is set
! 	  reasonably in the Makefile.  type:
  
  		make buildljfonts
  
--- 454,467 ----
  	  check out your troff manual page!  Suns and Ultrix want
  	  trofftype='-F/usr/lib/font/$width/ftXX'.
  
! 	- If you're going to be driving HP Laserjets without a Postscript
! 	  cartridge:
  
! 	  If you have an HPLJ III, mark in lj.fonts all of the fonts
! 	  as built-in, you don't need to build any fonts.
! 
! 	  Otherwise, If you have PK fonts from TeX, ensure that PKFONTS
! 	  is set reasonably in the Makefile.  type:	
  
  		make buildljfonts
  
*** /tmp/PATCHold/./debug.c	Sat Dec 15 00:05:12 1990
--- ./debug.c	Sat Dec 15 00:05:16 1990
***************
*** 2,22 ****
  
  #ifndef	lint
  static char SCCSid[] =
!     "@(#)debug.c: 2.4 Copyright 90/10/22 14:53:06 Chris Lewis";
  #endif
  
  #ifdef	DEBUG
  
  int debug = 0;
- 
- #define	D_CAT	1
- #define	D_SPEC	2
- #define	D_CHAR	4
- #define	D_FONT	8
- #define	D_BEND	0x10
- #define	D_PK	0x20
- #define	D_VERB	0x40
- #define	D_FLSH	0x80
  
  struct dbm {
      char req;
--- 2,13 ----
  
  #ifndef	lint
  static char SCCSid[] =
!     "@(#)debug.c: 2.5 Copyright 90/12/04 09:27:38 Chris Lewis";
  #endif
  
  #ifdef	DEBUG
  
  int debug = 0;
  
  struct dbm {
      char req;
*** /tmp/PATCHold/./widths/Makefile	Sat Dec 15 00:05:43 1990
--- ./widths/Makefile	Sat Dec 15 00:05:47 1990
***************
*** 1,4 ****
! #2.4 90/08/08
  SCRIPTS	= gfnttab
  TD	= testdir
  PSW	= \
--- 1,4 ----
! #2.6 90/12/13
  SCRIPTS	= gfnttab
  TD	= testdir
  PSW	= \
***************
*** 219,225 ****
--- 219,227 ----
  
  test:	dit2catwid $(SCRIPTS)
  	test -d $(TD) || mkdir $(TD)
+ 	rm -f $(TD)/*
  	cp widthps/S $(TD)/S
+ 	chmod +w $(TD)/S
  	sed -e '1,/charset/d' widthps/S2 >> $(TD)/S
  	./dit2catwid -v $(TD)/S widthps/R $(TD)/ftR > $(TD)/ftR.nout
  	@echo "Comparing $(TD)/ftR and $(FONTDIR)/ps/ftR"
***************
*** 235,240 ****
--- 237,243 ----
  	rm -f gfnttab.log pk2dit.log pk2sep.log pk2dit.err pk2sep.err
  
  dit2catwid.o:	../defs.h
+ 	$(CC) -c $(CFLAGS) '-DFONTDIR="$(FONTDIR)"' dit2catwid.c
  
  ../cattab.o:	../defs.h
  	@echo "cattab.o is out of date, please run make troff2ps in top level first"
*** /tmp/PATCHold/./widths/dit2catwid.c	Sat Dec 15 00:06:21 1990
--- ./widths/dit2catwid.c	Sat Dec 15 00:06:29 1990
***************
*** 1,4 ****
! /*	Copyright 1985, 1986, 1987, 1988 16:47:45 Chris Lewis
  		All Rights Reserved
  
      Permission to copy and further distribute is freely given provided
--- 1,4 ----
! /*	Copyright 1985, 1986, 1987, 1988 23:47:50 Chris Lewis
  		All Rights Reserved
  
      Permission to copy and further distribute is freely given provided
***************
*** 13,19 ****
  
  #ifndef	lint
  static char SCCSID[] =
!     "@(#)dit2catwid.c 2.1 Copyright 90/07/18 16:47:45 Chris Lewis";
  #endif
  
  #include <stdio.h>
--- 13,19 ----
  
  #ifndef	lint
  static char SCCSID[] =
!     "@(#)dit2catwid.c 2.4 Copyright 90/12/14 23:47:50 Chris Lewis";
  #endif
  
  #include <stdio.h>
***************
*** 20,25 ****
--- 20,31 ----
  #include "../defs.h"
  #include <ctype.h>
  
+ #ifndef	ASCIIWIDTHS
+ 
+ #ifndef	FONTDIR
+ #define	FONTDIR	"/usr/lib/font"
+ #endif
+ 
  #ifndef	HEADERSIZE
  #	ifdef COFF
  #		include <aouthdr.h>
***************
*** 36,46 ****
--- 42,55 ----
  #	endif
  #endif
  
+ #endif
+ 
  int res = 300;
  int unitwid = 10;
  int symfont = 0;
  int verbose = 0;
  int genc = 0;
+ int headersize = -1;
  
  #define	TROFFUWID	6
  
***************
*** 65,76 ****
  
      progname = argv[0];
  
!     while ((c = getopt(argc, argv, "vsr:u:ch")) != EOF)
  	switch(c) {
  	    case 'h':
  		printf("%d\n", HEADERSIZE);
  		exit(0);
  		break;
  	    case 's':
  		symfont = 1;
  		break;
--- 74,92 ----
  
      progname = argv[0];
  
!     while ((c = getopt(argc, argv, "vsr:u:chH:")) != EOF)
  	switch(c) {
  	    case 'h':
+ #ifdef	ASCIIWIDTHS
+ 		printf("ascii\n");
+ #else
  		printf("%d\n", HEADERSIZE);
+ #endif
  		exit(0);
  		break;
+ 	    case 'H':
+ 		headersize = atoi(optarg);
+ 		break;
  	    case 's':
  		symfont = 1;
  		break;
***************
*** 186,199 ****
  struct cattab *symset;
  char *type, *file; {
      int i, j;
!     /* This simply prepends HEADERSIZE bytes to the font width file.
!        This may not be adequate for some troffs, in that some of the
!        fields in the appropriate object headers have to be filled in.
!        If this is a problem, use dit2catwid -c and compile it manually.
      */
  
!     for (i = 0; i < HEADERSIZE; i++)
! 	fputc('\0', f);
  
      for (i = 0, j = 0; i < 224; i++) {
  
--- 202,243 ----
  struct cattab *symset;
  char *type, *file; {
      int i, j;
! 
! #ifdef	ASCIIWIDTHS
! #define	EMITWID(v,f)	fprintf(f, "%d\n", v)
! #else
! #define	EMITWID(v,f)	fputc(v, f)
! 
!     FILE *of = (FILE *) NULL;
!     /* If headersize != 0 AND there's a FONTDIR/ftR, output
!        the first headersize bytes of it, then the new width table,
!        then the trailing bytes of FONTDIR/ftR.  If there's
!        no FONTDIR/ftR, we just prepend headersize 0's.
!        The reason for this is that some troff's insist on valid
!        headers.
      */
  
!     if (headersize == -1)
! 	headersize = HEADERSIZE;
! 
!     if (headersize != 0) {
! 	char buf[128];
! 	sprintf(buf, "%s/%s", FONTDIR, "ftR");
! 	if (of = fopen(buf, "r")) {
! 	    for (i = 0; i < headersize; i++)
! 		fputc(fgetc(of), f);
! 	    for (i = 0; i < 224; i++)
! 		fgetc(of);
! 	    if (feof(of)) {
! 		fclose(of);
! 		of = (FILE *) NULL;
! 	    }
! 	} else {
! 	    for (i = 0; i < headersize; i++)
! 		fputc('\0', f);
! 	}
!     }
! #endif
  
      for (i = 0, j = 0; i < 224; i++) {
  
***************
*** 203,209 ****
  
  	/* not the right position yet */
  	if (!symset[j].ch_name || i < symset[j].ch_wididx) {
! 	    fputc('\0', f);
  	    continue;
  	}
  
--- 247,253 ----
  
  	/* not the right position yet */
  	if (!symset[j].ch_name || i < symset[j].ch_wididx) {
! 	    EMITWID('\0', f);
  	    continue;
  	}
  
***************
*** 216,226 ****
  	if (!(symset[j].ch_info&0x3f)) {
  	    printf("INFO: No width for %s (index %d, file %s)\n",
  		symset[j].ch_name, symset[j].ch_wididx, file);
! 	    fputc(symset[0].ch_info, f);
  	} else
! 	    fputc(symset[j].ch_info, f);
  	j++;
      }
  
      dumpset(symset, "After CAT dump");
  
--- 260,278 ----
  	if (!(symset[j].ch_info&0x3f)) {
  	    printf("INFO: No width for %s (index %d, file %s)\n",
  		symset[j].ch_name, symset[j].ch_wididx, file);
! 	    EMITWID(symset[0].ch_info, f);
  	} else
! 	    EMITWID(symset[j].ch_info, f);
  	j++;
      }
+ 
+ #ifndef	ASCIIWIDTHS
+     if (of) {
+ 	while((i = fgetc(of)) != EOF)
+ 	    fputc(i, f);
+ 	fclose(of);
+     }
+ #endif
  
      dumpset(symset, "After CAT dump");
  
*** /tmp/PATCHold/./utils/dumpft.c	Sat Dec 15 00:07:24 1990
--- ./utils/dumpft.c	Sat Dec 15 00:07:28 1990
***************
*** 1,4 ****
! /*	Copyright 1985, 1986, 1987, 1988 16:50:16 Chris Lewis
  		All Rights Reserved
  
      Permission to copy and further distribute is freely given provided
--- 1,4 ----
! /*	Copyright 1985, 1986, 1987, 1988 00:00:11 Chris Lewis
  		All Rights Reserved
  
      Permission to copy and further distribute is freely given provided
***************
*** 13,19 ****
  
  #ifndef	lint
  static char SCCSID[] =
!     "@(#)dumpft.c 2.1 Copyright 90/07/18 16:50:16 Chris Lewis";
  #endif
  
  #include "../defs.h"
--- 13,19 ----
  
  #ifndef	lint
  static char SCCSID[] =
!     "@(#)dumpft.c 2.6 Copyright 90/12/15 00:00:11 Chris Lewis";
  #endif
  
  #include "../defs.h"
***************
*** 20,26 ****
  #define	NUMPER	8
  #define	WPER	54
  int dotab = 0;
! struct cattab tabN[], tabS[];
  #ifdef	HEADERSIZE
  int skip = HEADERSIZE;
  #else
--- 20,27 ----
  #define	NUMPER	8
  #define	WPER	54
  int dotab = 0;
! extern struct cattab tabN[], tabS[];
! #ifndef	ASCIIWIDTHS
  #ifdef	HEADERSIZE
  int skip = HEADERSIZE;
  #else
***************
*** 42,47 ****
--- 43,50 ----
  #endif
  int skip = HEADERSIZE;
  #endif
+ #endif
+ int guessflag, verbose;
  
  double ditres = 1;
  
***************
*** 48,60 ****
  main(argc, argv)
  int argc; char **argv; {
      register int i;
!     register int j, c;
      register int k;
      extern int getopt();
      extern char *optarg;
      int found;
      struct cattab *ct = tabN;
!     while((c = getopt(argc, argv, "dstwfh:")) != EOF) {
  	switch(c) {
  	    case 'd':
  		ditres = (double) 300 / 432 * (double) 10 / 6;
--- 51,64 ----
  main(argc, argv)
  int argc; char **argv; {
      register int i;
!     register int j;
!     int c;
      register int k;
      extern int getopt();
      extern char *optarg;
      int found;
      struct cattab *ct = tabN;
!     while((c = getopt(argc, argv, "vgdstwfh:")) != EOF) {
  	switch(c) {
  	    case 'd':
  		ditres = (double) 300 / 432 * (double) 10 / 6;
***************
*** 62,67 ****
--- 66,77 ----
  	    case 's':
  		ct = tabS;
  		break;
+ 	    case 'g':
+ 		guessflag = 1;
+ 		break;
+ 	    case 'v':
+ 		verbose = 1;
+ 		break;
  	    case 't':
  		dotab = 1;
  		break;
***************
*** 71,93 ****
  	    case 'f':
  		dumpexamples();
  		exit(0);
  	    case 'h':
  		skip = atoi(optarg);
  		fprintf(stderr, "skip: %d\n", skip);
  		break;
  	    case '?':
  		fprintf(stderr,
! 	    "usage: dumpft [-s][-f][-t][-w][-hheadersize] < cat width file\n");
  		exit(1);
  	}
      }
  
      for (i = 0; i < skip; i++)
  	c = getchar();
      k = 0;
      for (i = 0; i < 224; i++) {
  	found = 0;
  	c = getchar();
  	for (j = 0; ct[j].ch_name; j++) {
  	    if (!ct[j].ch_name[0])
  		continue;
--- 81,116 ----
  	    case 'f':
  		dumpexamples();
  		exit(0);
+ #ifndef	ASCIIWIDTHS
  	    case 'h':
  		skip = atoi(optarg);
  		fprintf(stderr, "skip: %d\n", skip);
  		break;
+ #endif
  	    case '?':
  		fprintf(stderr,
! 		    "usage: dumpft [-v][-g][-s][-f][-t][-w][-hheadersize]%s\n",
! 			" < cat width table\n");
  		exit(1);
  	}
      }
+     if (guessflag) {
+ 	guess();
+ 	exit(0);
+     }
  
+ #ifndef	ASCIIWIDTHS
      for (i = 0; i < skip; i++)
  	c = getchar();
+ #endif
      k = 0;
      for (i = 0; i < 224; i++) {
  	found = 0;
+ #ifdef	ASCIIWIDTHS
+ 	scanf("%d", &c);
+ #else
  	c = getchar();
+ #endif
  	for (j = 0; ct[j].ch_name; j++) {
  	    if (!ct[j].ch_name[0])
  		continue;
***************
*** 134,140 ****
  			break;
  		    case 0:
  			if (i == 0) {
! 			    printf("spacewidth %d\n", c&0xf);
  			    printf("charset\n");
  			} else
  			    printf("%s\t%d\t%d\n", ct[j].ch_name,
--- 157,164 ----
  			break;
  		    case 0:
  			if (i == 0) {
! 			    printf("spacewidth %d\n", (int) ((c&0x3f) *
! 				ditres + .5));
  			    printf("charset\n");
  			} else
  			    printf("%s\t%d\t%d\n", ct[j].ch_name,
***************
*** 153,163 ****
      switch(dotab) {
  	case 0:
  	    for (i = 0; ct[i].ch_name; i++)
! 		if (ct[i].ch_name[0] && !ct[i].ch_info)
  		    fprintf(stderr, "Table problem - no width for '%s' (%d)",
  			ct[i].ch_name, i);
  		    fprintf(stderr, ", wididx: %d, catidx: %d\n",
  			ct[i].ch_wididx, ct[i].ch_catidx);
  	    break;
  	case 1:
  	    if (k % NUMPER != 0)
--- 177,188 ----
      switch(dotab) {
  	case 0:
  	    for (i = 0; ct[i].ch_name; i++)
! 		if (ct[i].ch_name[0] && !ct[i].ch_info) {
  		    fprintf(stderr, "Table problem - no width for '%s' (%d)",
  			ct[i].ch_name, i);
  		    fprintf(stderr, ", wididx: %d, catidx: %d\n",
  			ct[i].ch_wididx, ct[i].ch_catidx);
+ 		}
  	    break;
  	case 1:
  	    if (k % NUMPER != 0)
***************
*** 251,254 ****
--- 276,306 ----
  	    printf("\n.br\n");
      }
      printf("\n");
+ }
+ 
+ guess() {
+     char buffer[2048];
+     int filesize, errcnt, i, g;
+     filesize = fread(buffer, sizeof(char), sizeof(buffer), stdin);
+     for(g = 0; g <= filesize - 224; g++) {
+ 	errcnt = 0;
+ 	for (i = 0; tabN[i].ch_name; i++) {
+ 	    if (tabN[i].ch_wididx == -1)
+ 		continue;
+ 	    if (tabN[i].ch_name[0] && !buffer[g+tabN[i].ch_wididx]) {
+ 		if (verbose) {
+ 		    printf("Table problem - no width for '%s' (%d)",
+ 			tabN[i].ch_name, i);
+ 		    printf(", wididx: %d, catidx: %d\n",
+ 			tabN[i].ch_wididx, tabN[i].ch_catidx);
+ 		}
+ 		errcnt++;
+ 	    }
+ 	}
+ 	if (verbose)
+ 	    printf("Guess: %d, errcnt %d\n", g, errcnt);
+ 	if (errcnt)
+ 	    continue;
+ 	printf("Guess %d\n", g);
+     }
  }
*** /tmp/PATCHold/./defs.h	Sat Dec 15 00:07:56 1990
--- ./defs.h	Sat Dec 15 00:08:02 1990
***************
*** 1,4 ****
! /*	Copyright 1988, 1989 23:13:57 Chris Lewis
  		All Rights Reserved
  
      Permission to copy and further distribute is freely given provided
--- 1,4 ----
! /*	Copyright 1988, 1989 23:46:55 Chris Lewis
  		All Rights Reserved
  
      Permission to copy and further distribute is freely given provided
***************
*** 6,18 ****
      sold for profit.
  
  	Project:	Generic Troff drivers
! 	Module:		defs.h 2.10 90/11/16 23:13:57
  	Author: 	Chris Lewis
  	Specs:		Main header file - contains some customization
   */
  
  /*	Official Release and Patch level:	*/
! #define	T2VERSION	"@(#)PSROFF Copyright 90/11/16 Chris Lewis - R2 P5"
  
  #ifndef	LIBDIR
  /*	Don't touch this */
--- 6,18 ----
      sold for profit.
  
  	Project:	Generic Troff drivers
! 	Module:		defs.h 2.12 90/12/14 23:46:55
  	Author: 	Chris Lewis
  	Specs:		Main header file - contains some customization
   */
  
  /*	Official Release and Patch level:	*/
! #define	T2VERSION	"@(#)PSROFF Copyright 90/12/14 Chris Lewis - R2 P6"
  
  #ifndef	LIBDIR
  /*	Don't touch this */
***************
*** 61,77 ****
  	  the file.  I personally know of no machine that supports these.
  	- If neither are defined, use a BSD/V7 style a.out.h header, this
  	  is appropriate for V7 and BSD troffs
  
-     The headers I write out do not have anything in them, so some
-     troff's may blow.  Please let me know if they work for you...
-     If you do need the headers, and these doesn't work for you, enable
-     the COMPILE option in gfnttab.  I know of no troff that *needs*
-     COMPILE on.
- 
   */
  
  #define	HEADERSIZE 0	/* size of header in bytes */
  #undef	COFF		/* systems using COFF headers */
  
  /* What do your CAT codes look like?
  
--- 61,81 ----
  	  the file.  I personally know of no machine that supports these.
  	- If neither are defined, use a BSD/V7 style a.out.h header, this
  	  is appropriate for V7 and BSD troffs
+ 	- If you are running RISC/Ultrix (Mips box? from DEC) define
+ 	  ASCIIWIDTHS, and the rest of this stuff will be ignored - Mips
+ 	  apparently changed their width table format to an ASCII form,
+ 	  and DEC picked it up.  In this case IGNORE any messages about
+ 	  HEADERSIZE from "make check".
+ 
+     The headers I write will have something in them if HEADERSIZE > 0
+     and there's a font file from your original troff distribution in
+     /usr/lib/font/ftR (the header and trailer will be copied over).
  
   */
  
  #define	HEADERSIZE 0	/* size of header in bytes */
  #undef	COFF		/* systems using COFF headers */
+ #undef	ASCIIWIDTHS	/* For RISC/Ultrix */
  
  /* What do your CAT codes look like?
  
***************
*** 373,385 ****
  #define	max(a,b)	((a) > (b) ? (a) : (b))
  
  /* debug flags */
! #define	D_CAT	1
! #define	D_SPEC	2
! #define	D_CHAR	4
! #define	D_FONT	8
! #define	D_BEND	0x10
! #define	D_PK	0x20
! #define	D_VERB	0x40
  
  extern int debug;
  
--- 377,390 ----
  #define	max(a,b)	((a) > (b) ? (a) : (b))
  
  /* debug flags */
! #define	D_CAT	1	/* show cat interpretation machinery */
! #define	D_SPEC	2	/* show special directives */
! #define	D_CHAR	4	/* optimizer machinery */
! #define	D_FONT	8	/* font handling */
! #define	D_BEND	0x10	/* backend */
! #define	D_PK	0x20	/* PK font handling */
! #define	D_VERB	0x40	/* very verbose */
! #define	D_FLSH	0x80	/* flush after each fprintf */
  
  extern int debug;
  
*** /tmp/PATCHold/./troff2.c	Sat Dec 15 00:08:34 1990
--- ./troff2.c	Sat Dec 15 00:08:42 1990
***************
*** 15,21 ****
  
  #ifndef	lint
  static char SCCSid[] =
!     "@(#)troff2.c: 2.2 Copyright 90/08/10 15:15:35 Chris Lewis";
  #endif
  
  #define	ESC	0x80
--- 15,21 ----
  
  #ifndef	lint
  static char SCCSid[] =
!     "@(#)troff2.c: 2.3 Copyright 90/12/13 14:55:19 Chris Lewis";
  #endif
  
  #define	ESC	0x80
***************
*** 36,42 ****
  #endif
  
  char ptab[15] = { 7, 8, 10, 11, 12, 14, 18, 9, 6, 16, 20, 22, 24, 28, 36};
! int	points;
  
  int	xpos, ypos;
  
--- 36,42 ----
  #endif
  
  char ptab[15] = { 7, 8, 10, 11, 12, 14, 18, 9, 6, 16, 20, 22, 24, 28, 36};
! int	points, font;
  
  int	xpos, ypos;
  
***************
*** 111,117 ****
  #endif
  	register int nc, c;
  	register int units;
! 	register int font, rail, mag, tilt, half, escape, lead;
  
  	extern int getopt();
  	extern char *optarg;
--- 111,117 ----
  #endif
  	register int nc, c;
  	register int units;
! 	register int rail, mag, tilt, half, escape, lead;
  
  	extern int getopt();
  	extern char *optarg;
***************
*** 633,638 ****
--- 633,644 ----
  	    case 'D':
  		if (be->bedraw)
  		    (*be->bedraw)(specXPos, specYPos, string+1);
+ 		*string = '\0';
+ 		return;
+ 	    case 'C':
+ 		if (be->beputchar)
+ 		    (*be->beputchar)(specXPos, specYPos, font, points, 0,
+ 			string+1);
  		*string = '\0';
  		return;
  	    case 'E':
*** /tmp/PATCHold/./utils.c	Sat Dec 15 00:09:11 1990
--- ./utils.c	Sat Dec 15 00:09:17 1990
***************
*** 15,23 ****
  
  #ifndef	lint
  static char SCCSid[] =
!     "@(#)utils.c: 2.3 Copyright 90/10/24 13:37:08 Chris Lewis";
  #endif
  
  extern struct cattab tabN[], tabS[];
  
  int lastFont, lastPoints;
--- 15,39 ----
  
  #ifndef	lint
  static char SCCSid[] =
!     "@(#)utils.c: 2.5 Copyright 90/12/14 23:47:08 Chris Lewis";
  #endif
  
+ #ifndef	HEADERSIZE
+ #	ifdef COFF
+ #		include <aouthdr.h>
+ #		include <filehdr.h>
+ #		include <scnhdr.h>
+ #		include <ldfcn.h>
+ #		include <reloc.h>
+ #		define H1 (sizeof (struct filehdr) + sizeof (struct aouthdr))
+ #		define H2 (sizeof (struct scnhdr) + sizeof (struct reloc))
+ #		define HEADERSIZE (H1 + H2)
+ #	else
+ #		include <a.out.h>
+ #		define HEADERSIZE (sizeof (struct exec))
+ #	endif
+ #endif
+ 
  extern struct cattab tabN[], tabS[];
  
  int lastFont, lastPoints;
***************
*** 394,400 ****
--- 410,420 ----
      DBP((D_SPEC, "Attempting to read font file %s\n", widthtables));
      if (f = fopen(widthtables, "r")) {
  	for (c = 0; c < HEADERSIZE; c++) getc(f);
+ #ifdef	ASCIIWIDTHS
+ 	if (widread(p->widthtable, f)) {
+ #else
  	if (224 != fread(p->widthtable, 1, 224, f)) {
+ #endif
  	    fprintf(stderr, "%s: badly formed width table %s\n",
  		progname, widthtables);
  	    free(p->widthtable);
***************
*** 411,416 ****
--- 431,451 ----
  	p->widthtable = (char *) 1;
      }
  }
+ 
+ #ifdef	ASCIIWIDTHS
+ widread(widths, f)
+ char *widths;
+ FILE *f; {
+     int v, i;
+     for (i = 0; i < 224; i++)
+ 	if (fscanf(f, "%d", &v) != 1)
+ 	    return(1);
+ 	else
+ 	    widths[i] = v;
+     return(0);
+ }
+ #endif
+ 
  #endif
  
  #ifdef	NULLCHECK
*** /tmp/PATCHold/./psroff.S	Sat Dec 15 00:09:43 1990
--- ./psroff.S	Sat Dec 15 00:09:48 1990
***************
*** 11,17 ****
  #	Author: 	Chris Lewis
  #	Specs:		troff driver
  #
! #ident  "@(#)psroff.sh: 2.2 Copyright 90/10/01 14:41:16 Chris Lewis"
  
  LIBDIR="%%LIBDIR%%"
  FONTDIR="%%FONTDIR%%"
--- 11,17 ----
  #	Author: 	Chris Lewis
  #	Specs:		troff driver
  #
! #ident  "@(#)psroff.sh: 2.3 Copyright 90/12/14 23:59:43 Chris Lewis"
  
  LIBDIR="%%LIBDIR%%"
  FONTDIR="%%FONTDIR%%"
***************
*** 56,65 ****
--- 56,69 ----
  	    if [ ! -r $file ]
  	    then
  		file="$LIBDIR/adapters/tmac.$mac"
+ 	    else
+ 		foundadapter=1
  	    fi
  	    if [ ! -r $file ]
  	    then
  		file="%%RTMACDIR%%/tmac.$mac"
+ 	    else
+ 		foundadapter=1
  	    fi
  	    if [ ! -r $file ]
  	    then
***************
*** 66,74 ****
--- 70,86 ----
  		echo "$0: Couldn't find tmac.$mac anywhere!" >&2
  		exit 1
  	    fi
+ 	    if [ -z "$files" -a -z "$foundadapter" ]
+ 	    then
+ 		files=$LIBDIR/adapters/cmn.pre
+ 	    fi
  	    files="$files $file"
  	    ;;
  	-)
+ 	    if [ -z "$files" -a -z "$foundadapter" ]
+ 	    then
+ 		files=$LIBDIR/adapters/cmn.pre
+ 	    fi
  	    files="$files $i"
  	    seenfiles=1
  	    ;;
***************
*** 87,92 ****
--- 99,108 ----
  	    args="$args $i"
  	    ;;
  	*)
+ 	    if [ -z "$files" -a -z "$foundadapter" ]
+ 	    then
+ 		files=$LIBDIR/adapters/cmn.pre
+ 	    fi
  	    files="$files $i"
  	    seenfiles=1
  	    if [ ! -r $i ]
*** /tmp/PATCHold/./adapters/Makefile	Sat Dec 15 00:10:16 1990
--- ./adapters/Makefile	Sat Dec 15 00:10:19 1990
***************
*** 1,4 ****
! # 2.2 90/10/27
  ADAPTERS	= cmn.post cmn.pre tmac.an tmac.m tmac.s tmac.e
  MACROS		= tmac.t2
  
--- 1,4 ----
! # 2.3 90/12/13
  ADAPTERS	= cmn.post cmn.pre tmac.an tmac.m tmac.s tmac.e
  MACROS		= tmac.t2
  
***************
*** 15,20 ****
  
  install:
  	cd $(LIBDIR)/adapters ; rm -f $(ADAPTERS)
! 	cp cmn.post cmn.pre tmac.an tmac.m tmac.s $(LIBDIR)/adapters
  	cd $(RTMACDIR) ; rm -f $(MACROS)
  	cp $(MACROS) $(RTMACDIR)
--- 15,20 ----
  
  install:
  	cd $(LIBDIR)/adapters ; rm -f $(ADAPTERS)
! 	cp cmn.post cmn.pre tmac.an tmac.m tmac.s tmac.e $(LIBDIR)/adapters
  	cd $(RTMACDIR) ; rm -f $(MACROS)
  	cp $(MACROS) $(RTMACDIR)
*** /tmp/PATCHold/./audit.S	Sat Dec 15 00:10:44 1990
--- ./audit.S	Sat Dec 15 00:10:49 1990
***************
*** 1,5 ****
  %%STARTSHELL%%
! #	Psroff checking script 2.4 90/08/29
  chkinst=false
  for i
  do
--- 1,5 ----
  %%STARTSHELL%%
! #	Psroff checking script 2.5 90/12/14
  chkinst=false
  for i
  do
***************
*** 52,57 ****
--- 52,65 ----
      psrofflib=lib/psrofflib
      libbase=lib
  fi
+ if grep 'define.*ASCIIWIDTHS' defs.h > /dev/null 2>&1
+ then
+     cat <<\!
+ I see you've defined ASCIIWIDTHS.  This means that your trofftype
+ should be the -F variant.  Please ignore the rest of the checking
+ for trofftype and HEADERSIZE.
+ !
+ fi
  
  if [ ! -r $psrofflib ]
  then
***************
*** 136,141 ****
--- 144,153 ----
  		echo "      This means that you'll have to put all of your"
  		echo "      width files directly in $FONTDIR, and you'll not"
  		echo "      be able to support multiple sets of width tables"
+ 		echo "      The OTHER possibility is that you're running"
+ 		echo "      RISC/Ultrix who's troff cannot even read their"
+ 		echo "      own width tables!  In this case, -F is probably"
+ 		echo "      the correct form"
  		workingtype=" "
  		;;
  	esac
***************
*** 150,155 ****
--- 162,169 ----
      echo "       It's giving me non-zero return codes when I try"
      echo "       all of the known different ways of setting width table"
      echo "       directory (including none!).  Egads.  Get Help!!!!!!!"
+     echo "       (One possibility is that you have ditroff which doesn't"
+     echo "       understand -t and will not work with psroff)"
      exit 1
  fi
  
-- 
Chris Lewis, Phone: (613) 832-0541
UUCP: uunet!utai!lsuc!ecicrl!clewis
Moderator of the Ferret Mailing List (ferret-request@eci386)
Psroff mailing list (psroff-request@eci386)