Patch 1 for Psroff 2.0

Chris Lewis clewis at eci386.uucp
Sat Aug 11 06:35:47 AEST 1990


Psroff 2.0 hasn't made it thru comp.sources.unix yet, but it is available
via ftp from at least two sites.  This patch resolves all bugs that I
know of.  All of these bugs are build/configure problems.  There are
some enhancements, but most of them are disabled (and incomplete - wait
for me to finally get the bugs out of ditroff drawing emulation)

Please note: I will be moving to Ottawa in a few days.  No, I'm not
leaving the company, I'm opening a new office.  Existing e-mail addresses
will continue to work (via the wonders of mail aliasing), but expect a
delay until I get things rolling again.

    This is official patch 01 for Psroff 2.0.
    Please apply it by:
	cd <psroff source directory>
	patch -N -p < <this file>

If you had managed to succeed to get psroff 2.0 P0 to build, you may
get a small number of rejects which you may want to examine to ensure
that you fixed 'em right.

Bugs:
    - "make check" (audit & Makefile):
	- Made misleading remarks about testing trofftype when no
	  /usr/lib/font exists, or FONTDIR somewhere else.
	- Final verification message for HEADERSIZE used literal
	  "0" instead of empirically derived value.
	- Bug in awk script caused blowouts.
    - "make installwidths" (widths/Makefile):
	- "@$(IGNORESH) ; \" caused problems on some systems with IGNORESH
	  disabled.  Semi-colon removed.
	- widths/widthjt/DESC, widths/widthlj/DESC and widths/widthps/HW
	  aren't supposed to be part of the release.  Removed them.
    - ltest.m referenced font PA, which was changed to PR for consistency.
    - debug.c refered to pkmsg which isn't defined when LJ undef'd.
      With this fix, you can now build troff2ps with LJ undef'd, but
      several of the utilities having to do with laserjet fonts (eg:
      all of the "pk*" routines under utils) will not build.
      A "make -k" may help when you REALLY want to undef LJ.
    - troff2.c: fix made for compilers that can't handle float expression
      assignments to integer variables in initializers (Ultrix).

Enhancements:
    - Ditroff drawing emulation comprises the bulk of the diffs in this
      patch.  It is disabled, and some code is missing.
      This code will remain in, but disabled, until I get it a bit
      more bullet proof, then I'll also supply the backend code.
      (troff2.c, defs.h, t2conf.c, opt.c)
    - Comment regarding new -Y flag added to lib/psrofflib.
    - Improved greyscale settings in lib/confid.ps

*** /tmp/PATCHold/./Makefile	Fri Aug 10 15:58:01 1990
--- ./Makefile	Fri Aug 10 15:58:01 1990
***************
*** 16,22 ****
  #	Note:		This is a System V Makefile, so you may
  #			have some problems making a few of the items.
  #
! #ident  "@(#)Makefile: 2.1 Copyright 90/07/18 16:47:31 Chris Lewis"
  
  #	Use s5make on Ultrix and Sun!
  
--- 16,22 ----
  #	Note:		This is a System V Makefile, so you may
  #			have some problems making a few of the items.
  #
! #ident  "@(#)Makefile: 2.2 Copyright 90/08/10 15:22:08 Chris Lewis"
  
  #	Use s5make on Ultrix and Sun!
  
***************
*** 377,387 ****
  	tbl TEST | PATH=.:$(LIBDIR):$$PATH psroff -T$(TTYPE)
  
  check:	audit sedscript makeincl
! 	cd lib ; $(MAKE) psrofflib
  	./audit
  
  checkinstall:	audit sedscript makeincl
! 	cd lib ; $(MAKE) psrofflib
  	./audit install
  
  #	This is how I build a release - don't even try running this...!
--- 377,387 ----
  	tbl TEST | PATH=.:$(LIBDIR):$$PATH psroff -T$(TTYPE)
  
  check:	audit sedscript makeincl
! 	cd lib ; $(MAKE)
  	./audit
  
  checkinstall:	audit sedscript makeincl
