TWO BUGS (printf doesn't take a FILE *, plus wrong arg to gettimeofday)
[unix-history] / usr / src / old / tbl / tb.c
CommitLineData
94bed826
KB
1/*-
2 * %sccs.include.proprietary.c%
3 */
4
476fcd16 5#ifndef lint
94bed826
KB
6static char sccsid[] = "@(#)tb.c 4.6 (Berkeley) %G%";
7#endif /* not lint */
96529df1
BS
8
9 /* tb.c: check which entries exist, also storage allocation */
10# include "t..c"
11checkuse()
12{
13int i,c, k;
14for(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}
35real(s)
36 char *s;
37{
38if (s==0) return(0);
39if (!point(s)) return(1);
40if (*s==0) return(0);
41return(1);
42}
43int spcount = 0;
44extern char * calloc();
45# define MAXVEC 20
46char *spvecs[MAXVEC];
496e6be8
JB
47
48char *
96529df1
BS
49chspace()
50{
51char *pp;
52if (spvecs[spcount])
53 return(spvecs[spcount++]);
54if (spcount>=MAXVEC)
55 error("Too many characters in table");
56spvecs[spcount++]= pp = calloc(MAXCHS+200,1);
bdbc9c90 57if (pp == 0)
96529df1
BS
58 error("no space for characters");
59return(pp);
60}
61# define MAXPC 50
62char *thisvec;
63int tpcount = -1;
64char *tpvecs[MAXPC];
496e6be8
JB
65
66int *
96529df1
BS
67alocv(n)
68{
69int *tp, *q;
70if (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];
bdbc9c90 78 if (thisvec == 0)
96529df1
BS
79 error("no space for vectors");
80 }
d4cdb00e 81tp=(int *)thisvec;
96529df1 82thisvec+=n;
d4cdb00e 83for(q=tp; q<(int *)thisvec; q++)
96529df1
BS
84 *q=0;
85return(tp);
86}
87release()
88{
89extern char *exstore;
90/* give back unwanted space in some vectors */
91spcount=0;
92tpcount= -1;
93exstore=0;
94}