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 fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n", (int)s);
36 fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n", (int)s);
40 fprintf(tabout, ".mk #%c\n", linestop[nl] + 'a' - 1);
43 fprintf(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 fprintf(tabout, ".nr #^ \\n(\\*(#du\n");
64 fprintf(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 fprintf(tabout, ".nr %d \\n(.v\n", SVS);
91 fprintf(tabout, ".vs \\n(.vu-\\n(.sp\n");
92 fprintf(tabout, ".nr 35 \\n(.vu\n");
94 fprintf(tabout, ".nr 35 1m\n");
96 fprintf(tabout, ".nr %2d \\n(.f\n", S1);
97 fprintf(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 fprintf(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 fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c + 'a');
138 /* code folded from here */
139 fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c + 'a');
142 if (pr1403) /* must round to whole lines */
143 /* code folded from here */
144 fprintf(tabout, "/1v*1v");
146 fprintf(tabout, "'");
150 fprintf(tabout, "%c%c", F1, F2);
152 fprintf(tabout, "\\u");
153 puttext(s, fn, size);
155 fprintf(tabout, "\\d");
156 fprintf(tabout, "%c", F1);
158 s = table[nl][c].rcol;
173 if (real(table[nl][c].col))
174 fprintf(stderr, "%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 fprintf(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 fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c + 'a');
197 fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c + 'a');
199 if (pr1403) /* round to whole lines */
200 fprintf(tabout, "/1v*1v");
201 fprintf(tabout, "'");
204 fprintf(tabout, "%c", F1);
206 fprintf(tabout, "%c", F2);
212 fprintf(tabout, "\\u");
213 puttext(s, fn, size);
215 fprintf(tabout, "\\d");
218 fprintf(tabout, "%c", F2);
219 fprintf(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 fprintf(tabout, "\\v'(\\n(\\*(#du-\\n(^%cu", c + 'a');
231 fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c + 'a');
233 if (pr1403) /* round to whole lines */
234 fprintf(tabout, "/1v*1v");
235 fprintf(tabout, "'");
241 /* if lines need to be split for gcos here is the place for a backslash */
242 if (vct > 7 && c < ncol) {
243 fprintf(tabout, "\n.sp-1\n\\&");
247 fprintf(tabout, "\n");
248 if (allh(i) && !pr1403)
249 fprintf(tabout, ".vs \\n(%du\n", SVS);
253 for (c = 0; c < ncol; c++)
254 if (vspen(table[nl][c].col) && (nl == 0 || (lf = prev(nl)) < 0 ||
255 !vspen(table[lf][c].col))) {
256 fprintf(tabout, ".nr ^%c \\n(#^u\n", 'a' + c);
264 puttext(char *s, char *fn, char *size)
269 fprintf(tabout, "%s", s);
271 fprintf(tabout, "\\f\\n(%2d", S1);
279 funnies(int stl, int lin)
281 /* write out funny diverted things */
282 int c, s, pl, lwid, dv, lf, ct;
285 fprintf(tabout, ".mk ##\n"); /* rmember current vertical position */
286 fprintf(tabout, ".nr %d \\n(##\n", S1); /* bottom position */
287 for (c = 0; c < ncol; c++) {
288 ss = table[lin][c].col;
294 fprintf(tabout, ".sp |\\n(##u-1v\n");
295 fprintf(tabout, ".nr %d ", SIND);
297 for (pl = stl; pl >= 0 && !isalpha(ct = ctype(pl, c)); pl = prev(pl))
302 fprintf(tabout, "(\\n(%2su+\\n(%2su-\\n(%c-u)/2u\n", reg(c, CLEFT),
303 reg(c - 1 + ctspan(lin, c), CRIGHT),
307 fprintf(tabout, "\\n(%2su\n", reg(c, CLEFT));
310 fprintf(tabout, "\\n(%2su\n", reg(c, CMID));
313 fprintf(tabout, "\\n(%2su-\\n(%c-u\n", reg(c, CRIGHT), s);
316 fprintf(tabout, ".in +\\n(%du\n", SIND);
317 fn = font[c][stynum[stl]];
320 if (stl > 0 && pl >= 0 && vspen(table[pl][c].col)) {
321 fprintf(tabout, ".sp |\\n(^%cu\n", 'a' + c);
322 if ((flags[c][stynum[stl]] & (CTOP | CDOWN)) == 0) {
323 fprintf(tabout, ".nr %d \\n(#-u-\\n(^%c-\\n(%c|+1v\n",
325 fprintf(tabout, ".if \\n(%d>0 .sp \\n(%du/2u", TMP, TMP);
326 if (pr1403) /* round */
327 fprintf(tabout, "/1v*1v");
328 fprintf(tabout, "\n");
331 fprintf(tabout, ".%c+\n", s);
332 fprintf(tabout, ".in -\\n(%du\n", SIND);
335 fprintf(tabout, ".mk %d\n", S2);
336 fprintf(tabout, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n", S2, S1, S1, S2);
338 fprintf(tabout, ".sp |\\n(%du\n", S1);
339 for (c = dv = 0; c < ncol; c++) {
340 if (stl + 1 < nlin && (lf = left(stl, c, &lwid)) >= 0) {
342 fprintf(tabout, ".sp -1\n");
345 drawvert(lf, stl, c, lwid);
349 fprintf(tabout, "\n");
357 fprintf(tabout, fn[1] ? "\\f(%.2s" : "\\f%.2s", fn);
365 fprintf(tabout, "\\s%s", s);