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