| 1 | /* tb.c 4.1 83/02/12 */ |
| 2 | |
| 3 | /* tb.c: check which entries exist, also storage allocation */ |
| 4 | # include "t..c" |
| 5 | checkuse() |
| 6 | { |
| 7 | int i,c, k; |
| 8 | for(c=0; c<ncol; c++) |
| 9 | { |
| 10 | used[c]=lused[c]=rused[c]=0; |
| 11 | for(i=0; i<nlin; i++) |
| 12 | { |
| 13 | if (instead[i] || fullbot[i]) continue; |
| 14 | k = ctype(i,c); |
| 15 | if (k== '-' || k == '=') continue; |
| 16 | if ((k=='n'||k=='a')) |
| 17 | { |
| 18 | rused[c]|= real(table[i][c].rcol); |
| 19 | if( !real(table[i][c].rcol)) |
| 20 | used[c] |= real(table[i][c].col); |
| 21 | if (table[i][c].rcol) |
| 22 | lused[c] |= real(table[i][c].col); |
| 23 | } |
| 24 | else |
| 25 | used[c] |= real(table[i][c].col); |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | real(s) |
| 30 | char *s; |
| 31 | { |
| 32 | if (s==0) return(0); |
| 33 | if (!point(s)) return(1); |
| 34 | if (*s==0) return(0); |
| 35 | return(1); |
| 36 | } |
| 37 | int spcount = 0; |
| 38 | extern char * calloc(); |
| 39 | # define MAXVEC 20 |
| 40 | char *spvecs[MAXVEC]; |
| 41 | chspace() |
| 42 | { |
| 43 | char *pp; |
| 44 | if (spvecs[spcount]) |
| 45 | return(spvecs[spcount++]); |
| 46 | if (spcount>=MAXVEC) |
| 47 | error("Too many characters in table"); |
| 48 | spvecs[spcount++]= pp = calloc(MAXCHS+200,1); |
| 49 | if (pp== -1 || pp == 0) |
| 50 | error("no space for characters"); |
| 51 | return(pp); |
| 52 | } |
| 53 | # define MAXPC 50 |
| 54 | char *thisvec; |
| 55 | int tpcount = -1; |
| 56 | char *tpvecs[MAXPC]; |
| 57 | alocv(n) |
| 58 | { |
| 59 | int *tp, *q; |
| 60 | if (tpcount<0 || thisvec+n > tpvecs[tpcount]+MAXCHS) |
| 61 | { |
| 62 | tpcount++; |
| 63 | if (tpvecs[tpcount]==0) |
| 64 | { |
| 65 | tpvecs[tpcount] = calloc(MAXCHS,1); |
| 66 | } |
| 67 | thisvec = tpvecs[tpcount]; |
| 68 | if (thisvec == -1) |
| 69 | error("no space for vectors"); |
| 70 | } |
| 71 | tp=thisvec; |
| 72 | thisvec+=n; |
| 73 | for(q=tp; q<thisvec; q++) |
| 74 | *q=0; |
| 75 | return(tp); |
| 76 | } |
| 77 | release() |
| 78 | { |
| 79 | extern char *exstore; |
| 80 | /* give back unwanted space in some vectors */ |
| 81 | spcount=0; |
| 82 | tpcount= -1; |
| 83 | exstore=0; |
| 84 | } |