xref: /illumos-gate/usr/src/cmd/tbl/tb.c (revision 2a8bcb4e)
1*b5514887Smuffin /*
2*b5514887Smuffin  * Copyright 1991 Sun Microsystems, Inc.  All rights reserved.
3*b5514887Smuffin  * Use is subject to license terms.
4*b5514887Smuffin  */
5*b5514887Smuffin 
67c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
77c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
87c478bd9Sstevel@tonic-gate 
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
117c478bd9Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
127c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
137c478bd9Sstevel@tonic-gate  */
147c478bd9Sstevel@tonic-gate 
157c478bd9Sstevel@tonic-gate  /* tb.c: check which entries exist, also storage allocation */
167c478bd9Sstevel@tonic-gate # include "t..c"
17*b5514887Smuffin #include <stdlib.h>
18*b5514887Smuffin 
19*b5514887Smuffin void
checkuse(void)20*b5514887Smuffin checkuse(void)
217c478bd9Sstevel@tonic-gate {
227c478bd9Sstevel@tonic-gate int i,c, k;
237c478bd9Sstevel@tonic-gate for(c=0; c<ncol; c++)
247c478bd9Sstevel@tonic-gate 	{
257c478bd9Sstevel@tonic-gate 	used[c]=lused[c]=rused[c]=0;
267c478bd9Sstevel@tonic-gate 	for(i=0; i<nlin; i++)
277c478bd9Sstevel@tonic-gate 		{
287c478bd9Sstevel@tonic-gate 		if (instead[i] || fullbot[i]) continue;
297c478bd9Sstevel@tonic-gate 		k = ctype(i,c);
307c478bd9Sstevel@tonic-gate 		if (k== '-' || k == '=') continue;
317c478bd9Sstevel@tonic-gate 		if ((k=='n'||k=='a'))
327c478bd9Sstevel@tonic-gate 			{
337c478bd9Sstevel@tonic-gate 			rused[c]|= real(table[i][c].rcol);
347c478bd9Sstevel@tonic-gate 			if( !real(table[i][c].rcol))
357c478bd9Sstevel@tonic-gate 			used[c] |= real(table[i][c].col);
367c478bd9Sstevel@tonic-gate 			if (table[i][c].rcol)
377c478bd9Sstevel@tonic-gate 			lused[c] |= real(table[i][c].col);
387c478bd9Sstevel@tonic-gate 			}
397c478bd9Sstevel@tonic-gate 		else
407c478bd9Sstevel@tonic-gate 			used[c] |= real(table[i][c].col);
417c478bd9Sstevel@tonic-gate 		}
427c478bd9Sstevel@tonic-gate 	}
437c478bd9Sstevel@tonic-gate }
44*b5514887Smuffin 
45*b5514887Smuffin int
real(char * s)46*b5514887Smuffin real(char *s)
477c478bd9Sstevel@tonic-gate {
487c478bd9Sstevel@tonic-gate if (s==0) return(0);
497c478bd9Sstevel@tonic-gate if (!point(s)) return(1);
507c478bd9Sstevel@tonic-gate if (*s==0) return(0);
517c478bd9Sstevel@tonic-gate return(1);
527c478bd9Sstevel@tonic-gate }
53*b5514887Smuffin 
547c478bd9Sstevel@tonic-gate int spcount = 0;
55*b5514887Smuffin 
567c478bd9Sstevel@tonic-gate # define MAXVEC 20
57*b5514887Smuffin 
587c478bd9Sstevel@tonic-gate char *spvecs[MAXVEC];
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate char *
chspace(void)61*b5514887Smuffin chspace(void)
627c478bd9Sstevel@tonic-gate {
637c478bd9Sstevel@tonic-gate char *pp;
647c478bd9Sstevel@tonic-gate if (spvecs[spcount])
657c478bd9Sstevel@tonic-gate 	return(spvecs[spcount++]);
667c478bd9Sstevel@tonic-gate if (spcount>=MAXVEC)
677c478bd9Sstevel@tonic-gate 	error(gettext("Too many characters in table"));
687c478bd9Sstevel@tonic-gate spvecs[spcount++]= pp = calloc(MAXCHS+MAXSTR,1);
697c478bd9Sstevel@tonic-gate if (pp == 0)
707c478bd9Sstevel@tonic-gate 	error(gettext("no space for characters"));
717c478bd9Sstevel@tonic-gate return(pp);
727c478bd9Sstevel@tonic-gate }
73*b5514887Smuffin 
747c478bd9Sstevel@tonic-gate # define MAXPC 50
75*b5514887Smuffin 
767c478bd9Sstevel@tonic-gate char *thisvec;
777c478bd9Sstevel@tonic-gate int tpcount = -1;
787c478bd9Sstevel@tonic-gate char *tpvecs[MAXPC];
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate int *
alocv(int n)81*b5514887Smuffin alocv(int n)
827c478bd9Sstevel@tonic-gate {
837c478bd9Sstevel@tonic-gate int *tp, *q;
847c478bd9Sstevel@tonic-gate if (tpcount<0 || thisvec+n > tpvecs[tpcount]+MAXCHS)
857c478bd9Sstevel@tonic-gate 	{
867c478bd9Sstevel@tonic-gate 	tpcount++;
877c478bd9Sstevel@tonic-gate 	if (tpvecs[tpcount]==0)
887c478bd9Sstevel@tonic-gate 		{
897c478bd9Sstevel@tonic-gate 		tpvecs[tpcount] = calloc(MAXCHS,1);
907c478bd9Sstevel@tonic-gate 		}
917c478bd9Sstevel@tonic-gate 	thisvec = tpvecs[tpcount];
927c478bd9Sstevel@tonic-gate 	if (thisvec == 0)
937c478bd9Sstevel@tonic-gate 		error(gettext("no space for vectors"));
947c478bd9Sstevel@tonic-gate 	}
957c478bd9Sstevel@tonic-gate tp=(int *)thisvec;
967c478bd9Sstevel@tonic-gate thisvec+=n;
977c478bd9Sstevel@tonic-gate for(q=tp; q<(int *)thisvec; q++)
987c478bd9Sstevel@tonic-gate 	*q=0;
997c478bd9Sstevel@tonic-gate return(tp);
1007c478bd9Sstevel@tonic-gate }
101*b5514887Smuffin 
102*b5514887Smuffin void
release(void)103*b5514887Smuffin release(void)
1047c478bd9Sstevel@tonic-gate {
1057c478bd9Sstevel@tonic-gate extern char *exstore;
1067c478bd9Sstevel@tonic-gate /* give back unwanted space in some vectors */
1077c478bd9Sstevel@tonic-gate spcount=0;
1087c478bd9Sstevel@tonic-gate tpcount= -1;
1097c478bd9Sstevel@tonic-gate exstore=0;
1107c478bd9Sstevel@tonic-gate }
111