! 	cd lib ; $(MAKE)
  	./audit install
  
  #	This is how I build a release - don't even try running this...!
*** /tmp/PATCHold/./widths/Makefile	Fri Aug 10 15:58:08 1990
--- ./widths/Makefile	Fri Aug 10 15:58:09 1990
***************
*** 1,4 ****
! #2.1 90/07/18
  SCRIPTS	= gfnttab
  TD	= testdir
  PSW	= \
--- 1,4 ----
! #2.4 90/08/08
  SCRIPTS	= gfnttab
  TD	= testdir
  PSW	= \
***************
*** 5,16 ****
  	widthps/DESC \
  	widthps/AB widthps/BR widthps/HB widthps/I  widthps/PX \
  	widthps/AI widthps/BX widthps/HO widthps/NB widthps/R \
! 	widthps/AR widthps/C  widthps/HW widthps/NI widthps/S \
  	widthps/AX widthps/CB widthps/HX widthps/NR widthps/S2 \
  	widthps/B  widthps/CO widthps/Hb widthps/NX widthps/ZC \
  	widthps/BB widthps/CX widthps/Hi widthps/PB widthps/ZD \
  	widthps/BI widthps/Hr widthps/PI widthps/BO widthps/H \
! 	widthps/Hx widthps/PR widthjt/DESC widthlj/DESC
  
  include ../makeincl
  
--- 5,16 ----
  	widthps/DESC \
  	widthps/AB widthps/BR widthps/HB widthps/I  widthps/PX \
  	widthps/AI widthps/BX widthps/HO widthps/NB widthps/R \
! 	widthps/AR widthps/C  widthps/NI widthps/S \
  	widthps/AX widthps/CB widthps/HX widthps/NR widthps/S2 \
  	widthps/B  widthps/CO widthps/Hb widthps/NX widthps/ZC \
  	widthps/BB widthps/CX widthps/Hi widthps/PB widthps/ZD \
  	widthps/BI widthps/Hr widthps/PI widthps/BO widthps/H \
! 	widthps/Hx widthps/PR
  
  include ../makeincl
  
***************
*** 18,24 ****
  
  $(PSW):
  	@eval `echo $@ | sed -e 's/\(.*\)\/\([^\/]*\)$$/d=\1 f=s.\2/'` ; \
! 	    cd $$d ; get $(GFLAGS) $$f
  
  widths:	gfnttab dit2catwid
  	-rm -f gfnttab.log
--- 18,24 ----
  
  $(PSW):
  	@eval `echo $@ | sed -e 's/\(.*\)\/\([^\/]*\)$$/d=\1 f=s.\2/'` ; \
! 	    cd $$d ; $(GET) $(GFLAGS) $$f
  
  widths:	gfnttab dit2catwid
  	-rm -f gfnttab.log
***************
*** 41,47 ****
  # (eg: my PK 36 is actually closer to 32)
  sepwidths: ../utils/pk2ditwid
  	rm -f pk2sep.log pk2sep.err
! 	@ $(IGNORESH) if [ -d $(LJF) ] ; \
  	then \
  	    fontlist=`find $(LJF) -type f \
  		'(' -name '*.*.pk' -o -name '*.*.sfp' ')' -print | \
--- 41,47 ----
  # (eg: my PK 36 is actually closer to 32)
  sepwidths: ../utils/pk2ditwid
  	rm -f pk2sep.log pk2sep.err
! 	@$(IGNORESH) if [ -d $(LJF) ] ; \
  	then \
  	    fontlist=`find $(LJF) -type f \
  		'(' -name '*.*.pk' -o -name '*.*.sfp' ')' -print | \
***************
*** 122,128 ****
  # (eg: my PK 36 is actually closer to 32)
  ljwidths: ../utils/pk2ditwid
  	rm -f pk2dit.log pk2dit.err
