xref: /csrg-svn/old/tbl/tb.c (revision 48316)
1*48316Sbostic /*-
2*48316Sbostic  * %sccs.include.proprietary.c%
3*48316Sbostic  */
4*48316Sbostic 
514513Ssam #ifndef lint
6*48316Sbostic static char sccsid[] = "@(#)tb.c	4.6 (Berkeley) 04/18/91";
7*48316Sbostic #endif /* not lint */
811037Sshannon 
911037Sshannon  /* tb.c: check which entries exist, also storage allocation */
1011037Sshannon # include "t..c"
checkuse()1111037Sshannon checkuse()
1211037Sshannon {
1311037Sshannon int i,c, k;
1411037Sshannon for(c=0; c<ncol; c++)
1511037Sshannon 	{
1611037Sshannon 	used[c]=lused[c]=rused[c]=0;
1711037Sshannon 	for(i=0; i<nlin; i++)
1811037Sshannon 		{
1911037Sshannon 		if (instead[i] || fullbot[i]) continue;
2011037Sshannon 		k = ctype(i,c);
2111037Sshannon 		if (k== '-' || k == '=') continue;
2211037Sshannon 		if ((k=='n'||k=='a'))
2311037Sshannon 			{
2411037Sshannon 			rused[c]|= real(table[i][c].rcol);
2511037Sshannon 			if( !real(table[i][c].rcol))
2611037Sshannon 			used[c] |= real(table[i][c].col);
2711037Sshannon 			if (table[i][c].rcol)
2811037Sshannon 			lused[c] |= real(table[i][c].col);
2911037Sshannon 			}
3011037Sshannon 		else
3111037Sshannon 			used[c] |= real(table[i][c].col);
3211037Sshannon 		}
3311037Sshannon 	}
3411037Sshannon }
real(s)3511037Sshannon real(s)
3611037Sshannon 	char *s;
3711037Sshannon {
3811037Sshannon if (s==0) return(0);
3911037Sshannon if (!point(s)) return(1);
4011037Sshannon if (*s==0) return(0);
4111037Sshannon return(1);
4211037Sshannon }
4311037Sshannon int spcount = 0;
4411037Sshannon extern char * calloc();
4511037Sshannon # define MAXVEC 20
4611037Sshannon char *spvecs[MAXVEC];
4724737Sbloom 
4824737Sbloom char *
chspace()4911037Sshannon chspace()
5011037Sshannon {
5111037Sshannon char *pp;
5211037Sshannon if (spvecs[spcount])
5311037Sshannon 	return(spvecs[spcount++]);
5411037Sshannon if (spcount>=MAXVEC)
5511037Sshannon 	error("Too many characters in table");
5611037Sshannon spvecs[spcount++]= pp = calloc(MAXCHS+200,1);
5735262Sbostic if (pp == 0)
5811037Sshannon 	error("no space for characters");
5911037Sshannon return(pp);
6011037Sshannon }
6111037Sshannon # define MAXPC 50
6211037Sshannon char *thisvec;
6311037Sshannon int tpcount = -1;
6411037Sshannon char *tpvecs[MAXPC];
6524737Sbloom 
6624737Sbloom int *
alocv(n)6711037Sshannon alocv(n)
6811037Sshannon {
6911037Sshannon int *tp, *q;
7011037Sshannon if (tpcount<0 || thisvec+n > tpvecs[tpcount]+MAXCHS)
7111037Sshannon 	{
7211037Sshannon 	tpcount++;
7311037Sshannon 	if (tpvecs[tpcount]==0)
7411037Sshannon 		{
7511037Sshannon 		tpvecs[tpcount] = calloc(MAXCHS,1);
7611037Sshannon 		}
7711037Sshannon 	thisvec = tpvecs[tpcount];
7835262Sbostic 	if (thisvec == 0)
7911037Sshannon 		error("no space for vectors");
8011037Sshannon 	}
8145443Sbostic tp=(int *)thisvec;
8211037Sshannon thisvec+=n;
8345443Sbostic for(q=tp; q<(int *)thisvec; q++)
8411037Sshannon 	*q=0;
8511037Sshannon return(tp);
8611037Sshannon }
release()8711037Sshannon release()
8811037Sshannon {
8911037Sshannon extern char *exstore;
9011037Sshannon /* give back unwanted space in some vectors */
9111037Sshannon spcount=0;
9211037Sshannon tpcount= -1;
9311037Sshannon exstore=0;
9411037Sshannon }
95