[net.text] fixes to pic

kelem@aero.ARPA (Steve Kelem) (05/01/86)

Here are some context diffs for corrections to the pic source.

The corrections are:
    1.  above/below can be used in conjuction with text justification
	(ljust/rjust). E.g. "text" above ljust at COORD
    2.  Extra-line space generated by eqn is now compensated for when doing
	vertical movements.
    3.  Pic grammar corrected so that it recognizes (position,position),
	as advertised in the documentation.  The grammar had (place,place).
    4.  The device-dependent characteristics are read from the DESC.out file
	instead of hard-coded constants.
    5.  Corrections to the overall height & width calculations for a picture.
    6.  More readable debugging output.
    7.  Kaare Christian's correction for small radii.
    8.  Updates for the manual, pic.man.  (in a separate message)

---=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
*** /tmp/d25048	Wed Mar 19 15:47:18 1986
----- arcgen.c	Fri Mar 14 15:38:39 1986
***************
*** 1,6
  #include	<stdio.h>
  #include	"pic.h"
  #include	"y.tab.h"
  
  struct obj *arcgen(type)	/* handles circular and (eventually) elliptical arcs */
  {

----- 1,7 -----
  #include	<stdio.h>
  #include	"pic.h"
  #include	"y.tab.h"
+ static char * sccsid = "@(#)arcgen.c	1.1.1.1 3/14/86";
  
  struct obj *arcgen(type)	/* handles circular and (eventually) elliptical arcs */
  {
***************
*** 92,99
  		dx2 = (tox - fromx) / 2;
  		dy2 = (toy - fromy) / 2;
  		phi = atan2(dy2, dx2) + (cw ? -PI2 : PI2);
! 		for (r=prevrad; (d = r*r - (dx2*dx2+dy2*dy2)) <= 0.0; r *= 2)
! 			;	/* this kludge gets around too-small radii */
  		prevrad = r;
  		ht = sqrt(d);
  		curx = fromx + dx2 + ht * cos(phi);

----- 93,104 -----
  		dx2 = (tox - fromx) / 2;
  		dy2 = (toy - fromy) / 2;
  		phi = atan2(dy2, dx2) + (cw ? -PI2 : PI2);
!  		r=prevrad;
!  		if ((d = r*r - (dx2*dx2+dy2*dy2)) < 0.0) {
!  			/* this kludge gets around too-small radii */
!  			r = sqrt(dx2*dx2+dy2*dy2);/* smallest possible radius */
!  			d = 0;
!  		}
  		prevrad = r;
  		ht = sqrt(d);
  		curx = fromx + dx2 + ht * cos(phi);
*** /tmp/d25052	Wed Mar 19 15:47:24 1986
----- driver.c	Fri Feb 14 16:39:03 1986
***************
*** 1,5
  #include <stdio.h>
  #include <ctype.h>
  
  #define	DEV202	1
  #define	DEVAPS	2

----- 1,6 -----
  #include <stdio.h>
  #include <ctype.h>
+ #include <math.h>
  
  #define	DEV202	1
  #define	DEVAPS	2
***************
*** 7,14
  #define	DEV450	4
  int	devtype	= DEV202;
  
! float	deltx;	/* max x value in output, for scaling */
! float	delty;	/* max y value in output, for scaling */
  int	dbg	= 0;
  int	res	= 972;	/* 202 is default */
  FILE	*fin;	/* input file pointer */

----- 8,15 -----
  #define	DEV450	4
  int	devtype	= DEV202;
  
! double	deltx;	/* max x value in output, for scaling */
! double	delty;	/* max y value in output, for scaling */
  int	dbg	= 0;
  int	res	= 972;	/* 202 is default */
  FILE	*fin;	/* input file pointer */
***************
*** 34,40
  main(argc,argv)
  char **argv;
  {
--- 	float atof();
  	int c;
  
  	cmdname = argv[0];

----- 35,40 -----
  main(argc,argv)
  char **argv;
  {
  	int c;
  
  	cmdname = argv[0];
*** /tmp/d25054	Wed Mar 19 15:47:31 1986
----- main.c	Fri Mar 14 14:13:33 1986
***************
*** 1,4
  #include	<stdio.h>
  #include	"pic.h"
  #include	"y.tab.h"
  

----- 1,7 -----
  #include	<stdio.h>
+ #include	<sys/types.h>
+ #include	<sys/stat.h>
+ #include	"../troff/dev.h"
  #include	"pic.h"
  #include	"y.tab.h"
  static char * sccsid = "@(#)main.c	1.2 3/14/86";
***************
*** 1,6
  #include	<stdio.h>
  #include	"pic.h"
  #include	"y.tab.h"
  
  struct	obj	*objlist[MAXOBJ];	/* store the elements here */
  int	nobj	= 0;

----- 4,10 -----
  #include	"../troff/dev.h"
  #include	"pic.h"
  #include	"y.tab.h"
+ static char * sccsid = "@(#)main.c	1.2 3/14/86";
  
  struct	obj	*objlist[MAXOBJ];	/* store the elements here */
  int	nobj	= 0;
***************
*** 19,26
  
  int	codegen	= 0;	/* 1=>output for this picture; 0=>no output */
  
! float	deltx	= 6;	/* max x value in output, for scaling */
! float	delty	= 6;	/* max y value in output, for scaling */
  int	dbg	= 0;
  extern	FILE	*yyin,	/* input file pointer */
  		*skeldb; /* output pointer for dbg messeges */

----- 23,30 -----
  
  int	codegen	= 0;	/* 1=>output for this picture; 0=>no output */
  
! double	deltx	= 6;	/* max x value in output, for scaling */
! double	delty	= 6;	/* max y value in output, for scaling */
  int	dbg	= 0;
  extern	FILE	*yyin,	/* input file pointer */
  		*skeldb; /* output pointer for dbg messeges */
***************
*** 31,37
  int	crop	= 1;	/* trim off exterior white space if non-zero */
  extern int	useDline;	/* if set, use \D for all lines */
  
! /* You may want to change this if you don't have a 202... */
  
  #ifdef	APS
  	int	devtype	= DEVAPS;

----- 35,44 -----
  int	crop	= 1;	/* trim off exterior white space if non-zero */
  extern int	useDline;	/* if set, use \D for all lines */
  
! int	devtype;
! int	res;
! int	DX = 1;
! int	DY = 1;
  
  float	hshift	= 0;	/* move this far left for text (in em's) */
  float	vshift	= 0.2;	/* this far down */
***************
*** 33,58
  
  /* You may want to change this if you don't have a 202... */
  
--- #ifdef	APS
--- 	int	devtype	= DEVAPS;
--- 	int	res	= 723;
--- 	int	DX	= 3;
--- 	int	DY	= 3;
--- #else
--- 	int	devtype	= DEV202;
--- 	int	res	= 972;	/* default is 202 */
--- 	int	DX	= 4;	/* used only for old-style troff */
--- 	int	DY	= 4;
--- #endif
--- 
--- /* mandatory values for graphic systems CAT: */
--- /*
--- int	devtype = DEVCAT;
--- int	res	= 432;
--- int	DX = 3;
--- int	DY = 3;
--- */
--- 
  float	hshift	= 0;	/* move this far left for text (in em's) */
  float	vshift	= 0.2;	/* this far down */
  

----- 40,45 -----
  int	DX = 1;
  int	DY = 1;
  
  float	hshift	= 0;	/* move this far left for text (in em's) */
  float	vshift	= 0.2;	/* this far down */
  
***************
*** 69,74
  main(argc, argv)
  	char **argv;
  {
  	cmdname = argv[0];
  	while (argc > 1 && *argv[1] == '-') {
  		switch (argv[1][1]) {

----- 56,63 -----
  main(argc, argv)
  	char **argv;
  {
+ 	    /* read the resolution for postscript (default typesetter) */
+ 	readres("psc");
  	cmdname = argv[0];
  	while (argc > 1 && *argv[1] == '-') {
  		switch (argv[1][1]) {
***************
*** 73,97
  	while (argc > 1 && *argv[1] == '-') {
  		switch (argv[1][1]) {
  		case 'T':
! 			if (strcmp(&argv[1][2], "aps") == 0) {
! 				res = 723;
! 				devtype = DEVAPS;
! 				DX = DY = 1;
! 			} else if (strcmp(&argv[1][2], "cat") == 0) {
! 				res = 432;
! 				devtype = DEVCAT;
! 				DX = DY = 3;
! 			} else if (strcmp(&argv[1][2], "ver") == 0) {
! 				res = 200;
! 				devtype = DEVVER;
! 				DX = DY = 1;
! 			} else if (strcmp(&argv[1][2], "450") == 0) {
! 				res = 240;
! 				devtype = DEV450;
! 			} else {
! 				res = atoi(&argv[1][2]);
! 			}
! 			break;
  		case 'd':
  			dbg = 1;
  			break;

----- 62,69 -----
  	while (argc > 1 && *argv[1] == '-') {
  		switch (argv[1][1]) {
  		case 'T':
! 		    readres(&argv[1][2]);
! 		    break;
  		case 'd':
  			dbg = 1;
  			break;
***************
*** 202,210
  			reset();
  			yyparse();
  			/* yylval now contains 'E' or 'F' from .PE or .PF */
! 			if (buf[3] == ' ')	/* assume next thing is width */
! 				deltx = delty = atof(&buf[4]);
! 			else {
  				deltx = xmax - xmin;
  				if (deltx <= 0)
  					deltx = ymax - ymin;

----- 174,183 -----
  			reset();
  			yyparse();
  			/* yylval now contains 'E' or 'F' from .PE or .PF */
! 			switch (sscanf(p, "%lf %lf", &delty, &deltx)) {
! 			    default:
! 			    case EOF:
! 			    case 0:
  				deltx = xmax - xmin;
  				if (deltx <= 0)
  				    deltx = ymax - ymin;
***************
*** 207,213
  			else {
  				deltx = xmax - xmin;
  				if (deltx <= 0)
! 					deltx = ymax - ymin;
  				deltx /= getfval("scale");
  				delty = deltx;
  			}

----- 180,186 -----
  			    case 0:
  				deltx = xmax - xmin;
  				if (deltx <= 0)
! 				    deltx = ymax - ymin;
  				deltx /= getfval("scale");
  				delty = deltx;
  				break;
***************
*** 210,216
  					deltx = ymax - ymin;
  				deltx /= getfval("scale");
  				delty = deltx;
! 			}
  			dprintf("deltx = %.3f\n", deltx);
  			if (codegen && !synerr) {
  				openpl(&buf[3]);	/* puts out .PS, with ht & wid stuck in */

----- 183,192 -----
  				    deltx = ymax - ymin;
  				deltx /= getfval("scale");
  				delty = deltx;
! 				break;
! 			    case 1: deltx = delty; break;
! 			    case 2: break;
! 			    }
  			dprintf("deltx = %.3f\n", deltx);
  			if (codegen && !synerr) {
  				openpl(&buf[3]);	/* puts out .PS, with ht & wid stuck in */
***************
*** 250,253
  	sxmax = symax = 4096;
  	xmin = ymin = 30000;
  	xmax = ymax = -30000;
  }

----- 226,272 -----
  	sxmax = symax = 4096;
  	xmin = ymin = 30000;
  	xmax = ymax = -30000;
+ }
+ 
+ readres(devname)
+ char * devname;
+ {
+     char devicename[100];
+     struct dev device;	/* the device descriptor */
+     struct stat statbuf;
+     int rstat;		/* return code from read */
+     int tfile;		/* the file descriptor for the DESC.out file */
+ 
+ 	    /* copy the font directory name */
+     strcpy(devicename, FONTDIR);
+     strcpy(devicename+strlen(devicename), "/dev");
+     strcpy(devicename+strlen(devicename), devname);
+     if ((stat(devicename, &statbuf) == -1) ||
+ 	(statbuf.st_dev & S_IFDIR != S_IFDIR))
+ 	yyerror("eqn: cannot find typesetter device directory \"%s\"\n",
+ 	    devicename);
+     strcpy(devicename+strlen(devicename), "/DESC.out");
+     if (stat(devicename, &statbuf) == -1)
+ 	yyerror("eqn: cannot find typesetter device description file \"%s\"\n",
+ 	    devicename);
+     if ((tfile = open(devicename, 0)) == -1)
+ 	yyerror("eqn: cannot open typesetter device description file \"%s\"\n",
+ 	    devicename);
+     if (((rstat = read(tfile, &device, sizeof(device))) == 0) ||
+ 	(rstat == -1))
+ 	yyerror("eqn: cannot read typesetter device description from file \"%s\" could only read %d bytes\n",
+ 	    devicename, rstat);
+     res = device.res;
+ 
+     if (strcmp(devname, "202") == 0)
+ 	    {devtype = DEV202; }
+     else if (strcmp(devname, "aps") == 0)
+ 	    {devtype = DEVAPS; }
+     else if (strcmp(devname, "cat") == 0)
+ 	    {devtype = DEVCAT; }
+     else if (strcmp(devname, "450") == 0)
+ 	    {devtype = DEV450; }
+     else if (strcmp(devname, "450") == 0)
+ 	    {devtype = DEVVER; }
+     close(tfile);
  }
*** /tmp/d25062	Wed Mar 19 15:47:40 1986
----- makefile	Fri Feb 14 16:39:40 1986
***************
*** 1,4
  YFLAGS = -d
  MOFILES = main.o boxgen.o print.o misc.o symtab.o blockgen.o circgen.o  \
  	  arcgen.o linegen.o movegen.o troffgen.o textgen.o  \
  	  pic2.o lineseg.o

----- 1,5 -----
  YFLAGS = -d
+ LDFLAGS =
  MOFILES = main.o boxgen.o print.o misc.o symtab.o blockgen.o circgen.o  \
  	  arcgen.o linegen.o movegen.o troffgen.o textgen.o  \
  	  pic2.o lineseg.o
***************
*** 14,20
  a.out:	pic
  
  pltroff:	driver.o pltroff.o
! 	cc  -i -o pltroff pltroff.o driver.o -lm
  
  npltroff:	driver.o npltroff.o
  	cc -i -o npltroff npltroff.o driver.o -lm

----- 15,21 -----
  a.out:	pic
  
  pltroff:	driver.o pltroff.o
! 	$(CC)  $(LDFLAGS) -o pltroff pltroff.o driver.o -lm
  
  npltroff:	driver.o npltroff.o
  	$(CC) $(LDFLAGS) -o npltroff npltroff.o driver.o -lm
***************
*** 17,23
  	cc  -i -o pltroff pltroff.o driver.o -lm
  
  npltroff:	driver.o npltroff.o
! 	cc -i -o npltroff npltroff.o driver.o -lm
  
  $(OFILES):	pic.h
  

----- 18,24 -----
  	$(CC)  $(LDFLAGS) -o pltroff pltroff.o driver.o -lm
  
  npltroff:	driver.o npltroff.o
! 	$(CC) $(LDFLAGS) -o npltroff npltroff.o driver.o -lm
  
  $(OFILES):	pic.h
  
***************
*** 22,28
  $(OFILES):	pic.h
  
  pic:	picy.o picl.o $(OFILES) pic.h 
! 	cc  -i  picy.o picl.o $(OFILES)  -lm
  
  lineseg:	lineseg.o picy.o picl.o $(OFILES)
  	cc -o lineseg picy.o picl.o lineseg.o $(OFILES)  -lm

----- 23,29 -----
  $(OFILES):	pic.h
  
  pic:	picy.o picl.o $(OFILES) pic.h 
! 	$(CC)  $(LDFLAGS)  picy.o picl.o $(OFILES)  -lm
  
  lineseg:	lineseg.o picy.o picl.o $(OFILES)
  	$(CC) -o lineseg picy.o picl.o lineseg.o $(OFILES)  -lm
***************
*** 25,31
  	cc  -i  picy.o picl.o $(OFILES)  -lm
  
  lineseg:	lineseg.o picy.o picl.o $(OFILES)
! 	cc -o lineseg picy.o picl.o lineseg.o $(OFILES)  -lm
  
  
  

----- 26,32 -----
  	$(CC)  $(LDFLAGS)  picy.o picl.o $(OFILES)  -lm
  
  lineseg:	lineseg.o picy.o picl.o $(OFILES)
! 	$(CC) -o lineseg picy.o picl.o lineseg.o $(OFILES)  -lm
  
  
  
***************
*** 38,44
  	@pr WISH UNDOC picy.y picl.l pic.h  $(CFILES)
  
  gout:	gout.c
! 	cc -o gout gout.c
  
  gin:	gin.c
  	cc -o gin gin.c

----- 39,45 -----
  	@pr WISH UNDOC picy.y picl.l pic.h  $(CFILES)
  
  gout:	gout.c
! 	$(CC) -o gout gout.c
  
  gin:	gin.c
  	$(CC) -o gin gin.c
***************
*** 41,47
  	cc -o gout gout.c
  
  gin:	gin.c
! 	cc -o gin gin.c
  
  src:
  	cp UNDOC makefile $(SRCFILES)  driver.c /usr1/src/cmd/pic

----- 42,48 -----
  	$(CC) -o gout gout.c
  
  gin:	gin.c
! 	$(CC) -o gin gin.c
  
  src:
  	cp UNDOC makefile $(SRCFILES)  driver.c /usr1/src/cmd/pic
***************
*** 55,61
  	refer -e picmemo | pic | eqn | troff -ms $(TFLAGS) >pic.out 2>pic.mess
  
  spline:	spline.c
! 	cc spline.c -lm -o spline
  
  grapic: grapic.c
  	cc -DPIC -i -O grapic.c -lplot -lm -o grapic

----- 56,62 -----
  	refer -e picmemo | pic | eqn | troff -ms $(TFLAGS) >pic.out 2>pic.mess
  
  spline:	spline.c
! 	$(CC) spline.c -lm -o spline
  
  grapic: grapic.c
  	$(CC) -DPIC $(LDFLAGS) -O grapic.c -lplot -lm -o grapic
***************
*** 58,64
  	cc spline.c -lm -o spline
  
  grapic: grapic.c
! 	cc -DPIC -i -O grapic.c -lplot -lm -o grapic
  
  clean:
  	rm a.out *.o y.tab.h make.out

----- 59,65 -----
  	$(CC) spline.c -lm -o spline
  
  grapic: grapic.c
! 	$(CC) -DPIC $(LDFLAGS) -O grapic.c -lplot -lm -o grapic
  
  clean:
  	rm a.out *.o y.tab.h make.out
*** /tmp/d25064	Wed Mar 19 15:47:49 1986
----- misc.c	Wed Mar 19 08:48:27 1986
***************
*** 1,6
  #include	<stdio.h>
  #include	"pic.h"
  #include	"y.tab.h"
  
  setdir(n)	/* set direction from n */
  	int n;

----- 1,7 -----
  #include	<stdio.h>
  #include	"pic.h"
  #include	"y.tab.h"
+ static char * sccsid = "3/19/86 - @(#)misc.c	1.1.1.2";
  
  setdir(n)	/* set direction from n */
  	int n;
***************
*** 60,68
  	int type;
  	YYSTYPE val;
  {
! 	if (type == 0 && val.i == 0) {	/* clear table for next stat */
! 		nattr = 0;
! 		return;
  	}
  	dprintf("attr %d:  %d %d\n", nattr, type, val.i);
  	attr[nattr].a_type = type;

----- 61,186 -----
  	int type;
  	YYSTYPE val;
  {
!     if (type == 0 && val.i == 0) {	/* clear table for next stat */
! 	    nattr = 0;
! 	    return;
!     }
!     if (dbg) {
! 	printf("attr %d:  ", nattr);
! 	switch (type) {
! 	    case ABOVE: printf("ABOVE"); break; case AND: printf("AND"); break;
! 	    case ARC: printf("ARC"); break; case ARROW: printf("ARROW"); break;
! 	    case AT: printf("AT"); break; case ATTR: printf("ATTR"); break;
! 	    case BELOW: printf("BELOW"); break; case BETWEEN: printf("BETWEEN"); break;
! 	    case BLOCK: printf("BLOCK"); break; case BLOCKEND: printf("BLOCKEND"); break;
! 	    case BOX: printf("BOX"); break; case BY: printf("BY"); break;
! 	    case CCW: printf("CCW"); break; case CENTER: printf("CENTER"); break;
! 	    case CHOP: printf("CHOP"); break; case CIRCLE: printf("CIRCLE"); break;
! 	    case CORNER: printf("CORNER"); break; case CW: printf("CW"); break;
! 	    case DASH: printf("DASH"); break; case DEFNAME: printf("DEFNAME"); break;
! 	    case DIAMETER: printf("DIAMETER"); break; case DIR: printf("DIR"); break;
! 	    case DOT: printf("DOT"); break; case DOTHT: printf("DOTHT"); break;
! 	    case DOTRAD: printf("DOTRAD"); break; case DOTWID: printf("DOTWID"); break;
! 	    case DOTX: printf("DOTX"); break; case DOTY: printf("DOTY"); break;
! 	    case DOWN: printf("DOWN"); break; case EAST: printf("EAST"); break;
! 	    case ELLIPSE: printf("ELLIPSE"); break; case END: printf("END"); break;
! 	    case FILL: printf("FILL"); break; case FROM: printf("FROM"); break;
! 	    case HEAD: printf("HEAD"); break; case HEIGHT: printf("HEIGHT"); break;
! 	    case HERE: printf("HERE"); break; case LAST: printf("LAST"); break;
! 	    case LEFT: printf("LEFT"); break; case LENGTH: printf("LENGTH"); break;
! 	    case LINE: printf("LINE"); break; case LJUST: printf("LJUST"); break;
! 	    case MOVE: printf("MOVE"); break; case NE: printf("NE"); break;
! 	    case NORTH: printf("NORTH"); break; case NTH: printf("NTH"); break;
! 	    case NUMBER: printf("NUMBER"); break; case NW: printf("NW"); break;
! 	    case PLACE: printf("PLACE"); break; case PLACENAME: printf("PLACENAME"); break;
! 	    case PRINT: printf("PRINT"); break; case RADIUS: printf("RADIUS"); break;
! 	    case RIGHT: printf("RIGHT"); break; case RJUST: printf("RJUST"); break;
! 	    case SAME: printf("SAME"); break; case SE: printf("SE"); break;
! 	    case SIZE: printf("SIZE"); break; case SOUTH: printf("SOUTH"); break;
! 	    case SPLINE: printf("SPLINE"); break; case SPREAD: printf("SPREAD"); break;
! 	    case ST: printf("ST"); break; case START: printf("START"); break;
! 	    case SW: printf("SW"); break; case TEXT: printf("TEXT"); break;
! 	    case THEN: printf("THEN"); break; case TO: printf("TO"); break;
! 	    case TROFF: printf("TROFF"); break; case UMINUS: printf("UMINUS"); break;
! 	    case UP: printf("UP"); break; case VARNAME: printf("VARNAME"); break;
! 	    case WEST: printf("WEST"); break; case WIDTH: printf("WIDTH"); break;
! 	    case WITH: printf("WITH"); break;
! 	    default: printf("\"%s\"", type);
! 	    }
! 	switch(type) {
! 	    case ABOVE: case BELOW: case CENTER: case FILL: case LJUST:
! 	    case RJUST: case SPREAD:
! 		printf("\t%s\n", val.p); break;
! 	    case DASH:
! 	    case DIAMETER:
! 	    case DOT:
! 	    case DOTWID:
! 	    case DOWN:
! 	    case HEIGHT:
! 	    case LEFT:
! 	    case LENGTH:
! 	    case RADIUS:
! 	    case RIGHT:
! 	    case SIZE:
! 	    case UP:
! 	    case WIDTH:
! 		printf("\t%g\n", val.f); break;
! 
! 	    case AT:
! 	    case FROM:
! 	    case TO:
! 		printf("\t(%g,%g)\n", val.o->o_x, val.o->o_y); break;
! 	    case ARC:
! 	    case ARROW:
! 	    case ATTR:
! 	    case BETWEEN:
! 	    case BLOCK:
! 	    case BLOCKEND:
! 	    case BOX:
! 	    case BY:
! 	    case CCW:
! 	    case CHOP:
! 	    case CIRCLE:
! 	    case CORNER:
! 	    case CW:
! 	    case DEFNAME:
! 	    case DIR:
! 	    case DOTHT:
! 	    case DOTRAD:
! 	    case DOTX:
! 	    case DOTY:
! 	    case EAST:
! 	    case ELLIPSE:
! 	    case END:
! 	    case HEAD:
! 	    case HERE:
! 	    case LAST:
! 	    case LINE:
! 	    case MOVE:
! 	    case NE:
! 	    case NORTH:
! 	    case NTH:
! 	    case NUMBER:
! 	    case NW:
! 	    case PLACE:
! 	    case PLACENAME:
! 	    case PRINT:
! 	    case SAME:
! 	    case SE:
! 	    case SOUTH:
! 	    case SPLINE:
! 	    case ST:
! 	    case START:
! 	    case SW:
! 	    case TEXT:
! 	    case THEN:
! 	    case TROFF:
! 	    case UMINUS:
! 	    case VARNAME:
! 	    case WEST:
! 	    case WITH:
! 	    default:
! 		printf("\t%d\n", val.i); break;
  	}
      }
      attr[nattr].a_type = type;
***************
*** 64,73
  		nattr = 0;
  		return;
  	}
! 	dprintf("attr %d:  %d %d\n", nattr, type, val.i);
! 	attr[nattr].a_type = type;
! 	attr[nattr].a_val = val;
! 	nattr++;
  }
  
  printexpr(f)	/* print expression for debugging */

----- 182,191 -----
  	    default:
  		printf("\t%d\n", val.i); break;
  	}
!     }
!     attr[nattr].a_type = type;
!     attr[nattr].a_val = val;
!     nattr++;
  }
  
  printexpr(f)	/* print expression for debugging */
***************
*** 96,102
  	return(p);
  }
  
! struct obj *makepos(x, y)	/* make a osition cell */
  	float x, y;
  {
  	struct obj *p;

----- 214,220 -----
  	return(p);
  }
  
! struct obj *makepos(x, y)	/* make a position cell */
  	float x, y;
  {
  	struct obj *p;
***************
*** 113,119
  {
  	struct obj *p;
  
! 	dprintf("fraction = %.2f\n", f);
  	p = makenode(PLACE, 0);
  	p->o_x = p1->o_x + f * (p2->o_x - p1->o_x);
  	p->o_y = p1->o_y + f * (p2->o_y - p1->o_y);

----- 231,237 -----
  {
  	struct obj *p;
  
! 	dprintf("fraction = %g\n", f);
  	p = makenode(PLACE, 0);
  	p->o_x = p1->o_x + f * (p2->o_x - p1->o_x);
  	p->o_y = p1->o_y + f * (p2->o_y - p1->o_y);
***************
*** 124,130
  	struct obj *p;
  	int corner;
  {
! 	float x, y, x1, y1;
  
  	dprintf("getpos %o %d\n", p, corner);
  	x = p->o_x;

----- 242,248 -----
  	struct obj *p;
  	int corner;
  {
! 	double x, y, x1, y1;
  
  	dprintf("getpos %o(%g,%g) %s\n", p, p->o_x, p->o_y, 
  	    (corner == NORTH? "NORTH" :
***************
*** 126,132
  {
  	float x, y, x1, y1;
  
! 	dprintf("getpos %o %d\n", p, corner);
  	x = p->o_x;
  	y = p->o_y;
  	x1 = p->o_val[0];

----- 244,260 -----
  {
  	double x, y, x1, y1;
  
! 	dprintf("getpos %o(%g,%g) %s\n", p, p->o_x, p->o_y, 
! 	    (corner == NORTH? "NORTH" :
! 	    (corner == WEST? "WEST" :
! 	    (corner == SOUTH? "SOUTH" :
! 	    (corner == EAST? "EAST" :
! 	    (corner == NE? "NE" :
! 	    (corner == NW? "NW" :
! 	    (corner == SW? "SW" :
! 	    (corner == SE? "SE" :
! 	    (corner == START? "START" :
! 	    (corner == END? "END" : "UNKNOWN")))))))))) );
  	x = p->o_x;
  	y = p->o_y;
  	x1 = p->o_val[0];
*** /tmp/d25090	Wed Mar 19 15:48:04 1986
----- pic.h	Tue Mar 18 11:27:47 1986
***************
*** 1,4
  #define	dprintf	if(dbg)printf
  
  #define	HEAD1	1
  #define	HEAD2	2

----- 1,5 -----
  #define	dprintf	if(dbg)printf
+ #define FONTDIR "/usr/lib/font"
  
  #define	HEAD1	1
  #define	HEAD2	2
***************
*** 97,103
  extern	YYSTYPE	getvar();
  extern	struct symtab *lookup(), *makevar();
  
! extern	float	deltx, delty;
  extern	int	lineno;
  extern	int	synerr;
  extern	int	crop;

----- 98,104 -----
  extern	YYSTYPE	getvar();
  extern	struct symtab *lookup(), *makevar();
  
! extern	double	deltx, delty;
  extern	int	lineno;
  extern	int	synerr;
  extern	int	crop;
***************
*** 125,128
  extern	int	nstack;
  extern int cw;
  
--- extern float atof();

----- 126,128 -----
  extern	int	nstack;
  extern int cw;
  
*** /tmp/d25106	Wed Mar 19 15:48:08 1986
----- picy.y	Tue Mar 18 11:27:48 1986
***************
*** 30,35
  %token	<i>	DOT DASH CHOP
  %token	<o>	ST	/* statement terminator */
  
  %left	<f>	'+' '-'
  %left	<f>	'*' '/' '%'
  %right	<f>	UMINUS

----- 30,36 -----
  %token	<i>	DOT DASH CHOP
  %token	<o>	ST	/* statement terminator */
  
+ %right		':'
  %left	<f>	'+' '-'
  %left	<f>	'*' '/' '%'
  %right	<f>	UMINUS
***************
*** 143,149
  	| '(' expr ',' expr ')'			{ $$ = makepos($2, $4); }
  	| position '+' '(' expr ',' expr ')'	{ $$ = fixpos($1, $4, $6); }
  	| position '-' '(' expr ',' expr ')'	{ $$ = fixpos($1, -$4, -$6); }
! 	| '(' place ',' place ')'	{ $$ = makepos(getcomp($2,DOTX), getcomp($4,DOTY)); }
  	| expr '<' position ',' position '>'	{ $$ = makebetween($1, $3, $5); }
  	| expr BETWEEN position AND position	{ $$ = makebetween($1, $3, $5); }
  	;

----- 144,150 -----
  	| '(' expr ',' expr ')'			{ $$ = makepos($2, $4); }
  	| position '+' '(' expr ',' expr ')'	{ $$ = fixpos($1, $4, $6); }
  	| position '-' '(' expr ',' expr ')'	{ $$ = fixpos($1, -$4, -$6); }
! 	| '(' position ',' position ')'	{ $$ = makepos(getcomp($2,DOTX), getcomp($4,DOTY)); }
  	| expr '<' position ',' position '>'	{ $$ = makebetween($1, $3, $5); }
  	| expr BETWEEN position AND position	{ $$ = makebetween($1, $3, $5); }
  	;
*** /tmp/d25108	Wed Mar 19 15:48:13 1986
----- pltroff.c	Wed Mar 19 08:44:32 1986
***************
*** 13,18
   */
  
  #include <stdio.h>
  #include <math.h>
  extern int dbg;
  

----- 13,19 -----
   */
  
  #include <stdio.h>
+ static char * sccsid = "@(#)pltroff.c	1.1.1.4 3/19/86";
  #include <math.h>
  #include "pic.h"
  extern int dbg;
***************
*** 14,19
  
  #include <stdio.h>
  #include <math.h>
  extern int dbg;
  
  /* this is the place to define OLDTROFF if you're going to */

----- 15,21 -----
  #include <stdio.h>
  static char * sccsid = "@(#)pltroff.c	1.1.1.4 3/19/86";
  #include <math.h>
+ #include "pic.h"
  extern int dbg;
  
  /* this is the place to define OLDTROFF if you're going to */
***************
*** 67,74
  int	hmax;		/* right end of output */
  int	vmax;		/* top of output (down is positive) */
  
! extern	float	deltx;
! extern	float	delty;
  extern	float	xmin, ymin, xmax, ymax, sxmin, symin, sxmax, symax;
  extern	int	crop;
  

----- 69,76 -----
  int	hmax;		/* right end of output */
  int	vmax;		/* top of output (down is positive) */
  
! extern	double	deltx;
! extern	double	delty;
  extern	float	xmin, ymin, xmax, ymax, sxmin, symin, sxmax, symax;
  extern	int	crop;
  
***************
*** 193,199
  	hvflush();
  	printf("\\h'-%.1fm'\\v'%.1fm'", hshift, vshift);	/* shift down and left */
  			/*  .3 .3 is best for PO in circuit diagrams */
! 	if (t == 'A')
  		nh++;
  	else if (t == 'B')
  		nh--;

----- 195,212 -----
  	hvflush();
  	printf("\\h'-%.1fm'\\v'%.1fm'", hshift, vshift);	/* shift down and left */
  			/*  .3 .3 is best for PO in circuit diagrams */
! 	/*
! 	fprintf(stderr, "pltroff: t is %x (", t);
! 	if (((t & 0xff00)>>8) >= ' ') 
! 	    fprintf(stderr, "%c,", (t&0xff00)>>8);
! 	else
! 	    fprintf(stderr, "^%c,", ((t&0xff00)>>8) + '@');
! 	if ((t & 0xff) >= ' ') 
! 	    fprintf(stderr, "%c)\n", t&0xff);
! 	else
! 	    fprintf(stderr, "^%c)\n", (t&0xff) + '@');
! 	*/
! 	if (((t&0xff00) == ('A' << 8)) || ((t&0xff) == 'A'))
  		nh++;
  	else if (((t&0xff00) == ('B' << 8)) || ((t&0xff) == 'B'))
  		nh--;
***************
*** 195,201
  			/*  .3 .3 is best for PO in circuit diagrams */
  	if (t == 'A')
  		nh++;
! 	else if (t == 'B')
  		nh--;
  	if (nh)
  		printf("\\v'%du*\\n(.vu/2u'", -nh);

----- 208,214 -----
  	*/
  	if (((t&0xff00) == ('A' << 8)) || ((t&0xff) == 'A'))
  		nh++;
! 	else if (((t&0xff00) == ('B' << 8)) || ((t&0xff) == 'B'))
  		nh--;
  	if (nh)
  		printf("\\v'%du*\\n(.vu/2u'", -nh);
***************
*** 206,212
  			q = 1;
  			break;
  		}
! 	switch (t) {
  	case 'L':
  	default:
  		printf("%s", s);

----- 219,225 -----
  			q = 1;
  			break;
  		}
! 	switch (t&0xff) {
  	case 'L':
  	default:
  		printf("%s", s);
***************
*** 229,234
  	/* don't need these if flyback called immediately */
  	printf("\n");
  	flyback();
  }
  
  line(x0, y0, x1, y1)	/* draw line from x0,y0 to x1,y1 */

----- 242,250 -----
  	/* don't need these if flyback called immediately */
  	printf("\n");
  	flyback();
+ 	printf(".sp -\\n(.au\n");	/* take extra-line space into account */
+ 	printf("\\x'0'\n");		/* clear the extra-line space */
+ 	printf(".sp -1\n");
  }
  
  line(x0, y0, x1, y1)	/* draw line from x0,y0 to x1,y1 */
*** /tmp/d25111	Wed Mar 19 15:48:23 1986
----- print.c	Tue Mar 11 12:07:29 1986
***************
*** 1,7
  #include	<stdio.h>
  #include	"pic.h"
  #include	"y.tab.h"
! static char * print_sccsid = "@(#)print.c	1.1 2/15/85";
  int xxx;
  print()
  {

----- 1,7 -----
  #include	<stdio.h>
  #include	"pic.h"
  #include	"y.tab.h"
! static char * print_sccsid = "@(#)print.c	1.1.1.1 3/11/86";
  int xxx;
  print()
  {
***************
*** 198,203
  	dotline(x0, y1, x0, y0, ddtype, ddval);
  }
  
  dotext(p)	/* print text strings of p in proper vertical spacing */
  	struct obj *p;
  {

----- 198,219 -----
  	dotline(x0, y1, x0, y0, ddtype, ddval);
  }
  
+ isabove_below(type)	/* return 1 if type is a above_below type, 0 otherwise */
+ int type;
+ {
+     if (type == 'A' || type == 'B')
+ 	 return 1;
+     else return 0;
+ }
+ 
+ is_just(type)	/* return 1 if type is a justification type, 0 otherwise */
+ int type;
+ {
+     if (type == 'C' || type == 'L' ||type == 'R' )
+ 	 return 1;
+     else return 0;
+ }
+ 
  dotext(p)	/* print text strings of p in proper vertical spacing */
  	struct obj *p;
  {
***************
*** 203,208
  {
  	int i, nhalf;
  
  	nhalf = p->o_nt2 - p->o_nt1 - 1;
  	for (i = p->o_nt1; i < p->o_nt2; i++) {
  		label(text[i].t_val, text[i].t_type, nhalf);

----- 219,227 -----
  {
  	int i, nhalf;
  
+ 	/*
+ 	fprintf(stderr, "dotext: ");
+ 	*/
  	nhalf = p->o_nt2 - p->o_nt1 - 1;
  	for (i = p->o_nt1; i < p->o_nt2; i++) {
  	    /*
***************
*** 205,211
  
  	nhalf = p->o_nt2 - p->o_nt1 - 1;
  	for (i = p->o_nt1; i < p->o_nt2; i++) {
! 		label(text[i].t_val, text[i].t_type, nhalf);
! 		nhalf -= 2;
  	}
  }

----- 224,260 -----
  	*/
  	nhalf = p->o_nt2 - p->o_nt1 - 1;
  	for (i = p->o_nt1; i < p->o_nt2; i++) {
! 	    /*
! 	    fprintf(stderr, "    %d: %x %c \"%s\"\n",
! 		i, text[i].t_type, text[i].t_type, text[i].t_val);
! 	    */
! 	    if (i+1 < p->o_nt2) {
! 		if (is_just(text[i].t_type) && strlen(text[i+1].t_val) == 0 &&
! 			isabove_below(text[i+1].t_type)) {
! 		    /* put above/below on top of justification */
! 		    text[i].t_type |= text[i+1].t_type << 8;
! 		    /*
! 		    fprintf(stderr, "    %d adjusted to: %x %c \"%s\"\n",
! 			i, text[i].t_type, text[i].t_type, text[i].t_val);
! 		    */
! 		    label(text[i].t_val, text[i].t_type, nhalf);
! 		    i++;
! 		}
! 		else
! 		    if (isabove_below(text[i].t_type) && strlen(text[i+1].t_val) == 0 &&
! 			is_just(text[i+1].t_type)) {
! 		    /* put above/below on top of justification */
! 		    text[i].t_type = text[i+1].t_type | (text[i].t_type << 8);
! 		    /*
! 		    fprintf(stderr, "    %d adjusted to: %x %c \"%s\"\n",
! 			i, text[i].t_type, text[i].t_type, text[i].t_val);
! 		    */
! 		    label(text[i].t_val, text[i].t_type, nhalf);
! 		    i++;
! 		}
! 		else label(text[i].t_val, text[i].t_type, nhalf);
! 	    }
! 	    else label(text[i].t_val, text[i].t_type, nhalf);
! 	    nhalf -= 2;
  	}
  }
*** /tmp/d25116	Wed Mar 19 15:48:31 1986
----- textgen.c	Sun Mar  9 15:59:53 1986
***************
*** 1,4
  #include	<stdio.h>
  #include	"pic.h"
  #include	"y.tab.h"
  

----- 1,5 -----
  #include	<stdio.h>
+ static char * sccsid = "@(#)textgen.c	1.1.1.2 3/9/86";
  #include	"pic.h"
  #include	"y.tab.h"
  
***************
*** 30,36
  			cury = ppos->o_y;
  			break;
  		case LJUST:
! 			type = 'L';
  			break;
  		case RJUST:
  			type = 'R';

----- 31,37 -----
  			cury = ppos->o_y;
  			break;
  		case LJUST:
! 			type = 'L' | type & 0xff00;
  			break;
  		case RJUST:
  			type = 'R' | type & 0xff00;
***************
*** 33,39
  			type = 'L';
  			break;
  		case RJUST:
! 			type = 'R';
  			break;
  		case SPREAD:
  			type = 'S';

----- 34,40 -----
  			type = 'L' | type & 0xff00;
  			break;
  		case RJUST:
! 			type = 'R' | type & 0xff00;
  			break;
  		case SPREAD:
  			type = 'S' | type & 0xff00;
***************
*** 36,42
  			type = 'R';
  			break;
  		case SPREAD:
! 			type = 'S';
  			break;
  		case FILL:
  			type = 'F';

----- 37,43 -----
  			type = 'R' | type & 0xff00;
  			break;
  		case SPREAD:
! 			type = 'S' | type & 0xff00;
  			break;
  		case FILL:
  			type = 'F' | type & 0xff00;
***************
*** 39,45
  			type = 'S';
  			break;
  		case FILL:
! 			type = 'F';
  			break;
  		case ABOVE:
  			type = 'A';

----- 40,46 -----
  			type = 'S' | type & 0xff00;
  			break;
  		case FILL:
! 			type = 'F' | type & 0xff00;
  			break;
  		case ABOVE:
  			type = 'A' << 8 | type & 0xff;
***************
*** 42,48
  			type = 'F';
  			break;
  		case ABOVE:
! 			type = 'A';
  			break;
  		case BELOW:
  			type = 'B';

----- 43,49 -----
  			type = 'F' | type & 0xff00;
  			break;
  		case ABOVE:
! 			type = 'A' << 8 | type & 0xff;
  			break;
  		case BELOW:
  			type = 'B' << 8 | type & 0xff;
***************
*** 45,51
  			type = 'A';
  			break;
  		case BELOW:
! 			type = 'B';
  			break;
  		}
  	dprintf("T %c %s\n", type, s);

----- 46,52 -----
  			type = 'A' << 8 | type & 0xff;
  			break;
  		case BELOW:
! 			type = 'B' << 8 | type & 0xff;
  			break;
  		}
  	dprintf("T %c %s\n", type, s);