! 	@ $(IGNORESH) if [ -d $(LJF) ] ; \
  	then \
  	    fontlist=`find $(LJF) -type f \
  		'(' -name '*.*.pk' -o -name '*.*.sfp' ')' -print | \
--- 122,128 ----
  # (eg: my PK 36 is actually closer to 32)
  ljwidths: ../utils/pk2ditwid
  	rm -f pk2dit.log pk2dit.err
! 	@$(IGNORESH) if [ -d $(LJF) ] ; \
  	then \
  	    fontlist=`find $(LJF) -type f \
  		'(' -name '*.*.pk' -o -name '*.*.sfp' ')' -print | \
***************
*** 179,191 ****
  install:
  
  installwidths:
! 	@$(IGNORESH) ; \
  	test -w $(FONTDIR) || (echo "Install as root" ; exit 1 ; ) ; \
  	for i in width* ; \
  	do \
  	    base=`echo $$i | sed -e 's/.*width//'` ; \
  	    test -d $(FONTDIR)/$$base || mkdir $(FONTDIR)/$$base ; \
! 	    test -w $(FONTDIR)/$$base || (echo "Install as root" ; exit 1 ; ) ; \
  	    files=`echo width$$base/ft*` ; \
  	    if [ "$$files" = "width$$base"'/ft*' ] ; \
  	    then \
--- 179,192 ----
  install:
  
  installwidths:
! 	@$(IGNORESH) \
  	test -w $(FONTDIR) || (echo "Install as root" ; exit 1 ; ) ; \
  	for i in width* ; \
  	do \
  	    base=`echo $$i | sed -e 's/.*width//'` ; \
  	    test -d $(FONTDIR)/$$base || mkdir $(FONTDIR)/$$base ; \
! 	    test -w $(FONTDIR)/$$base || \
! 		(echo "Install as root" ; exit 1 ; ) ; \
  	    files=`echo width$$base/ft*` ; \
  	    if [ "$$files" = "width$$base"'/ft*' ] ; \
  	    then \
***************
*** 198,204 ****
  
  cmp:
  	test -d $(TD) || mkdir $(TD)
! 	@$(IGNORESH)for i in width* ; \
  	do \
  	    base=`echo $$i | sed -e 's/.*width//'` ; \
  	    cd $$i ; \
--- 199,205 ----
  
  cmp:
  	test -d $(TD) || mkdir $(TD)
! 	@$(IGNORESH) for i in width* ; \
  	do \
  	    base=`echo $$i | sed -e 's/.*width//'` ; \
  	    cd $$i ; \
*** /tmp/PATCHold/./tests/ltest.m.S	Fri Aug 10 15:58:15 1990
--- ./tests/ltest.m.S	Fri Aug 10 15:58:15 1990
***************
*** 1,4 ****
! .\"Document revision 2.1 90/07/18
  .nr Ej 1
  .TL
  troff2ps testing script.
--- 1,4 ----
! .\"Document revision 2.2 90/08/10
  .nr Ej 1
  .TL
  troff2ps testing script.
***************
*** 237,243 ****
  .EN
  .DE
  .H 2 "Hanging Caps"
! .fp 1 PA
  .fp 3 PB
  .ta 1i
  .in +0.6i
--- 237,243 ----
  .EN
  .DE
  .H 2 "Hanging Caps"
! .fp 1 PR
  .fp 3 PB
  .ta 1i
  .in +0.6i
*** /tmp/PATCHold/./debug.c	Fri Aug 10 15:58:23 1990
--- ./debug.c	Fri Aug 10 15:58:23 1990
***************
*** 2,8 ****
  
  #ifndef	lint
  static char SCCSid[] =
!     "@(#)debug.c: 2.1 Copyright 90/07/18 16:51:21 Chris Lewis";
  #endif
  
  #ifdef	DEBUG
--- 2,8 ----
  
  #ifndef	lint
  static char SCCSid[] =
!     "@(#)debug.c: 2.2 Copyright 90/08/08 13:14:09 Chris Lewis";
  #endif
  
  #ifdef	DEBUG
***************
*** 106,114 ****
      extern char *malloc();
      register char *p = malloc((unsigned) n);
      if (!p) {
! 	pkmsg("%s: Out of space! (requesting %d bytes, key: %s)\n",
  	    progname, n, msg);
! 	abort();
      }
      clrarray(p, n);
      return(p);
