initial port of plan9 troff to linux
[troff.git] / tbl / t9.c
blobd0699e8db8defc7490437cbc1803f3ee2963955d
1 /* t9.c: write lines for tables over 200 lines */
2 # include "t.h"
3 static useln;
5 void
6 yetmore(void)
8 for (useln = 0; useln < MAXLIN && table[useln] == 0; useln++)
10 if (useln >= MAXLIN)
11 error("Wierd. No data in table.");
12 table[0] = table[useln];
13 for (useln = nlin - 1; useln >= 0 && (fullbot[useln] || instead[useln]); useln--)
15 if (useln < 0)
16 error("Wierd. No real lines in table.");
17 domore(leftover);
18 while (gets1(cstore = cspace, MAXCHS) && domore(cstore))
20 last = cstore;
24 int
25 domore(char *dataln)
27 int icol, ch;
29 if (prefix(".TE", dataln))
30 return(0);
31 if (dataln[0] == '.' && !isdigit(dataln[1])) {
32 fprintf(tabout, "%s\n", dataln);
33 return(1);
35 fullbot[0] = 0;
36 instead[0] = (char *)0;
37 if (dataln[1] == 0)
38 switch (dataln[0]) {
39 case '_':
40 fullbot[0] = '-';
41 putline(useln, 0);
42 return(1);
43 case '=':
44 fullbot[0] = '=';
45 putline(useln, 0);
46 return(1);
48 for (icol = 0; icol < ncol; icol++) {
49 table[0][icol].col = dataln;
50 table[0][icol].rcol = 0;
51 for (; (ch = *dataln) != '\0' && ch != tab; dataln++)
53 *dataln++ = '\0';
54 switch (ctype(useln, icol)) {
55 case 'n':
56 table[0][icol].rcol = maknew(table[0][icol].col);
57 break;
58 case 'a':
59 table[0][icol].rcol = table[0][icol].col;
60 table[0][icol].col = "";
61 break;
63 while (ctype(useln, icol + 1) == 's') /* spanning */
64 table[0][++icol].col = "";
65 if (ch == '\0')
66 break;
68 while (++icol < ncol)
69 table[0][icol].col = "";
70 putline(useln, 0);
71 exstore = exspace; /* reuse space for numerical items */
72 return(1);