xref: /titanic_51/usr/src/cmd/tbl/tb.c (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
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"
20 checkuse()
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 real(s)
45 	char *s;
46 {
47 if (s==0) return(0);
48 if (!point(s)) return(1);
49 if (*s==0) return(0);
50 return(1);
51 }
52 int spcount = 0;
53 extern char * calloc();
54 # define MAXVEC 20
55 char *spvecs[MAXVEC];
56 
57 char *
58 chspace()
59 {
60 char *pp;
61 if (spvecs[spcount])
62 	return(spvecs[spcount++]);
63 if (spcount>=MAXVEC)
64 	error(gettext("Too many characters in table"));
65 spvecs[spcount++]= pp = calloc(MAXCHS+MAXSTR,1);
66 if (pp == 0)
67 	error(gettext("no space for characters"));
68 return(pp);
69 }
70 # define MAXPC 50
71 char *thisvec;
72 int tpcount = -1;
73 char *tpvecs[MAXPC];
74 
75 int *
76 alocv(n)
77 {
78 int *tp, *q;
79 if (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 	}
90 tp=(int *)thisvec;
91 thisvec+=n;
92 for(q=tp; q<(int *)thisvec; q++)
93 	*q=0;
94 return(tp);
95 }
96 release()
97 {
98 extern char *exstore;
99 /* give back unwanted space in some vectors */
100 spcount=0;
101 tpcount= -1;
102 exstore=0;
103 }
104