--- 106,114 ----
      extern char *malloc();
      register char *p = malloc((unsigned) n);
      if (!p) {
! 	fprintf(stderr, "%s: Out of space! (requesting %d bytes, key: %s)\n",
  	    progname, n, msg);
! 	exit(1);
      }
      clrarray(p, n);
      return(p);
*** /tmp/PATCHold/./defs.h	Fri Aug 10 15:58:27 1990
--- ./defs.h	Fri Aug 10 15:58:27 1990
***************
*** 1,4 ****
! /*	Copyright 1988, 1989 16:51:24 Chris Lewis
  		All Rights Reserved
  
      Permission to copy and further distribute is freely given provided
--- 1,4 ----
! /*	Copyright 1988, 1989 15:15:01 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.1 90/07/18 16:51:24
  	Author: 	Chris Lewis
  	Specs:		Main header file - contains some customization
   */
  
  /*	Official Release and Patch level:	*/
! #define	T2VERSION	"@(#)PSROFF Copyright 90/07/18 Chris Lewis - R2 P0"
  
  #ifndef	LIBDIR
  /*	Don't touch this */
--- 6,18 ----
      sold for profit.
  
  	Project:	Generic Troff drivers
! 	Module:		defs.h 2.2 90/08/10 15:15:01
  	Author: 	Chris Lewis
  	Specs:		Main header file - contains some customization
   */
  
  /*	Official Release and Patch level:	*/
! #define	T2VERSION	"@(#)PSROFF Copyright 90/08/10 Chris Lewis - R2 P1"
  
  #ifndef	LIBDIR
  /*	Don't touch this */
***************
*** 105,111 ****
  
  /*	Basic drivers: */
  #define	PS	/* Postscript */
! #define	LJ	/* Laserjet */
  #define	DT	/* ditroff */
  
  /*	Laserjet driver config: */
--- 105,111 ----
  
  /*	Basic drivers: */
  #define	PS	/* Postscript */
! #define	LJ	/* Laserjet - psroff will not build with this undef'd */
  #define	DT	/* ditroff */
  
  /*	Laserjet driver config: */
***************
*** 266,272 ****
  		befontsel,	/* special function F */
  		beoverlay,	/* special function O */
  		bepassthru,	/* special function P */
! 		bexlat;		/* Xlate function */
      struct troff2befont
  		*bestdfont,	/* standard font translate table */
  		*besymfont;	/* symbol font translate table */
--- 266,273 ----
  		befontsel,	/* special function F */
  		beoverlay,	/* special function O */
  		bepassthru,	/* special function P */
! 		bexlat,		/* Xlate function */
! 		bedraw;		/* Ditroff draw emulation routine */
      struct troff2befont
  		*bestdfont,	/* standard font translate table */
  		*besymfont;	/* symbol font translate table */
***************
*** 336,342 ****
  #endif
  
  extern int lastFont, lastPoints;
! extern int lastYPos, lastXPos;
  extern char *progname, *printer, *device;
  extern char **prologs;
  
--- 337,343 ----
  #endif
  
  extern int lastFont, lastPoints;
! extern int lastYPos, lastXPos, specXPos, specYPos;
  extern char *progname, *printer, *device;
  extern char **prologs;
  
*** /tmp/PATCHold/./t2conf.c	Fri Aug 10 15:58:30 1990
--- ./t2conf.c	Fri Aug 10 15:58:30 1990
***************
*** 15,21 ****
  
  #ifndef	lint
  static char SCCSid[] =
!     "@(#)t2conf.c: 2.1 Copyright 90/07/18 16:51:40 Chris Lewis";
  #endif
  
  #ifdef	PS
--- 15,21 ----
  
  #ifndef	lint
  static char SCCSid[] =
!     "@(#)t2conf.c: 2.2 Copyright 90/08/10 15:27:22 Chris Lewis";
  #endif
  
  #ifdef	PS
***************
*** 30,35 ****
--- 30,40 ----
  #include "dt.h"
  #endif
  
