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