added type-rename operator
[unix-history] / usr / src / old / tbl / t7.c
CommitLineData
31dcd0af 1/* t7.c 4.2 83/02/12 */
bf37f301
BS
2
3 /* t7.c: control to write table entries */
4# include "t..c"
5# define realsplit ((ct=='a'||ct=='n') && table[ldata][c].rcol)
6runout()
7{
8int i;
9if (boxflg || allflg || dboxflg) need();
10if (ctrflg)
11 {
12 fprintf(tabout, ".nr #I \\n(.i\n");
13 fprintf(tabout, ".in +(\\n(.lu-\\n(TWu-\\n(.iu)/2u\n");
14 }
15fprintf(tabout, ".fc %c %c\n", F1, F2);
16fprintf(tabout, ".nr #T 0-1\n");
17deftail();
18for(i=0; i<nlin; i++)
19 putline(i,i);
20if (leftover)
21 yetmore();
22fprintf(tabout, ".fc\n");
23fprintf(tabout, ".nr T. 1\n");
24fprintf(tabout, ".T# 1\n");
25if (ctrflg)
26 fprintf(tabout, ".in \\n(#Iu\n");
27}
28runtabs(lform, ldata)
29{
30int c, ct, vforml, lf;
31fprintf(tabout, ".ta ");
32for(c=0; c<ncol; c++)
33 {
34 vforml=lform;
35 for(lf=prev(lform); lf>=0 && vspen(table[lf][c].col); lf=prev(lf))
36 vforml=lf;
37 if (fspan(vforml,c))
38 continue;
39 switch(ct=ctype(vforml,c))
40 {
41 case 'n':
42 case 'a':
43 if (table[ldata][c].rcol)
44 if (lused[c]) /*Zero field width*/
45 fprintf(tabout, "\\n(%du ",c+CMID);
46 case 'c':
47 case 'l':
48 case 'r':
49 if (realsplit? rused[c]: (used[c]+lused[c]))
50 fprintf(tabout, "\\n(%du ",c+CRIGHT);
51 continue;
52 case 's':
53 if (lspan(lform, c))
54 fprintf(tabout, "\\n(%du ", c+CRIGHT);
55 continue;
56 }
57 }
58fprintf(tabout, "\n");
59}
60ifline(s)
61 char *s;
62{
31dcd0af 63if (!point(s)) return(0);
bf37f301
BS
64if (s[0] == '\\') s++;
65if (s[1] ) return(0);
66if (s[0] == '_') return('-');
67if (s[0] == '=') return('=');
68return(0);
69}
70need()
71{
72int texlin, horlin, i;
73for(texlin=horlin=i=0; i<nlin; i++)
74 {
75 if (fullbot[i]!=0)
76 horlin++;
77 else
78 if (instead[i]!=0)
79 continue;
80 else
81 texlin++;
82 }
83fprintf(tabout, ".ne %dv+%dp\n",texlin,2*horlin);
84}
85deftail()
86{
87int i, c, lf, lwid;
88for(i=0; i<MAXHEAD; i++)
89 if (linestop[i])
90 fprintf(tabout, ".nr #%c 0-1\n", linestop[i]+'a'-1);
91fprintf(tabout, ".nr #a 0-1\n");
92fprintf(tabout, ".eo\n");
93fprintf(tabout, ".de T#\n");
94fprintf(tabout, ".ds #d .d\n");
95fprintf(tabout, ".if \\(ts\\n(.z\\(ts\\(ts .ds #d nl\n");
96 fprintf(tabout, ".mk ##\n");
97 fprintf(tabout, ".nr ## -1v\n");
98 fprintf(tabout, ".ls 1\n");
99 for(i=0; i<MAXHEAD; i++)
100 if (linestop[i])
101 fprintf(tabout, ".if \\n(#T>=0 .nr #%c \\n(#T\n",linestop[i]+'a'-1);
102if (boxflg || allflg || dboxflg) /* bottom of table line */
103 if (fullbot[nlin-1]==0)
104 {
105 if (!pr1403)
106 fprintf(tabout, ".if \\n(T. .vs \\n(.vu-\\n(.sp\n");
107 fprintf(tabout, ".if \\n(T. ");
108 drawline(nlin,0,ncol, dboxflg ? '=' : '-',1,0);
109 fprintf(tabout, "\n.if \\n(T. .vs\n");
110 /* T. is really an argument to a macro but because of
111 eqn we don't dare pass it as an argument and reference by $1 */
112 }
113 for(c=0; c<ncol; c++)
114 {
115 if ((lf=left(nlin-1,c, &lwid))>=0)
116 {
117 fprintf(tabout, ".if \\n(#%c>=0 .sp -1\n",linestop[lf]+'a'-1);
118 fprintf(tabout, ".if \\n(#%c>=0 ", linestop[lf]+'a'-1);
119 tohcol(c);
120 drawvert(lf, nlin-1, c, lwid);
121 fprintf(tabout, "\\h'|\\n(TWu'\n");
122 }
123 }
124 if (boxflg || allflg || dboxflg) /* right hand line */
125 {
126 fprintf(tabout, ".if \\n(#a>=0 .sp -1\n");
127 fprintf(tabout, ".if \\n(#a>=0 \\h'|\\n(TWu'");
128 drawvert (0, nlin-1, ncol, dboxflg? 2 : 1);
129 fprintf(tabout, "\n");
130 }
131fprintf(tabout, ".ls\n");
132fprintf(tabout, "..\n");
133fprintf(tabout, ".ec\n");
134}