xref: /titanic_44/usr/src/cmd/tbl/t9.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright 1983-2003 Sun Microsystems, Inc.  All rights reserved.
3*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
4*7c478bd9Sstevel@tonic-gate  */
5*7c478bd9Sstevel@tonic-gate 
6*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
7*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
8*7c478bd9Sstevel@tonic-gate 
9*7c478bd9Sstevel@tonic-gate 
10*7c478bd9Sstevel@tonic-gate /*
11*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
12*7c478bd9Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
13*7c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
14*7c478bd9Sstevel@tonic-gate  */
15*7c478bd9Sstevel@tonic-gate 
16*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
17*7c478bd9Sstevel@tonic-gate 
18*7c478bd9Sstevel@tonic-gate  /* t9.c: write lines for tables over 200 lines */
19*7c478bd9Sstevel@tonic-gate # include "t..c"
20*7c478bd9Sstevel@tonic-gate static useln;
21*7c478bd9Sstevel@tonic-gate yetmore()
22*7c478bd9Sstevel@tonic-gate {
23*7c478bd9Sstevel@tonic-gate for(useln=0; useln<MAXLIN && table[useln]==0; useln++);
24*7c478bd9Sstevel@tonic-gate if (useln>=MAXLIN)
25*7c478bd9Sstevel@tonic-gate 	error(gettext("Weird.  No data in table."));
26*7c478bd9Sstevel@tonic-gate table[0]=table[useln];
27*7c478bd9Sstevel@tonic-gate for(useln=nlin-1; useln>=0 && (fullbot[useln] || instead[useln]); useln--);
28*7c478bd9Sstevel@tonic-gate if (useln<0)
29*7c478bd9Sstevel@tonic-gate 	error(gettext("Weird.  No real lines in table."));
30*7c478bd9Sstevel@tonic-gate domore(leftover);
31*7c478bd9Sstevel@tonic-gate while (gets1(cstore=cspace, MAXSTR) && domore(cstore))
32*7c478bd9Sstevel@tonic-gate 	;
33*7c478bd9Sstevel@tonic-gate last =cstore;
34*7c478bd9Sstevel@tonic-gate return;
35*7c478bd9Sstevel@tonic-gate }
36*7c478bd9Sstevel@tonic-gate domore(dataln)
37*7c478bd9Sstevel@tonic-gate 	char *dataln;
38*7c478bd9Sstevel@tonic-gate {
39*7c478bd9Sstevel@tonic-gate 	int icol, ch;
40*7c478bd9Sstevel@tonic-gate if (prefix(".TE", dataln))
41*7c478bd9Sstevel@tonic-gate 	return(0);
42*7c478bd9Sstevel@tonic-gate if (dataln[0] == '.' && !isdigit((unsigned char)dataln[1]))
43*7c478bd9Sstevel@tonic-gate 	{
44*7c478bd9Sstevel@tonic-gate 	puts(dataln);
45*7c478bd9Sstevel@tonic-gate 	return(1);
46*7c478bd9Sstevel@tonic-gate 	}
47*7c478bd9Sstevel@tonic-gate instead[0]=0;
48*7c478bd9Sstevel@tonic-gate fullbot[0]=0;
49*7c478bd9Sstevel@tonic-gate if (dataln[1]==0)
50*7c478bd9Sstevel@tonic-gate switch(dataln[0])
51*7c478bd9Sstevel@tonic-gate 	{
52*7c478bd9Sstevel@tonic-gate 	case '_': fullbot[0]= '-'; putline(useln,0);  return(1);
53*7c478bd9Sstevel@tonic-gate 	case '=': fullbot[0]= '='; putline(useln, 0); return(1);
54*7c478bd9Sstevel@tonic-gate 	}
55*7c478bd9Sstevel@tonic-gate for (icol = 0; icol <ncol; icol++)
56*7c478bd9Sstevel@tonic-gate 	{
57*7c478bd9Sstevel@tonic-gate 	table[0][icol].col = dataln;
58*7c478bd9Sstevel@tonic-gate 	table[0][icol].rcol=0;
59*7c478bd9Sstevel@tonic-gate 	for(; (ch= *dataln) != '\0' && ch != tab; dataln++)
60*7c478bd9Sstevel@tonic-gate 			;
61*7c478bd9Sstevel@tonic-gate 	*dataln++ = '\0';
62*7c478bd9Sstevel@tonic-gate 	switch(ctype(useln,icol))
63*7c478bd9Sstevel@tonic-gate 		{
64*7c478bd9Sstevel@tonic-gate 		case 'n':
65*7c478bd9Sstevel@tonic-gate 			table[0][icol].rcol = maknew(table[0][icol].col);
66*7c478bd9Sstevel@tonic-gate 			break;
67*7c478bd9Sstevel@tonic-gate 		case 'a':
68*7c478bd9Sstevel@tonic-gate 			table[0][icol].rcol = table[0][icol].col;
69*7c478bd9Sstevel@tonic-gate 			table[0][icol].col= "";
70*7c478bd9Sstevel@tonic-gate 			break;
71*7c478bd9Sstevel@tonic-gate 		}
72*7c478bd9Sstevel@tonic-gate 	while (ctype(useln,icol+1)== 's') /* spanning */
73*7c478bd9Sstevel@tonic-gate 		table[0][++icol].col = "";
74*7c478bd9Sstevel@tonic-gate 	if (ch == '\0') break;
75*7c478bd9Sstevel@tonic-gate 	}
76*7c478bd9Sstevel@tonic-gate while (++icol <ncol)
77*7c478bd9Sstevel@tonic-gate 	table[0][icol].col = "";
78*7c478bd9Sstevel@tonic-gate putline(useln,0);
79*7c478bd9Sstevel@tonic-gate return(1);
80*7c478bd9Sstevel@tonic-gate }
81