28 |
|
#include "copyright.h" |
29 |
|
|
30 |
|
#include <stdio.h> |
31 |
– |
|
31 |
|
#include <string.h> |
33 |
– |
|
32 |
|
#include <ctype.h> |
33 |
|
|
34 |
+ |
#include "rterror.h" |
35 |
|
#include "calcomp.h" |
36 |
|
|
37 |
|
#ifndef NHASH |
42 |
|
|
43 |
|
#define newnode() (EPNODE *)ecalloc(1, sizeof(EPNODE)) |
44 |
|
|
45 |
< |
static double dvalue(); |
45 |
> |
static double dvalue(char *name, EPNODE *d); |
46 |
|
|
47 |
|
#define MAXCLOCK (1L<<31) /* clock wrap value */ |
48 |
|
|
259 |
|
while (*++cp2 && *cp2 != CNTXMARK) |
260 |
|
; |
261 |
|
cp1 = context; /* copy tail to front */ |
262 |
< |
while (*cp1++ = *cp2++) |
262 |
> |
while ( (*cp1++ = *cp2++) ) |
263 |
|
; |
264 |
|
return(context); |
265 |
|
} |
271 |
|
int lvl |
272 |
|
) |
273 |
|
{ |
274 |
< |
static char nambuf[MAXWORD+1]; |
274 |
> |
static char nambuf[RMAXWORD+1]; |
275 |
|
register char *cp = nambuf, *cpp; |
276 |
|
/* check for explicit local */ |
277 |
|
if (*nam == CNTXMARK) |
283 |
|
return(lvl > 0 ? NULL : nam); |
284 |
|
/* copy name to static buffer */ |
285 |
|
while (*nam) { |
286 |
< |
if (cp >= nambuf+MAXWORD) |
286 |
> |
if (cp >= nambuf+RMAXWORD) |
287 |
|
goto toolong; |
288 |
|
*cp++ = *nam++; |
289 |
|
} |
302 |
|
; |
303 |
|
} |
304 |
|
while (*cpp) { /* copy context to static buffer */ |
305 |
< |
if (cp >= nambuf+MAXWORD) |
305 |
> |
if (cp >= nambuf+RMAXWORD) |
306 |
|
goto toolong; |
307 |
|
*cp++ = *cpp++; |
308 |
|
} |
349 |
|
/* if context is global, clear all */ |
350 |
|
for (i = 0; i < NHASH; i++) |
351 |
|
for (vp = hashtbl[i]; vp != NULL; vp = vp->next) |
352 |
< |
if (incontext(vp->name)) |
352 |
> |
if (incontext(vp->name)) { |
353 |
|
if (lvl >= 2) |
354 |
|
dremove(vp->name); |
355 |
|
else |
356 |
|
dclear(vp->name); |
357 |
+ |
} |
358 |
|
if (lvl >= 1) { |
359 |
|
for (ep = outchan; ep != NULL; ep = ep->sibling) |
360 |
|
epfree(ep); |
572 |
|
} else { /* ordinary definition */ |
573 |
|
ep = getdefn(); |
574 |
|
qname = qualname(dname(ep), 0); |
575 |
< |
if (esupport&E_REDEFW && (vdef = varlookup(qname)) != NULL) |
575 |
> |
if (esupport&E_REDEFW && (vdef = varlookup(qname)) != NULL) { |
576 |
|
if (vdef->def != NULL && epcmp(ep, vdef->def)) { |
577 |
|
wputs(qname); |
578 |
|
if (vdef->def->type == ':') |
583 |
|
wputs(qname); |
584 |
|
wputs(": definition hides library function\n"); |
585 |
|
} |
586 |
+ |
} |
587 |
|
if (ep->type == ':') |
588 |
|
dremove(qname); |
589 |
|
else |
690 |
|
*/ |
691 |
|
|
692 |
|
|
693 |
< |
static double |
694 |
< |
dvalue( /* evaluate a variable */ |
694 |
< |
char *name, |
695 |
< |
EPNODE *d |
696 |
< |
) |
693 |
> |
static double /* evaluate a variable */ |
694 |
> |
dvalue(char *name, EPNODE *d) |
695 |
|
{ |
696 |
|
register EPNODE *ep1, *ep2; |
697 |
|
|
707 |
|
if (eclock >= MAXCLOCK) |
708 |
|
eclock = 1; /* wrap clock counter */ |
709 |
|
if (ep2->v.tick < MAXCLOCK && |
710 |
< |
ep2->v.tick == 0 | ep2->v.tick != eclock) { |
710 |
> |
(ep2->v.tick == 0) | (ep2->v.tick != eclock)) { |
711 |
|
ep2->v.tick = d->type == ':' ? MAXCLOCK : eclock; |
712 |
|
ep2 = ep2->sibling; |
713 |
|
ep2->v.num = evalue(ep1); /* needs new value */ |