diff options
author | wkj <devnull@localhost> | 2004-05-16 07:56:41 +0000 |
---|---|---|
committer | wkj <devnull@localhost> | 2004-05-16 07:56:41 +0000 |
commit | 5f1cf8e6fb130fd48d6f016d13baf5408b3181f8 (patch) | |
tree | 7f77f458df8c8b34db139fb4551df602ab6286be /src/cmd/pic | |
parent | c5561c23cf394806cbf6d70a96f2dc0253f93745 (diff) | |
download | plan9port-5f1cf8e6fb130fd48d6f016d13baf5408b3181f8.tar.gz plan9port-5f1cf8e6fb130fd48d6f016d13baf5408b3181f8.tar.bz2 plan9port-5f1cf8e6fb130fd48d6f016d13baf5408b3181f8.zip |
Checkpoint: pull in mpm; merge pic from Taj's version of the world
Diffstat (limited to 'src/cmd/pic')
-rw-r--r-- | src/cmd/pic/arcgen.c | 13 | ||||
-rw-r--r-- | src/cmd/pic/circgen.c | 2 | ||||
-rw-r--r-- | src/cmd/pic/input.c | 21 | ||||
-rw-r--r-- | src/cmd/pic/main.c | 43 | ||||
-rw-r--r-- | src/cmd/pic/misc.c | 13 | ||||
-rw-r--r-- | src/cmd/pic/picl.lx | 2 | ||||
-rw-r--r-- | src/cmd/pic/print.c | 4 | ||||
-rw-r--r-- | src/cmd/pic/symtab.c | 2 |
8 files changed, 61 insertions, 39 deletions
diff --git a/src/cmd/pic/arcgen.c b/src/cmd/pic/arcgen.c index d1b64224..bec41e47 100644 --- a/src/cmd/pic/arcgen.c +++ b/src/cmd/pic/arcgen.c @@ -11,17 +11,19 @@ obj *arcgen(int type) /* handles circular and (eventually) elliptical arcs */ static double prevw = HT10; static double prevh = HT5; static double prevrad = HT2; - static int dtox[2][4] ={ 1, -1, -1, 1, 1, 1, -1, -1 }; - static int dtoy[2][4] ={ 1, 1, -1, -1, -1, 1, 1, -1 }; - static int dctrx[2][4] ={ 0, -1, 0, 1, 0, 1, 0, -1 }; - static int dctry[2][4] ={ 1, 0, -1, 0, -1, 0, 1, 0 }; - static int nexthv[2][4] ={ U_DIR, L_DIR, D_DIR, R_DIR, D_DIR, R_DIR, U_DIR, L_DIR }; + static int dtox[2][4] ={ { 1, -1, -1, 1}, {1, 1, -1, -1} }; + static int dtoy[2][4] ={ {1, 1, -1, -1}, {-1, 1, 1, -1} }; + static int dctrx[2][4] ={ {0, -1, 0, 1}, {0, 1, 0, -1} }; + static int dctry[2][4] ={ {1, 0, -1, 0}, {-1, 0, 1, 0} }; + static int nexthv[2][4] ={ {U_DIR, L_DIR, D_DIR, R_DIR}, {D_DIR, R_DIR, U_DIR, L_DIR} }; double dx2, dy2, ht, phi, r, d; int i, head, to, at, cw, invis, ddtype, battr; obj *p, *ppos; double fromx, fromy, tox, toy, fillval = 0; Attr *ap; + tox=toy=0.0; /* Botch? (gcc) */ + prevrad = getfval("arcrad"); prevh = getfval("arrowht"); prevw = getfval("arrowwid"); @@ -210,6 +212,7 @@ void arc_extreme(double x0, double y0, double x1, double y1, double xc, double y extreme(xmax, ymax); } +int quadrant(double x, double y) { if ( x>=0.0 && y> 0.0) return(1); diff --git a/src/cmd/pic/circgen.c b/src/cmd/pic/circgen.c index f40bae9a..6b1f1548 100644 --- a/src/cmd/pic/circgen.c +++ b/src/cmd/pic/circgen.c @@ -12,6 +12,8 @@ obj *circgen(int type) obj *p, *ppos; Attr *ap; + r = r2 = 0.0; /* Botch? (gcc) */ + battr = at = 0; with = xwith = ywith = fillval = ddval = 0; t = (type == CIRCLE) ? 0 : 1; diff --git a/src/cmd/pic/input.c b/src/cmd/pic/input.c index 875b1868..bef0c42b 100644 --- a/src/cmd/pic/input.c +++ b/src/cmd/pic/input.c @@ -26,7 +26,7 @@ void pushsrc(int type, char *ptr) /* new input source */ srcp->type = type; srcp->sp = ptr; if (dbg > 1) { - printf("\n%3d ", srcp - src); + printf("\n%3d ", (int) (srcp - src)); switch (srcp->type) { case File: printf("push file %s\n", ((Infile *)ptr)->fname); @@ -57,7 +57,7 @@ void popsrc(void) /* restore an old one */ if (srcp <= src) ERROR "too many inputs popped" FATAL; if (dbg > 1) { - printf("%3d ", srcp - src); + printf("%3d ", (int) (srcp - src)); switch (srcp->type) { case File: printf("pop file\n"); @@ -142,6 +142,7 @@ char *delimstr(char *s) /* get body of X ... X */ return tostring(buf); } +int baldelim(int c, char *s) /* replace c by balancing entry in s */ { for ( ; *s; s += 2) @@ -187,11 +188,12 @@ void dodef(struct symtab *stp) /* collect args and switch input to defn */ ap->argstk[i] = ""; if (dbg) for (i = 0; i < argcnt; i++) - printf("arg %d.%d = <%s>\n", ap-args, i+1, ap->argstk[i]); + printf("arg %d.%d = <%s>\n", (int) (ap-args), i+1, ap->argstk[i]); argfp = ap; pushsrc(Macro, stp->s_val.p); } +int getarg(char *p) /* pick up single argument, store in p, return length */ { int n, c, npar; @@ -232,6 +234,7 @@ extern int thru; extern struct symtab *thrudef; extern char *untilstr; +int input(void) { register int c; @@ -248,10 +251,13 @@ input(void) return *ep++ = c; } +int nextchar(void) { register int c; + c = 0; /* Botch: gcc */ + loop: switch (srcp->type) { case Free: /* free string */ @@ -289,9 +295,9 @@ nextchar(void) ERROR "argfp underflow" FATAL; popsrc(); goto loop; - } else if (c == '$' && isdigit(*srcp->sp)) { + } else if (c == '$' && isdigit((unsigned char) *srcp->sp)) { int n = 0; - while (isdigit(*srcp->sp)) + while (isdigit((unsigned char) *srcp->sp)) n = 10 * n + *srcp->sp++ - '0'; if (n > 0 && n <= MAXARGS) pushsrc(String, argfp->argstk[n-1]); @@ -380,7 +386,7 @@ void do_thru(void) /* read one line, make into a macro expansion */ ap->argstk[i] = ""; if (dbg) for (i = 0; i < argcnt; i++) - printf("arg %d.%d = <%s>\n", ap-args, i+1, ap->argstk[i]); + printf("arg %d.%d = <%s>\n", (int) (ap-args), i+1, ap->argstk[i]); if (strcmp(ap->argstk[0], ".PE") == 0) { thru = 0; thrudef = 0; @@ -400,6 +406,7 @@ void do_thru(void) /* read one line, make into a macro expansion */ pushsrc(Macro, thrudef->s_val.p); } +int unput(int c) { if (++pb >= pbuf + sizeof pbuf) @@ -580,7 +587,7 @@ void shell_init(void) /* set up to interpret a shell command */ void shell_text(char *s) /* add string to command being collected */ { - while (*shellp++ = *s++) + while ((*shellp++ = *s++)) ; shellp--; } diff --git a/src/cmd/pic/main.c b/src/cmd/pic/main.c index ab996650..1c7f5f65 100644 --- a/src/cmd/pic/main.c +++ b/src/cmd/pic/main.c @@ -47,6 +47,7 @@ void getdata(void), setdefaults(void); void setfval(char *, double); int getpid(void); +int main(int argc, char *argv[]) { char buf[20]; @@ -120,27 +121,27 @@ static struct { double val; short scalable; /* 1 => adjust when "scale" changes */ } defaults[] ={ - "scale", SCALE, 1, - "lineht", HT, 1, - "linewid", HT, 1, - "moveht", HT, 1, - "movewid", HT, 1, - "dashwid", HT10, 1, - "boxht", HT, 1, - "boxwid", WID, 1, - "circlerad", HT2, 1, - "arcrad", HT2, 1, - "ellipseht", HT, 1, - "ellipsewid", WID, 1, - "arrowht", HT5, 1, - "arrowwid", HT10, 1, - "arrowhead", 2, 0, /* arrowhead style */ - "textht", 0.0, 1, /* 6 lines/inch is also a useful value */ - "textwid", 0.0, 1, - "maxpsht", MAXHT, 0, - "maxpswid", MAXWID, 0, - "fillval", 0.7, 0, /* gray value for filling boxes */ - NULL, 0, 0 + { "scale", SCALE, 1, }, + { "lineht", HT, 1, }, + { "linewid", HT, 1, }, + { "moveht", HT, 1, }, + { "movewid", HT, 1, }, + { "dashwid", HT10, 1, }, + { "boxht", HT, 1, }, + { "boxwid", WID, 1, }, + { "circlerad", HT2, 1, }, + { "arcrad", HT2, 1, }, + { "ellipseht", HT, 1, }, + { "ellipsewid", WID, 1, }, + { "arrowht", HT5, 1, }, + { "arrowwid", HT10, 1, }, + { "arrowhead", 2, 0, }, /* arrowhead style */ + { "textht", 0.0, 1, }, /* 6 lines/inch is also a useful value */ + { "textwid", 0.0, 1, }, + { "maxpsht", MAXHT, 0, }, + { "maxpswid", MAXWID, 0, }, + { "fillval", 0.7, 0, }, /* gray value for filling boxes */ + { NULL, 0, 0 } }; void setdefaults(void) /* set default sizes for variables like boxht */ diff --git a/src/cmd/pic/misc.c b/src/cmd/pic/misc.c index 0a33c672..1ada1c1c 100644 --- a/src/cmd/pic/misc.c +++ b/src/cmd/pic/misc.c @@ -9,6 +9,7 @@ int whatpos(obj *p, int corner, double *px, double *py); void makeattr(int type, int sub, YYSTYPE val); YYSTYPE getblk(obj *, char *); +int setdir(int n) /* set direction (hvmode) from LEFT, RIGHT, etc. */ { switch (n) { @@ -20,6 +21,7 @@ setdir(int n) /* set direction (hvmode) from LEFT, RIGHT, etc. */ return(hvmode); } +int curdir(void) /* convert current dir (hvmode) to RIGHT, LEFT, etc. */ { switch (hvmode) { @@ -32,7 +34,8 @@ curdir(void) /* convert current dir (hvmode) to RIGHT, LEFT, etc. */ return 0; } -double getcomp(obj *p, int t) /* return component of a position */ +double +getcomp(obj *p, int t) /* return component of a position */ { switch (t) { case DOTX: @@ -207,7 +210,9 @@ int whatpos(obj *p, int corner, double *px, double *py) /* what is the position { double x, y, x1, y1; - dprintf("whatpos %o %d %d\n", p, p->o_type, corner); + x1 = y1 = 0.0; /* Botch? (gcc) */ + + dprintf("whatpos %p %d %d\n", p, p->o_type, corner); x = p->o_x; y = p->o_y; if (p->o_type != PLACE && p->o_type != MOVE) { @@ -320,7 +325,7 @@ obj *getlast(int n, int t) /* find n-th previous occurrence of type t */ dprintf("got a last of x,y= %g,%g\n", p->o_x, p->o_y); return(p); } - ERROR "there is no %dth last", n FATAL; + ERROR "there is no %dth last", n WARNING; return(NULL); } @@ -343,7 +348,7 @@ obj *getfirst(int n, int t) /* find n-th occurrence of type t */ dprintf("got a first of x,y= %g,%g\n", p->o_x, p->o_y); return(p); } - ERROR "there is no %dth ", n FATAL; + ERROR "there is no %dth ", n WARNING; return(NULL); } diff --git a/src/cmd/pic/picl.lx b/src/cmd/pic/picl.lx index dbe2a3d5..f5a9c155 100644 --- a/src/cmd/pic/picl.lx +++ b/src/cmd/pic/picl.lx @@ -133,7 +133,7 @@ WS [ \t] <A>ccw { yylval.i = CCW; return(ATTR); } <A>invis(ible)? { yylval.i = INVIS; return(ATTR); } <A>noedge { yylval.i = INVIS; return ATTR; } -<A>fill return(yylval.i = FILL); +<A>fill { yylval.i = FILL; return ATTR; } <A>solid ; <A>dot(ted)? return(yylval.i = DOT); <A>dash(ed)? return(yylval.i = DASH); diff --git a/src/cmd/pic/print.c b/src/cmd/pic/print.c index ad21e0d7..6cf5103d 100644 --- a/src/cmd/pic/print.c +++ b/src/cmd/pic/print.c @@ -25,6 +25,8 @@ void print(void) int fill, vis, invis; double x0, y0, x1, y1, ox, oy, dx, dy, ndx, ndy; + x1 = y1 = 0.0; /* Botch? (gcc) */ + for (i = 0; i < nobj; i++) { p = objlist[i]; ox = p->o_x; @@ -180,6 +182,8 @@ void dotline(double x0, double y0, double x1, double y1, int ddtype, double ddva int i, numdots; double a, b, dx, dy; + b = 0.0; /* Botch? (gcc) */ + if (ddval == 0) ddval = prevval; prevval = ddval; diff --git a/src/cmd/pic/symtab.c b/src/cmd/pic/symtab.c index 879075c6..059d3be7 100644 --- a/src/cmd/pic/symtab.c +++ b/src/cmd/pic/symtab.c @@ -12,7 +12,7 @@ YYSTYPE getvar(char *s) /* return value of variable s (usually pointer) */ p = lookup(s); if (p == NULL) { - if (islower(s[0])) + if (islower((int) s[0])) ERROR "no such variable as %s", s WARNING; else ERROR "no such place as %s", s WARNING; |