Edition 8 Version of pic (July 1985).
authorJaap Akkerhuis <jaap@ucbvax.Berkeley.EDU>
Wed, 31 Jul 1985 06:06:32 +0000 (22:06 -0800)
committerJaap Akkerhuis <jaap@ucbvax.Berkeley.EDU>
Wed, 31 Jul 1985 06:06:32 +0000 (22:06 -0800)
Local hacks from jaap.

SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/arcgen.c 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/blockgen.c 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/boxgen.c 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/circgen.c 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/for.c 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/input.c 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/linegen.c 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/main.c 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/misc.c 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/movegen.c 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/pic.h 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/picy.y 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/pltroff.c 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/print.c 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/symtab.c 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/textgen.c 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/PS-PEmacros 3.1
SCCS-vsn: local/ditroff/ditroff.okeeffe/pic/UNDOC 3.1

17 files changed:
usr/src/local/ditroff/ditroff.okeeffe/pic/UNDOC
usr/src/local/ditroff/ditroff.okeeffe/pic/arcgen.c
usr/src/local/ditroff/ditroff.okeeffe/pic/blockgen.c
usr/src/local/ditroff/ditroff.okeeffe/pic/boxgen.c
usr/src/local/ditroff/ditroff.okeeffe/pic/circgen.c
usr/src/local/ditroff/ditroff.okeeffe/pic/for.c
usr/src/local/ditroff/ditroff.okeeffe/pic/input.c
usr/src/local/ditroff/ditroff.okeeffe/pic/linegen.c
usr/src/local/ditroff/ditroff.okeeffe/pic/main.c
usr/src/local/ditroff/ditroff.okeeffe/pic/misc.c
usr/src/local/ditroff/ditroff.okeeffe/pic/movegen.c
usr/src/local/ditroff/ditroff.okeeffe/pic/pic.h
usr/src/local/ditroff/ditroff.okeeffe/pic/picy.y
usr/src/local/ditroff/ditroff.okeeffe/pic/pltroff.c
usr/src/local/ditroff/ditroff.okeeffe/pic/print.c
usr/src/local/ditroff/ditroff.okeeffe/pic/symtab.c
usr/src/local/ditroff/ditroff.okeeffe/pic/textgen.c

index 2213b17..9212153 100644 (file)
@@ -1,3 +1,13 @@
+May 85:
+
+"solid" is now a valid (though uninteresting) attribute.
+
+Mar 85:
+
+Limited amount of point arithmetic:
+       point +/- point
+works
+
 Dec, 1984:
 
 reset varlist
 Dec, 1984:
 
 reset varlist
index 3d02092..bfcf4ad 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)arcgen.c   2.1 (CWI) 85/07/23";
+static char sccsid[] = "@(#)arcgen.c   3.1 (CWI) 85/07/30";
 #endif lint
 #endif lint
+
 #include       <stdio.h>
 #include       <math.h>
 #include       "pic.h"
 #include       <stdio.h>
 #include       <math.h>
 #include       "pic.h"
index 6d421b6..925e226 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)blockgen.c 2.1 (CWI) 85/07/23";
+static char sccsid[] = "@(#)blockgen.c 3.1 (CWI) 85/07/30";
 #endif lint
 #endif lint
+
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"
@@ -117,6 +118,7 @@ obj *blockgen(p, type, q)   /* handles [...] */
                        with = PLACE;
                        break;
                case AT:
                        with = PLACE;
                        break;
                case AT:
+               case FROM:
                        ppos = ap->a_val.o;
                        curx = ppos->o_x;
                        cury = ppos->o_y;
                        ppos = ap->a_val.o;
                        curx = ppos->o_x;
                        cury = ppos->o_y;
index e58b3cd..001576a 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)boxgen.c   2.1 (CWI) 85/07/23";
+static char sccsid[] = "@(#)boxgen.c   3.1 (CWI) 85/07/30";
 #endif lint
 #endif lint
+
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"
index 4a0f45a..65f56e5 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)circgen.c  2.1 (CWI) 85/07/23";
+static char sccsid[] = "@(#)circgen.c  3.1 (CWI) 85/07/30";
 #endif lint
 #endif lint
