Commit | Line | Data |
---|---|---|
70668e30 KT |
1 | # |
2 | ||
3 | #include "m6.h" | |
4 | ||
5 | char * | |
6 | finddef(n) { | |
7 | char *p; | |
8 | if((p = lookup(arg(n)))==0) | |
9 | if((p = lookup(""))==0) diag("Software error"); | |
10 | return(p); | |
11 | } | |
12 | ||
13 | char * | |
14 | lookup(s) { | |
15 | char *dt; | |
16 | dt = df; | |
17 | while(dt>d0) { | |
18 | if(dt->dswitch>=0 && comp(s,&dt->dident)) return(dt); | |
19 | dt =+ dt->prev; | |
20 | } | |
21 | return(0); | |
22 | } | |
23 | ||
24 | comp(s,t) | |
25 | char *s, *t; | |
26 | { | |
27 | for(;*s++ == *t;t++) | |
28 | if(*t==0) return(1); | |
29 | return(0); | |
30 | } | |
31 | ||
32 | remove(n) { | |
33 | char *p; | |
34 | if(p = lookup(arg(n))) if(p>d0+2) { | |
35 | trashflag++; | |
36 | p->dswitch = -1; | |
37 | } | |
38 | } | |
39 | ||
40 | trash() { | |
41 | char *p,*q,*r; | |
42 | if(lg>0) return; | |
43 | while(df->dswitch<0) { | |
44 | de = df; | |
45 | df =+ df->prev; | |
46 | trashflag--; | |
47 | } | |
48 | if(trashflag<=0) return; | |
49 | de = (de+1)&0177776; | |
50 | revptr(de,df,&p,&q); | |
51 | q = p; | |
52 | for(;p->word!=0;p=+r->word) { | |
53 | r = p; | |
54 | if(p->dswitch>=0) { | |
55 | r = q; | |
56 | q = move(p,q,p->word); | |
57 | } | |
58 | } | |
59 | q->word = 0; | |
60 | revptr(d0,d0+2,&df,&de); | |
61 | } | |
62 | ||
63 | ||
64 | revptr(p,q,np,nq) | |
65 | char *p, *q, **np, **nq; | |
66 | { | |
67 | int t; | |
68 | p->word = 0; | |
69 | while((t = q->word)!=0) { | |
70 | q->word = p-q; | |
71 | p = q; | |
72 | q =+ t; | |
73 | if(q<d0 || q>dmax) diag("Software error"); | |
74 | } | |
75 | *np = p; | |
76 | *nq = q; | |
77 | } | |
78 | ||
79 | char * | |
80 | move(from,to,count) | |
81 | char *from, *to; | |
82 | { | |
83 | while(count-->0) *to++ = *from++; | |
84 | return(to); | |
85 | } |