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