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