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