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