1 /* t8.c: write out one line of output table */
3 # define realsplit ((ct=='a'||ct=='n') && table[nl][c].rcol)
9 /* i is line number for deciding format */
10 /* nl is line number for finding data usually identical */
12 int c, lf, ct, form, lwid, vspf, ip, cmidx, exvspen, vforml;
13 int vct, chfont, uphalf;
14 char *s, *size, *fn, *rct;
16 cmidx = watchout = vspf = exvspen = 0;
19 if (i == 0 && ( allflg || boxflg || dboxflg))
20 fullwide(0, dboxflg ? '=' : '-');
21 if (instead[nl] == 0 && fullbot[nl] == 0)
22 for (c = 0; c < ncol; c++) {
27 for (ip = nl; ip < nlin; ip = next(ip))
28 if (!vspen(s = table[ip][c].col))
30 if ((int)s > 0 && (int)s < 128)
31 Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", (int)s);
36 Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", (int)s);
40 Bprint(&tabout, ".mk #%c\n", linestop[nl] + 'a' - 1);
43 Bprint(&tabout, "%s\n", instead[nl]);
47 switch (ct = fullbot[nl]) {
54 for (c = 0; c < ncol; c++) {
55 if (instead[nl] == 0 && fullbot[nl] == 0)
56 if (vspen(table[nl][c].col))
59 if (vspen(table[lf][c].col))
63 Bprint(&tabout, ".nr #^ \\n(\\*(#du\n");
64 Bprint(&tabout, ".nr #- \\n(#^\n"); /* current line position relative to bottom */
68 for (c = 0; c < ncol; c++) {
72 chfont |= (int)(font[c][stynum[nl]]);
76 if (lf >= 0 && vspen(table[lf][c].col))
78 ".if (\\n(%c|+\\n(^%c-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(^%c-\\n(#--1v)\n",
79 (int)s, 'a' + c, (int)s, 'a' + c);
82 ".if (\\n(%c|+\\n(#^-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(#^-\\n(#--1v)\n",
85 if (allflg && once > 0 )
89 if (allh(i) && !pr1403) {
90 Bprint(&tabout, ".nr %d \\n(.v\n", SVS);
91 Bprint(&tabout, ".vs \\n(.vu-\\n(.sp\n");
92 Bprint(&tabout, ".nr 35 \\n(.vu\n");
94 Bprint(&tabout, ".nr 35 1m\n");
96 Bprint(&tabout, ".nr %2d \\n(.f\n", S1);
97 Bprint(&tabout, "\\&");
99 for (c = 0; c < ncol; c++) {
101 if (watchout == 0 && i + 1 < nlin && (lf = left(i, c, &lwid)) >= 0) {
103 drawvert(lf, i, c, lwid);
106 if (rightl && c + 1 == ncol)
109 for (lf = prev(nl); lf >= 0 && vspen(table[lf][c].col); lf = prev(lf))
111 form = ctype(vforml, c);
116 if (form == 'n' && table[nl][c].rcol && lused[c] == 0)
118 Bprint(&tabout, "\\h'|\\n(%2su'", rct);
120 s = table[nl][c].col;
121 fn = font[c][stynum[vforml]];
122 size = csize[c][stynum[vforml]];
125 if ((flags[c][stynum[nl]] & HALFUP) != 0 && pr1403 == 0)
127 switch (ct = ctype(vforml, c)) {
130 if (table[nl][c].rcol) {
131 if (lused[c]) /*Zero field width*/ {
134 if (vspen(table[ip][c].col)) {
136 Bprint(&tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c + 'a');
138 /* code folded from here */
139 Bprint(&tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c + 'a');
142 if (pr1403) /* must round to whole lines */
143 /* code folded from here */
144 Bprint(&tabout, "/1v*1v");
146 Bprint(&tabout, "'");
150 Bprint(&tabout, "%c%c", F1, F2);
152 Bprint(&tabout, "\\u");
153 puttext(s, fn, size);
155 Bprint(&tabout, "\\d");
156 Bprint(&tabout, "%c", F1);
158 s = table[nl][c].rcol;
173 if (real(table[nl][c].col))
174 fprint(2, "%s: line %d: Data ignored on table line %d\n", ifile, iline - 1, i + 1);
180 if (realsplit ? rused[c] : used[c]) /*Zero field width*/ {
181 /* form: 1 left, 2 right, 3 center adjust */
183 makeline(i, c, ifline(s));
187 Bprint(&tabout, "\\l'|\\n(%2su\\&%s'", reg(c, CRIGHT), s + 2);
191 cmidx = (flags[c][stynum[nl]] & (CTOP | CDOWN)) == 0;
193 if (vspen(table[ip][c].col)) {
195 Bprint(&tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c + 'a');
197 Bprint(&tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c + 'a');
199 if (pr1403) /* round to whole lines */
200 Bprint(&tabout, "/1v*1v");
201 Bprint(&tabout, "'");
204 Bprint(&tabout, "%c", F1);
206 Bprint(&tabout, "%c", F2);
212 Bprint(&tabout, "\\u");
213 puttext(s, fn, size);
215 Bprint(&tabout, "\\d");
218 Bprint(&tabout, "%c", F2);
219 Bprint(&tabout, "%c", F1);
223 if (vspen(table[ip][c].col)) {
224 exvspen = (c + 1 < ncol) && vspen(table[ip][c+1].col) &&
225 (topat[c] == topat[c+1]) &&
226 (cmidx == (flags[c+1] [stynum[nl]] & (CTOP | CDOWN) == 0))
227 && (left(i, c + 1, &lwid) < 0);
229 Bprint(&tabout, "\\v'(\\n(\\*(#du-\\n(^%cu", c + 'a');
231 Bprint(&tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c + 'a');
233 if (pr1403) /* round to whole lines */
234 Bprint(&tabout, "/1v*1v");
235 Bprint(&tabout, "'");
240 /* if lines need to be split for gcos here is the place for a backslash */
241 if (vct > 7 && c < ncol) {
242 Bprint(&tabout, "\n.sp-1\n\\&");
246 Bprint(&tabout, "\n");
247 if (allh(i) && !pr1403)
248 Bprint(&tabout, ".vs \\n(%du\n", SVS);
252 for (c = 0; c < ncol; c++)
253 if (vspen(table[nl][c].col) && (nl == 0 || (lf = prev(nl)) < 0 ||
254 !vspen(table[lf][c].col))) {
255 Bprint(&tabout, ".nr ^%c \\n(#^u\n", 'a' + c);
263 puttext(char *s, char *fn, char *size)
268 Bprint(&tabout, "%s", s);
270 Bprint(&tabout, "\\f\\n(%2d", S1);
278 funnies(int stl, int lin)
280 /* write out funny diverted things */
281 int c, s, pl, lwid, dv, lf, ct;
284 Bprint(&tabout, ".mk ##\n"); /* rmember current vertical position */
285 Bprint(&tabout, ".nr %d \\n(##\n", S1); /* bottom position */
286 for (c = 0; c < ncol; c++) {
287 ss = table[lin][c].col;
293 Bprint(&tabout, ".sp |\\n(##u-1v\n");
294 Bprint(&tabout, ".nr %d ", SIND);
296 for (pl = stl; pl >= 0 && !isalpha(ct = ctype(pl, c)); pl = prev(pl))
301 Bprint(&tabout, "(\\n(%2su+\\n(%2su-\\n(%c-u)/2u\n", reg(c, CLEFT),
302 reg(c - 1 + ctspan(lin, c), CRIGHT),
306 Bprint(&tabout, "\\n(%2su\n", reg(c, CLEFT));
309 Bprint(&tabout, "\\n(%2su\n", reg(c, CMID));
312 Bprint(&tabout, "\\n(%2su-\\n(%c-u\n", reg(c, CRIGHT), s);
315 Bprint(&tabout, ".in +\\n(%du\n", SIND);
316 fn = font[c][stynum[stl]];
319 if (stl > 0 && pl >= 0 && vspen(table[pl][c].col)) {
320 Bprint(&tabout, ".sp |\\n(^%cu\n", 'a' + c);
321 if ((flags[c][stynum[stl]] & (CTOP | CDOWN)) == 0) {
322 Bprint(&tabout, ".nr %d \\n(#-u-\\n(^%c-\\n(%c|+1v\n",
324 Bprint(&tabout, ".if \\n(%d>0 .sp \\n(%du/2u", TMP, TMP);
325 if (pr1403) /* round */
326 Bprint(&tabout, "/1v*1v");
327 Bprint(&tabout, "\n");
330 Bprint(&tabout, ".%c+\n", s);
331 Bprint(&tabout, ".in -\\n(%du\n", SIND);
334 Bprint(&tabout, ".mk %d\n", S2);
335 Bprint(&tabout, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n", S2, S1, S1, S2);
337 Bprint(&tabout, ".sp |\\n(%du\n", S1);
338 for (c = dv = 0; c < ncol; c++) {
339 if (stl + 1 < nlin && (lf = left(stl, c, &lwid)) >= 0) {
341 Bprint(&tabout, ".sp -1\n");
344 drawvert(lf, stl, c, lwid);
348 Bprint(&tabout, "\n");
356 Bprint(&tabout, fn[1] ? "\\f(%.2s" : "\\f%.2s", fn);
364 Bprint(&tabout, "\\s%s", s);