+ #ifndef	INSPECIAL
+ #define	dtDraw	NULL
+ #define	psDraw	NULL
+ #endif
+ 
  extern int FontSel();
  
  /*	Common variables */
***************
*** 37,58 ****
  int	currentPage = 0;
  
  struct backend B[] = {
! /*   bename,	beprolog,	beepilog,	bechar,	bepage,	befontsel */
! /*		beoverlay,	bepassthru	bexlat, bestdfont, besymfont */
  
  #ifdef	PS
      { "ps",	psProlog,	psEpilog,	psChar,	psPage,	FontSel,
! 		psOverlay,	NULL,		psXlate, psStdFont, psSymFont },
  #endif
  
  #ifdef	DT
      { "dt",	dtProlog,	dtEpilog,	dtChar,	dtPage,	FontSel,
! 		NULL,		dtPassthru,	NULL,	dtStdFont, dtSymFont },
  #endif
  
  #ifdef	LJ
      { "lj",	ljProlog,	ljEpilog,	ljChar,	ljPage,	FontSel,
! 		NULL,		NULL,		NULL,   ljStdFont, ljSymFont },
  #endif
      { NULL }
  };
--- 42,67 ----
  int	currentPage = 0;
  
  struct backend B[] = {
! /*   bename,	beprolog,	beepilog,	bechar,	bepage,	befontsel
! 		beoverlay,	bepassthru,	bexlat, beDraw,
! 		bestdfont,	besymfont */
  
  #ifdef	PS
      { "ps",	psProlog,	psEpilog,	psChar,	psPage,	FontSel,
! 		psOverlay,	NULL,		psXlate, psDraw,
! 		psStdFont,	psSymFont },
  #endif
  
  #ifdef	DT
      { "dt",	dtProlog,	dtEpilog,	dtChar,	dtPage,	FontSel,
! 		NULL,		dtPassthru,	NULL, dtDraw,
! 		dtStdFont,	dtSymFont },
  #endif
  
  #ifdef	LJ
      { "lj",	ljProlog,	ljEpilog,	ljChar,	ljPage,	FontSel,
! 		NULL,		NULL,		NULL, NULL,
! 		ljStdFont,	ljSymFont },
  #endif
      { NULL }
  };
*** /tmp/PATCHold/./troff2.c	Fri Aug 10 15:58:34 1990
--- ./troff2.c	Fri Aug 10 15:58:34 1990
***************
*** 15,21 ****
  
  #ifndef	lint
  static char SCCSid[] =
!     "@(#)troff2.c: 2.1 Copyright 90/07/18 16:51:45 Chris Lewis";
  #endif
  
  #define	ESC	0x80
--- 15,21 ----
  
  #ifndef	lint
  static char SCCSid[] =
!     "@(#)troff2.c: 2.2 Copyright 90/08/10 15:15:35 Chris Lewis";
  #endif
  
  #define	ESC	0x80
***************
*** 49,57 ****
  
  #define	CTOINT(val,sig)	((~c)&sig)
  
! int pagelength = DEFPL * TROFFRESOLUTION;
! int pageoffset = DEFOFF * TROFFRESOLUTION;
! int pageyoffset = DEFYOFF * TROFFRESOLUTION;
  
  char *version, *shortversion;
  
--- 49,57 ----
  
  #define	CTOINT(val,sig)	((~c)&sig)
  
! int pagelength;
! int pageoffset;
! int pageyoffset;
  
  char *version, *shortversion;
  
***************
*** 133,138 ****
--- 133,143 ----
  #endif
  	    sprintf(username, "uid=%d", getuid());
  
+ 	/* some compilers complain about floating point in initializers... */
+ 	pagelength = DEFPL * TROFFRESOLUTION;
+ 	pageoffset = DEFOFF * TROFFRESOLUTION;
+ 	pageyoffset = DEFYOFF * TROFFRESOLUTION;
+ 
  	progname = strrchr(argv[0], '/');
  	if (progname)
  	    progname++;
***************
*** 345,357 ****
  #endif
  
  #ifdef OPT
