aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/tbl/t9.c
blob: 379126d2103231937ad35620b4d05a57af470efb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* t9.c: write lines for tables over 200 lines */
# include "t.h"
static int useln;

void
yetmore(void)
{
	for (useln = 0; useln < MAXLIN && table[useln] == 0; useln++)
		;
	if (useln >= MAXLIN)
		error("Wierd.  No data in table.");
	table[0] = table[useln];
	for (useln = nlin - 1; useln >= 0 && (fullbot[useln] || instead[useln]); useln--)
		;
	if (useln < 0)
		error("Wierd.  No real lines in table.");
	domore(leftover);
	while (gets1(cstore = cspace, MAXCHS) && domore(cstore))
		;
	last = cstore;
	return;
}


int
domore(char *dataln)
{
	int	icol, ch;

	if (prefix(".TE", dataln))
		return(0);
	if (dataln[0] == '.' && !isdigit(dataln[1])) {
		Bprint(&tabout, "%s\n", dataln);
		return(1);
	}
	fullbot[0] = 0;
	instead[0] = (char *)0;
	if (dataln[1] == 0)
		switch (dataln[0]) {
		case '_': 
			fullbot[0] = '-'; 
			putline(useln, 0);  
			return(1);
		case '=': 
			fullbot[0] = '='; 
			putline(useln, 0); 
			return(1);
		}
	for (icol = 0; icol < ncol; icol++) {
		table[0][icol].col = dataln;
		table[0][icol].rcol = 0;
		for (; (ch = *dataln) != '\0' && ch != tab; dataln++)
			;
		*dataln++ = '\0';
		switch (ctype(useln, icol)) {
		case 'n':
			table[0][icol].rcol = maknew(table[0][icol].col);
			break;
		case 'a':
			table[0][icol].rcol = table[0][icol].col;
			table[0][icol].col = "";
			break;
		}
		while (ctype(useln, icol + 1) == 's') /* spanning */
			table[0][++icol].col = "";
		if (ch == '\0') 
			break;
	}
	while (++icol < ncol)
		table[0][icol].col = "";
	putline(useln, 0);
	exstore = exspace;		 /* reuse space for numerical items */
	return(1);
}