]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/tbl/t9.c
fix filetype detecton by suffix so that multiple dots dont confuse it. (thanks kvik)
[plan9front.git] / sys / src / cmd / tbl / t9.c
1 /* t9.c: write lines for tables over 200 lines */
2 # include "t.h"
3 static useln;
4
5 void
6 yetmore(void)
7 {
8         for (useln = 0; useln < MAXLIN && table[useln] == 0; useln++)
9                 ;
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--)
14                 ;
15         if (useln < 0)
16                 error("Wierd.  No real lines in table.");
17         domore(leftover);
18         while (gets1(cstore = cspace, MAXCHS) && domore(cstore))
19                 ;
20         last = cstore;
21 }
22
23
24 int
25 domore(char *dataln)
26 {
27         int     icol, ch;
28
29         if (prefix(".TE", dataln))
30                 return(0);
31         if (dataln[0] == '.' && !isdigit(dataln[1])) {
32                 Bprint(&tabout, "%s\n", dataln);
33                 return(1);
34         }
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);
47                 }
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++)
52                         ;
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;
62                 }
63                 while (ctype(useln, icol + 1) == 's') /* spanning */
64                         table[0][++icol].col = "";
65                 if (ch == '\0') 
66                         break;
67         }
68         while (++icol < ncol)
69                 table[0][icol].col = "";
70         putline(useln, 0);
71         exstore = exspace;               /* reuse space for numerical items */
72         return(1);
73 }
74
75