7 int nnum
= 0; /* number of saved numbers */
10 int just
; /* current justification mode (RJUST, etc.) */
11 int sizeop
; /* current optional operator for size change */
12 double sizexpr
; /* current size change expression */
14 void savenum(int n
, double f
) /* save f in num[n] */
19 ERROR
"too many numbers" WARNING
;
27 void setsize(int op
, double expr
)
33 char *tostring(char *s
)
37 p
= malloc(strlen(s
)+1);
39 ERROR
"out of space in tostring on %s", s FATAL
;
44 void range(Point pt
) /* update the range for point pt */
48 if (!(p
->coord
& XFLAG
)) {
54 if (!(p
->coord
& YFLAG
)) {
62 void halfrange(Obj
*p
, int side
, double val
) /* record max and min for one direction */
64 if (!(p
->coord
&XFLAG
) && (side
== LEFT
|| side
== RIGHT
)) {
69 } else if (!(p
->coord
&YFLAG
) && (side
== TOP
|| side
== BOT
)) {
78 Obj
*lookup(char *s
, int inst
) /* find s in objlist, install if inst */
83 for (p
= objlist
; p
; p
= p
->next
){
84 if (strcmp(s
, p
->name
) == 0) {
89 if (p
== NULL
&& inst
!= 0) {
90 p
= (Obj
*) calloc(1, sizeof(Obj
));
92 ERROR
"out of space in lookup" FATAL
;
93 p
->name
= tostring(s
);
101 dprintf("lookup(%s,%d) = %d\n", s
, inst
, found
);
105 double getvar(Obj
*p
) /* return value of variable */
110 double setvar(Obj
*p
, double f
) /* set value of variable to f */
112 if (strcmp(p
->name
, "pointsize") == 0) { /* kludge */
120 Point
makepoint(Obj
*s
, double x
, double y
) /* make a Point */
124 dprintf("makepoint: %s, %g,%g\n", s
->name
, x
, y
);
131 Attr
*makefattr(int type
, double fval
) /* set double in attribute */
133 return makeattr(type
, fval
, (char *) 0, 0, 0);
136 Attr
*makesattr(char *s
) /* make an Attr cell containing s */
138 Attr
*ap
= makeattr(STRING
, sizexpr
, s
, just
, sizeop
);
144 Attr
*makeattr(int type
, double fval
, char *sval
, int just
, int op
)
148 a
= (Attr
*) malloc(sizeof(Attr
));
150 ERROR
"out of space in makeattr" FATAL
;
160 Attr
*addattr(Attr
*a1
, Attr
*ap
) /* add attr ap to end of list a1 */
168 for (p
= a1
; p
->next
; p
= p
->next
)
174 void freeattr(Attr
*ap
) /* free an attribute list */
179 p
= ap
->next
; /* save next */
187 char *slprint(Attr
*stringlist
) /* print strings from stringlist */
189 int ntext
, n
, last_op
, last_just
;
191 static char buf
[1000];
195 last_op
= last_just
= 0;
197 for (ntext
= 0, ap
= stringlist
; ap
!= NULL
; ap
= ap
->next
)
199 sprintf(buf
, "box invis wid 0 ht %d*textht", ntext
);
201 for (ap
= stringlist
; ap
!= NULL
; ap
= ap
->next
) {
202 if (ap
->op
== 0) { /* propagate last value */
204 ap
->fval
= last_fval
;
207 last_fval
= ap
->fval
;
209 sprintf(buf
+n
, " \"%s\"", ps_set
|| ap
->op
? sizeit(ap
) : ap
->sval
);
211 last_just
= ap
->just
;
213 strcat(buf
+n
, juststr(last_just
));
216 return buf
; /* watch it: static */
219 char *juststr(int j
) /* convert RJUST, etc., into string */
225 strcat(buf
, " rjust");
227 strcat(buf
, " ljust");
229 strcat(buf
, " above");
231 strcat(buf
, " below");
232 return buf
; /* watch it: static */
235 char *sprntf(char *s
, Attr
*ap
) /* sprintf(s, attrlist ap) */
241 for (n
= 0, p
= ap
; p
; p
= p
->next
)
247 sprintf(buf
, s
, ap
->fval
);
250 sprintf(buf
, s
, ap
->fval
, ap
->next
->fval
);
253 sprintf(buf
, s
, ap
->fval
, ap
->next
->fval
, ap
->next
->next
->fval
);
256 ERROR
"too many expressions in sprintf" WARNING
;
258 sprintf(buf
, s
, ap
->fval
, ap
->next
->fval
, ap
->next
->next
->fval
, ap
->next
->next
->next
->fval
);
262 return tostring(buf
);