xref: /onnv-gate/usr/src/cmd/tbl/tb.c (revision 381:1a7f0e46092a)
1*381Smuffin /*
2*381Smuffin  * Copyright 1991 Sun Microsystems, Inc.  All rights reserved.
3*381Smuffin  * Use is subject to license terms.
4*381Smuffin  */
5*381Smuffin 
60Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
70Sstevel@tonic-gate /*	  All Rights Reserved  	*/
80Sstevel@tonic-gate 
90Sstevel@tonic-gate /*
100Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
110Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
120Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
130Sstevel@tonic-gate  */
140Sstevel@tonic-gate 
15*381Smuffin #pragma ident	"%Z%%M%	%I%	%E% SMI"
160Sstevel@tonic-gate 
170Sstevel@tonic-gate  /* tb.c: check which entries exist, also storage allocation */
180Sstevel@tonic-gate # include "t..c"
19*381Smuffin #include <stdlib.h>
20*381Smuffin 
21*381Smuffin void
checkuse(void)22*381Smuffin checkuse(void)
230Sstevel@tonic-gate {
240Sstevel@tonic-gate int i,c, k;
250Sstevel@tonic-gate for(c=0; c<ncol; c++)
260Sstevel@tonic-gate 	{
270Sstevel@tonic-gate 	used[c]=lused[c]=rused[c]=0;
280Sstevel@tonic-gate 	for(i=0; i<nlin; i++)
290Sstevel@tonic-gate 		{
300Sstevel@tonic-gate 		if (instead[i] || fullbot[i]) continue;
310Sstevel@tonic-gate 		k = ctype(i,c);
320Sstevel@tonic-gate 		if (k== '-' || k == '=') continue;
330Sstevel@tonic-gate 		if ((k=='n'||k=='a'))
340Sstevel@tonic-gate 			{
350Sstevel@tonic-gate 			rused[c]|= real(table[i][c].rcol);
360Sstevel@tonic-gate 			if( !real(table[i][c].rcol))
370Sstevel@tonic-gate 			used[c] |= real(table[i][c].col);
380Sstevel@tonic-gate 			if (table[i][c].rcol)
390Sstevel@tonic-gate 			lused[c] |= real(table[i][c].col);
400Sstevel@tonic-gate 			}
410Sstevel@tonic-gate 		else
420Sstevel@tonic-gate 			used[c] |= real(table[i][c].col);
430Sstevel@tonic-gate 		}
440Sstevel@tonic-gate 	}
450Sstevel@tonic-gate }
46*381Smuffin 
47*381Smuffin int
real(char * s)48*381Smuffin real(char *s)
490Sstevel@tonic-gate {
500Sstevel@tonic-gate if (s==0) return(0);
510Sstevel@tonic-gate if (!point(s)) return(1);
520Sstevel@tonic-gate if (*s==0) return(0);
530Sstevel@tonic-gate return(1);
540Sstevel@tonic-gate }
55*381Smuffin 
560Sstevel@tonic-gate int spcount = 0;
57*381Smuffin 
580Sstevel@tonic-gate # define MAXVEC 20
59*381Smuffin 
600Sstevel@tonic-gate char *spvecs[MAXVEC];
610Sstevel@tonic-gate 
620Sstevel@tonic-gate char *
chspace(void)63*381Smuffin chspace(void)
640Sstevel@tonic-gate {
650Sstevel@tonic-gate char *pp;
660Sstevel@tonic-gate if (spvecs[spcount])
670Sstevel@tonic-gate 	return(spvecs[spcount++]);
680Sstevel@tonic-gate if (spcount>=MAXVEC)
690Sstevel@tonic-gate 	error(gettext("Too many characters in table"));
700Sstevel@tonic-gate spvecs[spcount++]= pp = calloc(MAXCHS+MAXSTR,1);
710Sstevel@tonic-gate if (pp == 0)
720Sstevel@tonic-gate 	error(gettext("no space for characters"));
730Sstevel@tonic-gate return(pp);
740Sstevel@tonic-gate }
75*381Smuffin 
760Sstevel@tonic-gate # define MAXPC 50
77*381Smuffin 
780Sstevel@tonic-gate char *thisvec;
790Sstevel@tonic-gate int tpcount = -1;
800Sstevel@tonic-gate char *tpvecs[MAXPC];
810Sstevel@tonic-gate 
820Sstevel@tonic-gate int *
alocv(int n)83*381Smuffin alocv(int n)
840Sstevel@tonic-gate {
850Sstevel@tonic-gate int *tp, *q;
860Sstevel@tonic-gate if (tpcount<0 || thisvec+n > tpvecs[tpcount]+MAXCHS)
870Sstevel@tonic-gate 	{
880Sstevel@tonic-gate 	tpcount++;
890Sstevel@tonic-gate 	if (tpvecs[tpcount]==0)
900Sstevel@tonic-gate 		{
910Sstevel@tonic-gate 		tpvecs[tpcount] = calloc(MAXCHS,1);
920Sstevel@tonic-gate 		}
930Sstevel@tonic-gate 	thisvec = tpvecs[tpcount];
940Sstevel@tonic-gate 	if (thisvec == 0)
950Sstevel@tonic-gate 		error(gettext("no space for vectors"));
960Sstevel@tonic-gate 	}
970Sstevel@tonic-gate tp=(int *)thisvec;
980Sstevel@tonic-gate thisvec+=n;
990Sstevel@tonic-gate for(q=tp; q<(int *)thisvec; q++)
1000Sstevel@tonic-gate 	*q=0;
1010Sstevel@tonic-gate return(tp);
1020Sstevel@tonic-gate }
103*381Smuffin 
104*381Smuffin void
release(void)105*381Smuffin release(void)
1060Sstevel@tonic-gate {
1070Sstevel@tonic-gate extern char *exstore;
1080Sstevel@tonic-gate /* give back unwanted space in some vectors */
1090Sstevel@tonic-gate spcount=0;
1100Sstevel@tonic-gate tpcount= -1;
1110Sstevel@tonic-gate exstore=0;
1120Sstevel@tonic-gate }
113