4 * (C) 1989 Saeko Hirabauashi & Kouichi Hirabayashi
6 * Absolutely no warranty. Use this software with your own risk.
8 * Permission to use, copy, modify and distribute this software for any
9 * purpose and without fee is hereby granted, provided that the above
10 * copyright and disclaimer notice.
12 * This program was written to fit into 64K+64K memory of the Minix 1.2.
25 p
= (NODE
*) emalloc(sizeof(*p
) - sizeof(p
));
32 node1(type
, arg0
) NODE
*arg0
;
37 p
= (NODE
*) emalloc(sizeof(*p
));
40 p
->n_arg
[0] = (NODE
*) arg0
;
45 node2(type
, arg0
, arg1
) NODE
*arg0
, *arg1
;
50 p
= (NODE
*) emalloc(sizeof(*p
) + sizeof(p
) * 1);
53 p
->n_arg
[0] = (NODE
*) arg0
;
54 p
->n_arg
[1] = (NODE
*) arg1
;
59 node3(type
, arg0
, arg1
, arg2
) NODE
*arg0
, *arg1
, *arg2
;
64 p
= (NODE
*) emalloc(sizeof(*p
) + sizeof(p
) * 2);
67 p
->n_arg
[0] = (NODE
*) arg0
;
68 p
->n_arg
[1] = (NODE
*) arg1
;
69 p
->n_arg
[2] = (NODE
*) arg2
;
74 node4(type
, arg0
, arg1
, arg2
, arg3
) NODE
*arg0
, *arg1
, *arg2
, *arg3
;
79 p
= (NODE
*) emalloc(sizeof(*p
) + sizeof(p
) * 3);
82 p
->n_arg
[0] = (NODE
*) arg0
;
83 p
->n_arg
[1] = (NODE
*) arg1
;
84 p
->n_arg
[2] = (NODE
*) arg2
;
85 p
->n_arg
[3] = (NODE
*) arg3
;
90 mkcell(type
, sval
, fval
) char *sval
; double fval
;
93 char *emalloc(), *strsave();
95 p
= (CELL
*) emalloc(sizeof(*p
));
100 p
->c_sval
= strsave(sval
);
108 CELL tmpcell
[MAXTMP
];
112 mktmp(type
, sval
, fval
) char *sval
; double fval
;
118 for (i
= 0; i
< MAXTMP
; i
++)
119 if (tmpcell
[i
].c_type
== 0) {
120 tmpcell
[i
].c_type
= type
| TMP
;
121 tmpcell
[i
].c_sval
= strsave(sval
);
122 tmpcell
[i
].c_fval
= fval
;
125 error("formula too complex", (char *) 0);
127 return mkcell(type
| TMP
, sval
, fval
);
133 if ((p
!= NULL
) && (p
->c_type
& TMP
)) {
137 p
->c_sval
= (char *)NULL
;
140 if (p
->c_sval
!= NULL
) {