formatting
[unix-history] / usr / src / old / tbl / tb.c
CommitLineData
96529df1
BS
1/* tb.c 4.1 83/02/12 */
2
3 /* tb.c: check which entries exist, also storage allocation */
4# include "t..c"
5checkuse()
6{
7int i,c, k;
8for(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}
29real(s)
30 char *s;
31{
32if (s==0) return(0);
33if (!point(s)) return(1);
34if (*s==0) return(0);
35return(1);
36}
37int spcount = 0;
38extern char * calloc();
39# define MAXVEC 20
40char *spvecs[MAXVEC];
41chspace()
42{
43char *pp;
44if (spvecs[spcount])
45 return(spvecs[spcount++]);
46if (spcount>=MAXVEC)
47 error("Too many characters in table");
48spvecs[spcount++]= pp = calloc(MAXCHS+200,1);
49if (pp== -1 || pp == 0)
50 error("no space for characters");
51return(pp);
52}
53# define MAXPC 50
54char *thisvec;
55int tpcount = -1;
56char *tpvecs[MAXPC];
57alocv(n)
58{
59int *tp, *q;
60if (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 }
71tp=thisvec;
72thisvec+=n;
73for(q=tp; q<thisvec; q++)
74 *q=0;
75return(tp);
76}
77release()
78{
79extern char *exstore;
80/* give back unwanted space in some vectors */
81spcount=0;
82tpcount= -1;
83exstore=0;
84}