tb.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
1/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
2/*	  All Rights Reserved  	*/
3
4
5/*
6 * Copyright (c) 1980 Regents of the University of California.
7 * All rights reserved. The Berkeley software License Agreement
8 * specifies the terms and conditions for redistribution.
9 */
10
11/*
12 * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc.
13 * All Rights Reserved.
14 */
15
16#ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.1	*/
17
18 /* tb.c: check which entries exist, also storage allocation */
19# include "t..c"
20checkuse()
21{
22int i,c, k;
23for(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}
44real(s)
45	char *s;
46{
47if (s==0) return(0);
48if (!point(s)) return(1);
49if (*s==0) return(0);
50return(1);
51}
52int spcount = 0;
53extern char * calloc();
54# define MAXVEC 20
55char *spvecs[MAXVEC];
56
57char *
58chspace()
59{
60char *pp;
61if (spvecs[spcount])
62	return(spvecs[spcount++]);
63if (spcount>=MAXVEC)
64	error(gettext("Too many characters in table"));
65spvecs[spcount++]= pp = calloc(MAXCHS+MAXSTR,1);
66if (pp == 0)
67	error(gettext("no space for characters"));
68return(pp);
69}
70# define MAXPC 50
71char *thisvec;
72int tpcount = -1;
73char *tpvecs[MAXPC];
74
75int *
76alocv(n)
77{
78int *tp, *q;
79if (tpcount<0 || thisvec+n > tpvecs[tpcount]+MAXCHS)
80	{
81	tpcount++;
82	if (tpvecs[tpcount]==0)
83		{
84		tpvecs[tpcount] = calloc(MAXCHS,1);
85		}
86	thisvec = tpvecs[tpcount];
87	if (thisvec == 0)
88		error(gettext("no space for vectors"));
89	}
90tp=(int *)thisvec;
91thisvec+=n;
92for(q=tp; q<(int *)thisvec; q++)
93	*q=0;
94return(tp);
95}
96release()
97{
98extern char *exstore;
99/* give back unwanted space in some vectors */
100spcount=0;
101tpcount= -1;
102exstore=0;
103}
104