Checkpoint: pull in mpm; merge pic from Taj's version of the world

This commit is contained in:
wkj 2004-05-16 07:56:41 +00:00
parent c5561c23cf
commit 5f1cf8e6fb
21 changed files with 3878 additions and 39 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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--;
}

View file

@ -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 */

View file

@ -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);
}

View file

@ -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);

View file

@ -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;

View file

@ -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;