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