+
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"
index 2217ebd..6ccf3c1 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)for.c      2.1 (CWI) 85/07/23";
+static char sccsid[] = "@(#)for.c      3.1 (CWI) 85/07/30";
 #endif lint
 #endif lint
+
 #include <stdio.h>
 #include "pic.h"
 #include "y.tab.h"
 #include <stdio.h>
 #include "pic.h"
 #include "y.tab.h"
index cbaa0ce..efba815 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)input.c    2.1 (CWI) 85/07/23";
+static char sccsid[] = "@(#)input.c    3.1 (CWI) 85/07/30";
 #endif lint
 #endif lint
+
 #include <stdio.h>
 #include <ctype.h>
 #include <errno.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <errno.h>
index 87b35ad..ba0bb1e 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)linegen.c  2.1 (CWI) 85/07/23";
+static char sccsid[] = "@(#)linegen.c  3.1 (CWI) 85/07/30";
 #endif lint
 #endif lint
+
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"
@@ -149,17 +150,19 @@ obj *linegen(type)
        if (chop) {
                if (chop == 1 && chop1 == 0)    /* just said "chop", so use default */
                        chop1 = chop2 = getfval("circlerad");
        if (chop) {
                if (chop == 1 && chop1 == 0)    /* just said "chop", so use default */
                        chop1 = chop2 = getfval("circlerad");
-               theta = atan2((float) defy, (float) defx);
+               theta = atan2(dy[0], dx[0]);
                x0 = chop1 * cos(theta);
                y0 = chop1 * sin(theta);
                curx += x0;
                cury += y0;
                x0 = chop1 * cos(theta);
                y0 = chop1 * sin(theta);
                curx += x0;
                cury += y0;
+               dx[0] -= x0;
+               dy[0] -= y0;
+
+               theta = atan2(dy[ndxy-1], dx[ndxy-1]);
                x1 = chop2 * cos(theta);
                y1 = chop2 * sin(theta);
                nx -= x1;
                ny -= y1;
                x1 = chop2 * cos(theta);
                y1 = chop2 * sin(theta);
                nx -= x1;
                ny -= y1;
-               dx[0] -= x0;
-               dy[0] -= y0;
                dx[ndxy-1] -= x1;
                dy[ndxy-1] -= y1;
                dprintf("chopping %g %g %g %g; cur=%g,%g end=%g,%g\n",
                dx[ndxy-1] -= x1;
                dy[ndxy-1] -= y1;
                dprintf("chopping %g %g %g %g; cur=%g,%g end=%g,%g\n",
index b1833ad..5abe922 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)main.c     2.1 (CWI) 85/07/23";
+static char sccsid[] = "@(#)main.c     3.1 (CWI) 85/07/30";
 #endif lint
 #endif lint
+
 #include       <stdio.h>
 #include       <signal.h>
 #include       "pic.h"
 #include       <stdio.h>
 #include       <signal.h>
 #include       "pic.h"
@@ -10,7 +11,7 @@ obj   **objlist = 0;  /* store the elements here */
 int    nobjlist = 0;           /* size of objlist array */
 int    nobj    = 0;
 
 int    nobjlist = 0;           /* size of objlist array */
 int    nobj    = 0;
 
-Attr   *attr;  /* attributes stored here as collected */
+Attr   *attr;  /*;attributes stored here as collected */
 int    nattrlist = 0;
 int    nattr   = 0;    /* number of entries in attr_list */
 
 int    nattrlist = 0;
 int    nattr   = 0;    /* number of entries in attr_list */
 
index e1f8646..0ed6a88 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)misc.c     2.1 (CWI) 85/07/23";
+static char sccsid[] = "@(#)misc.c     3.1 (CWI) 85/07/30";
 #endif lint
 #endif lint
+
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"
@@ -40,6 +41,7 @@ float getcomp(p, t)   /* return component of a position */
                switch (p->o_type) {
                case BOX:
                case BLOCK:
                switch (p->o_type) {
                case BOX:
                case BLOCK:
+               case TEXT:
                        return p->o_val[0];
                case CIRCLE:
                case ELLIPSE:
                        return p->o_val[0];
                case CIRCLE:
                case ELLIPSE:
@@ -52,6 +54,7 @@ float getcomp(p, t)   /* return component of a position */
                switch (p->o_type) {
                case BOX:
                case BLOCK:
                switch (p->o_type) {
                case BOX:
                case BLOCK:
+               case TEXT:
                        return p->o_val[1];
                case CIRCLE:
                case ELLIPSE:
                        return p->o_val[1];
                case CIRCLE:
                case ELLIPSE:
@@ -231,6 +234,7 @@ whatpos(p, corner, px, py)  /* what is the position (no side effect) */
                break;
        case BOX:
        case BLOCK:
                break;
        case BOX:
        case BLOCK:
+       case TEXT:
                switch (corner) {
                case NORTH:     y += y1 / 2; break;
                case SOUTH:     y -= y1 / 2; break;
                switch (corner) {
                case NORTH:     y += y1 / 2; break;
                case SOUTH:     y -= y1 / 2; break;
@@ -357,24 +361,45 @@ obj *getfirst(n, t)       /* find n-th occurrence of type t */
        return(NULL);
 }
 
        return(NULL);
 }
 
+float getblkvar(p, s)  /* find variable s2 in block p */
+       obj *p;
+       char *s;
+{
+       YYSTYPE y, getblk();
+
+       y = getblk(p, s);
+       return y.f;
+}
+
 obj *getblock(p, s)    /* find variable s in block p */
        obj *p;
        char *s;
 {
 obj *getblock(p, s)    /* find variable s in block p */
        obj *p;
        char *s;
 {
+       YYSTYPE y, getblk();
+
+       y = getblk(p, s);
+       return y.o;
+}
+
+YYSTYPE getblk(p, s)   /* find union type for s in p */
+       obj *p;
+       char *s;
+{
+       static YYSTYPE bug;
        struct symtab *stp;
 
        if (p->o_type != BLOCK) {
                yyerror(".%s is not in that block", s);
        struct symtab *stp;
 
        if (p->o_type != BLOCK) {
                yyerror(".%s is not in that block", s);
-               return(NULL);
+               return(bug);
        }
        for (stp = p->o_symtab; stp != NULL; stp = stp->s_next)
                if (strcmp(s, stp->s_name) == 0) {
        }
        for (stp = p->o_symtab; stp != NULL; stp = stp->s_next)
                if (strcmp(s, stp->s_name) == 0) {
-                       dprintf("getblock found x,y= %g,%g\n",
+                       dprintf("getblk found x,y= %g,%g\n",
                                (stp->s_val.o)->o_x, (stp->s_val.o)->o_y);
                                (stp->s_val.o)->o_x, (stp->s_val.o)->o_y);
-                       return(stp->s_val.o);
+                       return(stp->s_val);
                }
        yyerror("there is no .%s in that []", s);
                }
        yyerror("there is no .%s in that []", s);
-       return(NULL);
+       return(bug);
 }
 
 obj *fixpos(p, x, y)
 }
 
 obj *fixpos(p, x, y)
index aa56d0e..f46fc46 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)movegen.c  2.1 (CWI) 85/07/23";
+static char sccsid[] = "@(#)movegen.c  3.1 (CWI) 85/07/30";
 #endif lint
 #endif lint
+
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"
index 29a6eee..e5b7d25 100644 (file)
@@ -1,4 +1,7 @@
 #define        dprintf if(dbg)printf
 #define        dprintf if(dbg)printf
+#ifndef PI
+#define        PI      3.141592654
+#endif
 
 #define        DEFAULT 0
 
 
 #define        DEFAULT 0
 
@@ -7,9 +10,6 @@
 #define        HEAD12  (HEAD1+HEAD2)
 #define        INVIS   4
 #define        CW_ARC  8       /* clockwise arc */
 #define        HEAD12  (HEAD1+HEAD2)
 #define        INVIS   4
 #define        CW_ARC  8       /* clockwise arc */
-#ifndef PI
-#define        PI      3.141592654
-#endif
 #define        DOTBIT  16
 #define        DASHBIT 32
 
 #define        DOTBIT  16
 #define        DASHBIT 32
 
@@ -137,7 +137,7 @@ extern      float   curx, cury;
 extern int     hvmode;
 extern int     codegen;
 extern char    *malloc(), *realloc(), *tostring(), *grow();
 extern int     hvmode;
 extern int     codegen;
 extern char    *malloc(), *realloc(), *tostring(), *grow();
-extern float   getfval(), getcomp();
+extern float   getfval(), getcomp(), getblkvar();
 extern YYSTYPE getvar();
 extern struct symtab *lookup(), *makevar();
 extern char    *ifstat(), *delimstr(), *sprintgen();
 extern YYSTYPE getvar();
 extern struct symtab *lookup(), *makevar();
 extern char    *ifstat(), *delimstr(), *sprintgen();
index 52ed143..d10ef8c 100644 (file)
@@ -223,6 +223,8 @@ position:           /* absolute, not relative */
        | position '-' expr ',' expr            { $$ = fixpos($1, -$3, -$5); }
        | position '+' '(' expr ',' expr ')'    { $$ = fixpos($1, $4, $6); }
        | position '-' '(' expr ',' expr ')'    { $$ = fixpos($1, -$4, -$6); }
        | position '-' expr ',' expr            { $$ = fixpos($1, -$3, -$5); }
        | position '+' '(' expr ',' expr ')'    { $$ = fixpos($1, $4, $6); }
        | position '-' '(' expr ',' expr ')'    { $$ = fixpos($1, -$4, -$6); }
+       | position '+' place                    { $$ = addpos($1, $3); }
+       | position '-' place                    { $$ = subpos($1, $3); }
        | '(' place ',' place ')'       { $$ = makepos(getcomp($2,DOTX), getcomp($4,DOTY)); }
        | expr LT position ',' position GT      { $$ = makebetween($1, $3, $5); }
        | expr BETWEEN position AND position    { $$ = makebetween($1, $3, $5); }
        | '(' place ',' place ')'       { $$ = makepos(getcomp($2,DOTX), getcomp($4,DOTY)); }
        | expr LT position ',' position GT      { $$ = makebetween($1, $3, $5); }
        | expr BETWEEN position AND position    { $$ = makebetween($1, $3, $5); }
@@ -278,7 +280,7 @@ expr:
                                        yyerror("division by 0"); $3 = 1; }
                                  $$ = $1 / $3; }
        | expr '%' expr         { if ((long)$3 == 0) {
                                        yyerror("division by 0"); $3 = 1; }
                                  $$ = $1 / $3; }
        | expr '%' expr         { if ((long)$3 == 0) {
-                                       yyerror("mod does division by 0"); $3 = 1; }
+                                       yyerror("mod division by 0"); $3 = 1; }
                                  $$ = (long)$1 % (long)$3; }
        | '-' expr %prec UMINUS { $$ = -$2; }
        | '(' expr ')'          { $$ = $2; }
                                  $$ = (long)$1 % (long)$3; }
        | '-' expr %prec UMINUS { $$ = -$2; }
        | '(' expr ')'          { $$ = $2; }
@@ -287,6 +289,9 @@ expr:
        | place DOTHT           { $$ = getcomp($1, $2); }
        | place DOTWID          { $$ = getcomp($1, $2); }
        | place DOTRAD          { $$ = getcomp($1, $2); }
        | place DOTHT           { $$ = getcomp($1, $2); }
        | place DOTWID          { $$ = getcomp($1, $2); }
        | place DOTRAD          { $$ = getcomp($1, $2); }
+       | PLACENAME '.' VARNAME { y = getvar($1); $$ = getblkvar(y.o, $3); }
+       | last BLOCK '.' VARNAME { $$ = getblkvar(getlast($1,$2), $4); }
+       | NTH BLOCK '.' VARNAME { $$ = getblkvar(getfirst($1,$2), $4); }
        | expr GT expr          { $$ = $1 > $3; }
        | expr LT expr          { $$ = $1 < $3; }
        | expr LE expr          { $$ = $1 <= $3; }
        | expr GT expr          { $$ = $1 > $3; }
        | expr LT expr          { $$ = $1 < $3; }
        | expr LE expr          { $$ = $1 <= $3; }
index 196e7ea..ce1babc 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)pltroff.c  2.1 (CWI) 85/07/23";
+static char sccsid[] = "@(#)pltroff.c  3.1 (CWI) 85/07/30";
 #endif lint
 #endif lint
