int nnum = 0; /* number of saved numbers */
double num[MAXNUM];
int just; /* current justification mode (RJUST, etc.) */
int sizeop; /* current optional operator for size change */
double sizexpr; /* current size change expression */
void savenum(int n, double f) /* save f in num[n] */
{
num[n] = f;
nnum = n+1;
if (nnum >= MAXNUM)
ERROR "too many numbers" WARNING;
}
p = malloc(strlen(s)+1);
if (p == NULL)
ERROR "out of space in tostring on %s", s FATAL;
strcpy(p, s);
return(p);
}
void range(Point pt) /* update the range for point pt */
{
Obj *p = pt.obj;
if (!(p->coord & XFLAG)) {
if (pt.x > p->pt1.x)
p->pt1.x = pt.x;
if (pt.x < p->pt.x)
p->pt.x = pt.x;
}
if (!(p->coord & YFLAG)) {
if (pt.y > p->pt1.y)
p->pt1.y = pt.y;
if (pt.y < p->pt.y)
p->pt.y = pt.y;
}
}
void halfrange(Obj *p, int side, double val) /* record max and min for one direction */
{
if (!(p->coord&XFLAG) && (side == LEFT || side == RIGHT)) {
if (val < p->pt.y)
p->pt.y = val;
if (val > p->pt1.y)
p->pt1.y = val;
} else if (!(p->coord&YFLAG) && (side == TOP || side == BOT)) {
if (val < p->pt.x)
p->pt.x = val;
if (val > p->pt1.x)
p->pt1.x = val;
}
}
Obj *lookup(char *s, int inst) /* find s in objlist, install if inst */
{
Obj *p;
int found = 0;
for (p = objlist; p; p = p->next){
if (strcmp(s, p->name) == 0) {
found = 1;
break;
}
}
if (p == NULL && inst != 0) {
p = (Obj *) calloc(1, sizeof(Obj));
if (p == NULL)
ERROR "out of space in lookup" FATAL;
p->name = tostring(s);
p->type = NAME;
p->pt = ptmax;
p->pt1 = ptmin;
p->fval = 0.0;
p->next = objlist;
objlist = p;
}
dprintf("lookup(%s,%d) = %d\n", s, inst, found);
return p;
}
double getvar(Obj *p) /* return value of variable */
{
return p->fval;
}
double setvar(Obj *p, double f) /* set value of variable to f */
{
if (strcmp(p->name, "pointsize") == 0) { /* kludge */
pointsize = f;
ps_set = 1;
}
p->type = VARNAME;
return p->fval = f;
}
Point makepoint(Obj *s, double x, double y) /* make a Point */
{
Point p;