add sanity checks for old file systems
[unix-history] / usr / src / old / tbl / tb.c
CommitLineData
476fcd16 1#ifndef lint
496e6be8 2static char sccsid[] = "@(#)tb.c 4.3 %G%";
476fcd16 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];
496e6be8
JB
43
44char *
96529df1
BS
45chspace()
46{
47char *pp;
48if (spvecs[spcount])
49 return(spvecs[spcount++]);
50if (spcount>=MAXVEC)
51 error("Too many characters in table");
52spvecs[spcount++]= pp = calloc(MAXCHS+200,1);
53if (pp== -1 || pp == 0)
54 error("no space for characters");
55return(pp);
56}
57# define MAXPC 50
58char *thisvec;
59int tpcount = -1;
60char *tpvecs[MAXPC];
496e6be8
JB
61
62int *
96529df1
BS
63alocv(n)
64{
65int *tp, *q;
66if (tpcount<0 || thisvec+n > tpvecs[tpcount]+MAXCHS)
67 {
68 tpcount++;
69 if (tpvecs[tpcount]==0)
70 {
71 tpvecs[tpcount] = calloc(MAXCHS,1);
72 }
73 thisvec = tpvecs[tpcount];
74 if (thisvec == -1)
75 error("no space for vectors");
76 }
77tp=thisvec;
78thisvec+=n;
79for(q=tp; q<thisvec; q++)
80 *q=0;
81return(tp);
82}
83release()
84{
85extern char *exstore;
86/* give back unwanted space in some vectors */
87spcount=0;
88tpcount= -1;
89exstore=0;
90}