+
 #include <stdio.h>
 #include <math.h>
 #include "pic.h"
 #include <stdio.h>
 #include <math.h>
 #include "pic.h"
@@ -278,18 +279,28 @@ circle(x, y, r)
        flyback();
 }
 
        flyback();
 }
 
-spline(x, y, n, p)
+spline(x, y, n, p, dashed, ddval)
        float x, y, *p;
        float n;        /* sic */
        float x, y, *p;
        float n;        /* sic */
+       int dashed;
+       float ddval;
 {
        int i;
        float dx, dy;
        float xerr, yerr;
 
 {
        int i;
        float dx, dy;
        float xerr, yerr;
 
+       if (dashed && ddval)
+               printf(".nr 99 %.3fi\n", ddval);
        move(x, y);
        hvflush();
        move(x, y);
        hvflush();
-       printf("\\D'~");
        xerr = yerr = 0.0;
        xerr = yerr = 0.0;
+       if (dashed) {
+               if (ddval)
+                       printf("\\X'Pd \\n(99'\\D'q 0 0");
+               else
+                       printf("\\X'Pd'\\D'q 0 0");
+       } else
+               printf("\\D'~");
        for (i = 0; i < 2 * n; i += 2) {
                dx = xsc(xerr += p[i]);
                xerr -= dx/xscale;
        for (i = 0; i < 2 * n; i += 2) {
                dx = xsc(xerr += p[i]);
                xerr -= dx/xscale;
@@ -297,7 +308,10 @@ spline(x, y, n, p)
                yerr -= dy/yscale;
                printf(" %.3fi %.3fi", dx, -dy);        /* WATCH SIGN */
        }
                yerr -= dy/yscale;
                printf(" %.3fi %.3fi", dx, -dy);        /* WATCH SIGN */
        }
-       printf("'\n");
+       if (dashed)
+               printf(" 0 0'\\X'Ps'\n");
+       else
+               printf("'\n");
        flyback();
 }
 
        flyback();
 }
 
