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