! 			if (optimize)
! 			    canoninsert(xpos, ypos, font, points, nc);
! 			else
  #endif
- 			    if (be->beputchar)
- 				(*be->beputchar)(xpos, ypos, font, points, nc,
- 				    (char *) NULL);
  
  			break;
  		/* Control codes */
--- 350,361 ----
  #endif
  
  #ifdef OPT
! 			canoninsert(xpos, ypos, font, points, nc);
! #else
! 			if (be->beputchar)
! 			    (*be->beputchar)(xpos, ypos, font, points, nc,
! 				(char *) NULL);
  #endif
  
  			break;
  		/* Control codes */
***************
*** 626,631 ****
--- 630,640 ----
      DBP((D_SPEC,"Dospecial: (%d) %s\n", strlen(string), string));
      while (*string)
  	switch(*string) {
+ 	    case 'D':
+ 		if (be->bedraw)
+ 		    (*be->bedraw)(specXPos, specYPos, string+1);
+ 		*string = '\0';
+ 		return;
  	    case 'E':
  		fprintf(stderr, "%s\n", string+1);
  		*string = '\0';
*** /tmp/PATCHold/./lib/confid.ps	Fri Aug 10 15:58:44 1990
--- ./lib/confid.ps	Fri Aug 10 15:58:45 1990
***************
*** 9,18 ****
  %	Module:		confid.ps
  %	Author: 	Chris Lewis
  %	Specs:		Confidential overlay inclusion.
! %ident  @(#)confid.ps: 2.1 Copyright 90/07/18 16:52:40 Chris Lewis"
  
  /Confidential {
      gsave
      .99 setgray
      /Courier-Bold findfont 80 scalefont setfont
      0 0 moveto
--- 9,19 ----
  %	Module:		confid.ps
  %	Author: 	Chris Lewis
  %	Specs:		Confidential overlay inclusion.
! %ident  @(#)confid.ps: 2.2 Copyright 90/08/09 17:13:28 Chris Lewis"
  
  /Confidential {
      gsave
+     106 45 { dup mul exch dup mul add 1.0 exch sub } setscreen
      .99 setgray
      /Courier-Bold findfont 80 scalefont setfont
      0 0 moveto
*** /tmp/PATCHold/./lib/psrofflib.S	Fri Aug 10 15:58:55 1990
--- ./lib/psrofflib.S	Fri Aug 10 15:58:55 1990
***************
*** 1,4 ****
! #	2.1 90/07/18
  #	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.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.
***************
*** 37,42 ****
--- 37,44 ----
  #				(effectively) 7.5i, the adapters plus
  #				the .5i default makes pages centre
  #				by default in 8.5i (matter of taste).
+ #		-Y<vertoff>	ditto, but vertical.  Default 0.
+ #				Some postscript printers differ in location.
  #
  #	lparg: how to get output to printer.  Note the "-n$copies" and
  #		-d$ptr.  The $ptr is the psroff selected physical printer
*** /tmp/PATCHold/./audit.S	Fri Aug 10 15:59:03 1990
--- ./audit.S	Fri Aug 10 15:59:04 1990
***************
*** 1,5 ****
  %%STARTSHELL%%
! #	Psroff checking script 2.1 90/07/18
  chkinst=false
  for i
  do
--- 1,5 ----
  %%STARTSHELL%%
! #	Psroff checking script 2.2 90/08/07
  chkinst=false
  for i
  do
***************
*** 205,211 ****
      then
  	echo "ERROR: HEADERSIZE should be set to $acthdr, not $hdrsize"
      else
! 	echo "INFO: HEADERSIZE appears to be set correctly to 0"
      fi
  fi
  
--- 205,211 ----
      then
  	echo "ERROR: HEADERSIZE should be set to $acthdr, not $hdrsize"
      else
! 	echo "INFO: HEADERSIZE appears to be set correctly to $hdrsize"
      fi
  fi
  
***************
*** 355,367 ****
  	if (ftdirfound) {
  	    for (name in fonts) {
  		if (name && !catfonts[name])
! 		    printf("  FONT %s: don't use: %s/%s/ft%s not installed\n",\
  			name, fontdir, printertype, name);
  	    }
  	}
  	for (name in catfonts) {
  	    if (name && !fonts[name])
! 		printf("  FONT %s: don't use: %s/%s/ft%s exists, but"
  		    name, fontdir, printertype, name)
  		printf(" no %s.fonts\n", printertype)
  	}
--- 355,367 ----
  	if (ftdirfound) {
  	    for (name in fonts) {
  		if (name && !catfonts[name])
! 		    printf("  FONT %s: do not use: %s/%s/ft%s not installed\n",\
  			name, fontdir, printertype, name);
  	    }
  	}
  	for (name in catfonts) {
  	    if (name && !fonts[name])
! 		printf("  FONT %s: do not use: %s/%s/ft%s exists, but"
  		    name, fontdir, printertype, name)
  		printf(" no %s.fonts\n", printertype)
  	}
*** /tmp/PATCHold/./opt.c	Fri Aug 10 15:59:09 1990
--- ./opt.c	Fri Aug 10 15:59:09 1990
***************
*** 13,22 ****
  
  #include "defs.h"
  
  #ifdef	OPT
  #ifndef	lint
  static char SCCSid[] =
!     "@(#)opt.c: 2.1 Copyright 90/07/18 16:53:02 Chris Lewis";
  #endif
  
  struct insbuf {
--- 13,25 ----
  
  #include "defs.h"
  
+ int specXPos, specYPos;
+ extern struct cattab tabN[], tabS[];
+ 
  #ifdef	OPT
  #ifndef	lint
  static char SCCSid[] =
!     "@(#)opt.c: 2.2 Copyright 90/08/10 15:16:19 Chris Lewis";
  #endif
  
  struct insbuf {
***************
*** 47,52 ****
--- 50,71 ----
      insptr++;
  }
  
+ #ifdef	SORT
+ int xsortorder;
+ 
+ xsort(a, b)
+ register struct insbuf *a, *b; {
+     int ret;
+     if (a->xpos < b->xpos)
+ 	ret = -1;
+     else if (a->xpos > b->xpos)
+ 	ret = 1;
+     else
+ 	ret = 0;
+     return(xsortorder * ret);
+ }
+ #endif
+ 
  canonflush() {
      register struct insbuf *ip;
      insptr--;
***************
*** 59,68 ****
--- 78,99 ----
  
      if (insptr->xpos < insbuf[0].xpos) {
  	DBP((D_CAT, "canonflush: BACK (%d chars)\n", insptr - insbuf + 1));
+ #ifdef	SORT
+ 	xsortorder = -1;
+ 	insdump(insbuf, insptr);
+ 	qsort(insbuf, insptr - insbuf + 1, sizeof(struct insbuf), xsort);
+ 	insdump(insbuf, insptr);
+ #endif
  	for(ip = insptr;ip >= insbuf; ip--)
  	    canonchar(ip->xpos, insypos, ip->font, ip->points, ip->nc);
      } else {
  	DBP((D_CAT, "canonflush: FORW (%d chars)\n", insptr - insbuf + 1));
+ #ifdef	SORT
+ 	xsortorder = 1;
+ insdump(insbuf, insptr);
+ 	qsort(insbuf, insptr - insbuf + 1, sizeof(struct insbuf), xsort);
+ insdump(insbuf, insptr);
+ #endif
  	for(ip = insbuf;ip <= insptr; ip++)
  	    canonchar(ip->xpos, insypos, ip->font, ip->points, ip->nc);
      }
***************
*** 77,107 ****
      static short lastypos;
      static sstate = 0;
      static char sbuf[512];
! #ifdef	SPECIAL
      switch(sstate) {
  	case 0:
  	    if (font == 3 && nc == 34) {
  		sstate = 1;
! 		lastchar.xpos = xpos;
  		lastchar.font = font;
  		lastchar.points = points;
  		lastchar.nc = nc;
! 		lastypos = ypos;
  		optflush();
  		return;
  	    }
  	    break;
  	case 1:
! 	    if (font == 3 && nc == 34 &&
! 		xpos == lastchar.xpos && ypos == lastypos) {
! 		sstate++;
! 		sbuf[0] = '\0';
! 		return;
! 	    }
  	    if (be->beputchar)
  		(*be->beputchar)(lastchar.xpos, lastypos, lastchar.font,
  		    lastchar.points, lastchar.nc, (char *) NULL);
- 	    sstate = 0;
  	    break;
  	case 2:
  	    if (nc == 34 && font == 3) {
--- 108,146 ----
      static short lastypos;
      static sstate = 0;
      static char sbuf[512];
!     register char *p;
! #ifdef	INSPECIAL
!     /* Inline special directives, not supported yet */
      switch(sstate) {
  	case 0:
  	    if (font == 3 && nc == 34) {
  		sstate = 1;
! 		lastchar.xpos = specXPos = xpos;
  		lastchar.font = font;
  		lastchar.points = points;
  		lastchar.nc = nc;
! 		lastypos = specYPos = ypos;
  		optflush();
  		return;
  	    }
  	    break;
  	case 1:
! 	    if (font == 3 && nc == 34) {
! 		if (xpos == lastchar.xpos && ypos == lastypos) {
! 		    sstate++;
! 		    sbuf[0] = '\0';
! 		    return;
! 		} else {
! 		    lastchar.xpos = xpos;
! 		    lastypos = ypos;
! 		    /* stay in this state */
! 		}
! 	    } else
! 		sstate = 0;
! 
  	    if (be->beputchar)
  		(*be->beputchar)(lastchar.xpos, lastypos, lastchar.font,
  		    lastchar.points, lastchar.nc, (char *) NULL);
  	    break;
  	case 2:
  	    if (nc == 34 && font == 3) {
***************
*** 118,130 ****
  		return;
  	    }
  	    if (font == 3)
! 		strcat(sbuf, be->besymfont[nc].t2b_charseq);
  	    else
! 		strcat(sbuf, be->bestdfont[nc].t2b_charseq);
  	    return;
      }
  #endif
- 
      optinsert(xpos, ypos, font, points, nc);
  }
  
--- 157,185 ----
  		return;
  	    }
  	    if (font == 3)
! 		p = tabS[nc].ch_name;
  	    else
! 		p = tabN[nc].ch_name;
! 	    if (strlen(p) >= 2) {
! 		if (strcmp(p, "hy") == 0 ||
! 		    strcmp(p, "mi") == 0 ||
! 		    strcmp(p, "\\-") == 0)
! 		    p = "-";
! 		else if (strcmp(p, "ff") == 0 ||
! 			 strcmp(p, "fi") == 0 ||
! 			 strcmp(p, "fl") == 0)
! 		    ;
! 		else if (strcmp(p, "Fi") == 0)
! 		    p = "ffi";
! 		else if (strcmp(p, "Fl") == 0)
! 		    p = "ffl";
! 		else
! 		    p = " ";
! 	    }
! 	    strcat(sbuf, p);
  	    return;
      }
  #endif
      optinsert(xpos, ypos, font, points, nc);
  }
  
***************
*** 214,218 ****
--- 269,284 ----
      for (from = bp->t2b_charseq; *from;)
  	*optp++ = *from++;
      *optp = '\0';
+ }
+ #endif
+ 
+ #ifdef	SORT
+ insdump(b, p)
+ register struct insbuf *b, *p; {
+     if (!(debug&D_VERB))
+ 	return;
+     DBP((D_VERB, "insdump:\n"));
+     for(; b <= p; b++)
+ 	DBP((D_VERB, "%d %d\n", b->xpos, b->nc));
  }
  #endif
-- 
Chris Lewis, Elegant Communications Inc, {uunet!attcan,utzoo}!lsuc!eci386!clewis
Ferret mailing list: eci386!ferret-list, psroff mailing list: eci386!psroff-list
Psroff information/questions: psroff-request at eci386



More information about the Comp.sources.bugs mailing list