index 7352e95..7a9015e 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)print.c    2.1 (CWI) 85/07/23";
+static char sccsid[] = "@(#)print.c    3.1 (CWI) 85/07/30";
 #endif lint
 #endif lint
+
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"
@@ -91,7 +92,7 @@ print()
                         if (p->o_attr & INVIS)
                                 move(x1, y1);
                        else if (p->o_type == SPLINE)
                         if (p->o_attr & INVIS)
                                 move(x1, y1);
                        else if (p->o_type == SPLINE)
-                               spline(ox, oy, p->o_val[4], &p->o_val[5]);
+                               spline(ox, oy, p->o_val[4], &p->o_val[5], p->o_attr & (DOTBIT|DASHBIT), p->o_ddval);
                        else {
                                dx = ox;
                                dy = oy;
                        else {
                                dx = ox;
                                dy = oy;
index ea76778..e1a8f56 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)symtab.c   2.1 (CWI) 85/07/23";
+static char sccsid[] = "@(#)symtab.c   3.1 (CWI) 85/07/30";
 #endif lint
 #endif lint
+
 #include       <stdio.h>
 #include       <ctype.h>
 #include       "pic.h"
 #include       <stdio.h>
 #include       <ctype.h>
 #include       "pic.h"
index f84d148..17437bb 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)textgen.c  2.1 (CWI) 85/07/23";
+static char sccsid[] = "@(#)textgen.c  3.1 (CWI) 85/07/30";
 #endif lint
 #endif lint
+
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"
 #include       <stdio.h>
 #include       "pic.h"
 #include       "y.tab.h"