xref: /original-bsd/old/tbl/t9.c (revision 46bf0326)
1 /*-
2  * %sccs.include.proprietary.c%
3  */
4 
5 #ifndef lint
6 static char sccsid[] = "@(#)t9.c	4.4 (Berkeley) 04/18/91";
7 #endif /* not lint */
8 
9  /* t9.c: write lines for tables over 200 lines */
10 # include "t..c"
11 static useln;
12 yetmore()
13 {
14 for(useln=0; useln<MAXLIN && table[useln]==0; useln++);
15 if (useln>=MAXLIN)
16 	error("Weird.  No data in table.");
17 table[0]=table[useln];
18 for(useln=nlin-1; useln>=0 && (fullbot[useln] || instead[useln]); useln--);
19 if (useln<0)
20 	error("Weird.  No real lines in table.");
21 domore(leftover);
22 while (gets1(cstore=cspace) && domore(cstore))
23 	;
24 last =cstore;
25 return;
26 }
27 domore(dataln)
28 	char *dataln;
29 {
30 	int icol, ch;
31 if (prefix(".TE", dataln))
32 	return(0);
33 if (dataln[0] == '.' && !isdigit(dataln[1]))
34 	{
35 	puts(dataln);
36 	return(1);
37 	}
38 instead[0]=fullbot[0]=0;
39 if (dataln[1]==0)
40 switch(dataln[0])
41 	{
42 	case '_': fullbot[0]= '-'; putline(useln,0);  return(1);
43 	case '=': fullbot[0]= '='; putline(useln, 0); return(1);
44 	}
45 for (icol = 0; icol <ncol; icol++)
46 	{
47 	table[0][icol].col = dataln;
48 	table[0][icol].rcol=0;
49 	for(; (ch= *dataln) != '\0' && ch != tab; dataln++)
50 			;
51 	*dataln++ = '\0';
52 	switch(ctype(useln,icol))
53 		{
54 		case 'n':
55 			table[0][icol].rcol = maknew(table[0][icol].col);
56 			break;
57 		case 'a':
58 			table[0][icol].rcol = table[0][icol].col;
59 			table[0][icol].col= "";
60 			break;
61 		}
62 	while (ctype(useln,icol+1)== 's') /* spanning */
63 		table[0][++icol].col = "";
64 	if (ch == '\0') break;
65 	}
66 while (++icol <ncol)
67 	table[0][icol].col = "";
68 putline(useln,0);
69 return(1);
70 }
71