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#pragma ident	"%Z%%M%	%I%	%E% SMI"
16
17 /* tb.c: check which entries exist, also storage allocation */
18# include "t..c"
19#include <stdlib.h>
20
21void
22checkuse(void)
23{
24int i,c, k;
25for(c=0; c<ncol; c++)
26	{
27	used[c]=lused[c]=rused[c]=0;
28	for(i=0; i<nlin; i++)
29		{
30		if (instead[i] || fullbot[i]) continue;
31		k = ctype(i,c);
32		if (k== '-' || k == '=') continue;
33		if ((k=='n'||k=='a'))
34			{
35			rused[c]|= real(table[i][c].rcol);
36			if( !real(table[i][c].rcol))
37			used[c] |= real(table[i][c].col);
38			if (table[i][c].rcol)
39			lused[c] |= real(table[i][c].col);
40			}
41		else
42			used[c] |= real(table[i][c].col);
43		}
44	}
45}
46
47int
48real(char *s)
49{
50if (s==0) return(0);
51if (!point(s)) return(1);
52if (*s==0) return(0);
53return(1);
54}
55
56int spcount = 0;
57
58# define MAXVEC 20
59
60char *spvecs[MAXVEC];
61
62char *
63chspace(void)
64{
65char *pp;
66if (spvecs[spcount])
67	return(spvecs[spcount++]);
68if (spcount>=MAXVEC)
69	error(gettext("Too many characters in table"));
70spvecs[spcount++]= pp = calloc(MAXCHS+MAXSTR,1);
71if (pp == 0)
72	error(gettext("no space for characters"));
73return(pp);
74}
75
76# define MAXPC 50
77
78char *thisvec;
79int tpcount = -1;
80char *tpvecs[MAXPC];
81
82int *
83alocv(int n)
84{
85int *tp, *q;
86if (tpcount<0 || thisvec+n > tpvecs[tpcount]+MAXCHS)
87	{
88	tpcount++;
89	if (tpvecs[tpcount]==0)
90		{
91		tpvecs[tpcount] = calloc(MAXCHS,1);
92		}
93	thisvec = tpvecs[tpcount];
94	if (thisvec == 0)
95		error(gettext("no space for vectors"));
96	}
97tp=(int *)thisvec;
98thisvec+=n;
99for(q=tp; q<(int *)thisvec; q++)
100	*q=0;
101return(tp);
102}
103
104void
105release(void)
106{
107extern char *exstore;
108/* give back unwanted space in some vectors */
109spcount=0;
110tpcount= -1;
111exstore=0;
112}
113