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