xref: /onnv-gate/usr/src/cmd/tbl/t9.c (revision 381:1a7f0e46092a)
10Sstevel@tonic-gate /*
2*381Smuffin  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
30Sstevel@tonic-gate  * Use is subject to license terms.
40Sstevel@tonic-gate  */
50Sstevel@tonic-gate 
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 /*
110Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
120Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
130Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
140Sstevel@tonic-gate  */
150Sstevel@tonic-gate 
160Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
170Sstevel@tonic-gate 
180Sstevel@tonic-gate  /* t9.c: write lines for tables over 200 lines */
190Sstevel@tonic-gate # include "t..c"
20*381Smuffin 
21*381Smuffin static int useln;
22*381Smuffin 
23*381Smuffin void
yetmore(void)24*381Smuffin yetmore(void)
250Sstevel@tonic-gate {
260Sstevel@tonic-gate for(useln=0; useln<MAXLIN && table[useln]==0; useln++);
270Sstevel@tonic-gate if (useln>=MAXLIN)
280Sstevel@tonic-gate 	error(gettext("Weird.  No data in table."));
290Sstevel@tonic-gate table[0]=table[useln];
300Sstevel@tonic-gate for(useln=nlin-1; useln>=0 && (fullbot[useln] || instead[useln]); useln--);
310Sstevel@tonic-gate if (useln<0)
320Sstevel@tonic-gate 	error(gettext("Weird.  No real lines in table."));
330Sstevel@tonic-gate domore(leftover);
340Sstevel@tonic-gate while (gets1(cstore=cspace, MAXSTR) && domore(cstore))
350Sstevel@tonic-gate 	;
360Sstevel@tonic-gate last =cstore;
370Sstevel@tonic-gate return;
380Sstevel@tonic-gate }
39*381Smuffin 
40*381Smuffin int
domore(char * dataln)41*381Smuffin domore(char *dataln)
420Sstevel@tonic-gate {
430Sstevel@tonic-gate 	int icol, ch;
440Sstevel@tonic-gate if (prefix(".TE", dataln))
450Sstevel@tonic-gate 	return(0);
460Sstevel@tonic-gate if (dataln[0] == '.' && !isdigit((unsigned char)dataln[1]))
470Sstevel@tonic-gate 	{
480Sstevel@tonic-gate 	puts(dataln);
490Sstevel@tonic-gate 	return(1);
500Sstevel@tonic-gate 	}
510Sstevel@tonic-gate instead[0]=0;
520Sstevel@tonic-gate fullbot[0]=0;
530Sstevel@tonic-gate if (dataln[1]==0)
540Sstevel@tonic-gate switch(dataln[0])
550Sstevel@tonic-gate 	{
560Sstevel@tonic-gate 	case '_': fullbot[0]= '-'; putline(useln,0);  return(1);
570Sstevel@tonic-gate 	case '=': fullbot[0]= '='; putline(useln, 0); return(1);
580Sstevel@tonic-gate 	}
590Sstevel@tonic-gate for (icol = 0; icol <ncol; icol++)
600Sstevel@tonic-gate 	{
610Sstevel@tonic-gate 	table[0][icol].col = dataln;
620Sstevel@tonic-gate 	table[0][icol].rcol=0;
630Sstevel@tonic-gate 	for(; (ch= *dataln) != '\0' && ch != tab; dataln++)
640Sstevel@tonic-gate 			;
650Sstevel@tonic-gate 	*dataln++ = '\0';
660Sstevel@tonic-gate 	switch(ctype(useln,icol))
670Sstevel@tonic-gate 		{
680Sstevel@tonic-gate 		case 'n':
690Sstevel@tonic-gate 			table[0][icol].rcol = maknew(table[0][icol].col);
700Sstevel@tonic-gate 			break;
710Sstevel@tonic-gate 		case 'a':
720Sstevel@tonic-gate 			table[0][icol].rcol = table[0][icol].col;
730Sstevel@tonic-gate 			table[0][icol].col= "";
740Sstevel@tonic-gate 			break;
750Sstevel@tonic-gate 		}
760Sstevel@tonic-gate 	while (ctype(useln,icol+1)== 's') /* spanning */
770Sstevel@tonic-gate 		table[0][++icol].col = "";
780Sstevel@tonic-gate 	if (ch == '\0') break;
790Sstevel@tonic-gate 	}
800Sstevel@tonic-gate while (++icol <ncol)
810Sstevel@tonic-gate 	table[0][icol].col = "";
820Sstevel@tonic-gate putline(useln,0);
830Sstevel@tonic-gate return(1);
840Sstevel@tonic-gate }
85