1 /*
2 * Copyright 1991 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
5
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
8
9 /*
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
13 */
14
15 /* tb.c: check which entries exist, also storage allocation */
16 # include "t..c"
17 #include <stdlib.h>
18
19 void
checkuse(void)20 checkuse(void)
21 {
22 int i,c, k;
23 for(c=0; c<ncol; c++)
24 {
25 used[c]=lused[c]=rused[c]=0;
26 for(i=0; i<nlin; i++)
27 {
28 if (instead[i] || fullbot[i]) continue;
29 k = ctype(i,c);
30 if (k== '-' || k == '=') continue;
31 if ((k=='n'||k=='a'))
32 {
33 rused[c]|= real(table[i][c].rcol);
34 if( !real(table[i][c].rcol))
35 used[c] |= real(table[i][c].col);
36 if (table[i][c].rcol)
37 lused[c] |= real(table[i][c].col);
38 }
39 else
40 used[c] |= real(table[i][c].col);
41 }
42 }
43 }
44
45 int
real(char * s)46 real(char *s)
47 {
48 if (s==0) return(0);
49 if (!point(s)) return(1);
50 if (*s==0) return(0);
51 return(1);
52 }
53
54 int spcount = 0;
55
56 # define MAXVEC 20
57
58 char *spvecs[MAXVEC];
59
60 char *
chspace(void)61 chspace(void)
62 {
63 char *pp;
64 if (spvecs[spcount])
65 return(spvecs[spcount++]);
66 if (spcount>=MAXVEC)
67 error(gettext("Too many characters in table"));
68 spvecs[spcount++]= pp = calloc(MAXCHS+MAXSTR,1);
69 if (pp == 0)
70 error(gettext("no space for characters"));
71 return(pp);
72 }
73
74 # define MAXPC 50
75
76 char *thisvec;
77 int tpcount = -1;
78 char *tpvecs[MAXPC];
79
80 int *
alocv(int n)81 alocv(int n)
82 {
83 int *tp, *q;
84 if (tpcount<0 || thisvec+n > tpvecs[tpcount]+MAXCHS)
85 {
86 tpcount++;
87 if (tpvecs[tpcount]==0)
88 {
89 tpvecs[tpcount] = calloc(MAXCHS,1);
90 }
91 thisvec = tpvecs[tpcount];
92 if (thisvec == 0)
93 error(gettext("no space for vectors"));
94 }
95 tp=(int *)thisvec;
96 thisvec+=n;
97 for(q=tp; q<(int *)thisvec; q++)
98 *q=0;
99 return(tp);
100 }
101
102 void
release(void)103 release(void)
104 {
105 extern char *exstore;
106 /* give back unwanted space in some vectors */
107 spcount=0;
108 tpcount= -1;
109 exstore=0;
110 }
111