|
|
1.1 root 1: /* t8.c: write out one line of output table */
2: # include "t..c"
3: # define realsplit ((ct=='a'||ct=='n') && table[nl][c].rcol)
4: int watchout;
5: int once;
6: putline(i, nl)
7: /* i is line number for deciding format */
8: /* nl is line number for finding data usually identical */
9: {
10: int c, lf, ct, form, lwid, vspf, ip, cmidx, exvspen, vforml;
11: int vct, chfont, uphalf;
12: char *s, *size, *fn;
13: cmidx=watchout=vspf=exvspen=0;
14: if (i==0) once=0;
15: if (i==0 && ( allflg || boxflg || dboxflg))
16: fullwide(0, dboxflg? '=' : '-');
17: if (instead[nl]==0 && fullbot[nl] ==0)
18: for(c=0; c<ncol; c++)
19: {
20: s = table[nl][c].col;
21: if (s==0) continue;
22: if (vspen(s))
23: {
24: for(ip=nl; ip<nlin; ip=next(ip))
25: if (!vspen(s=table[ip][c].col)) break;
26: if ((int)s>0 && (int)s<128)
27: fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n",s);
28: continue;
29: }
30: if (point(s)) continue;
31: fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n",s);
32: watchout=1;
33: }
34: if (linestop[nl])
35: fprintf(tabout, ".mk #%c\n", linestop[nl]+'a'-1);
36: lf = prev(nl);
37: if (instead[nl])
38: {
39: puts(instead[nl]);
40: return;
41: }
42: if (fullbot[nl])
43: {
44: switch (ct=fullbot[nl])
45: {
46: case '=':
47: case '-':
48: fullwide(nl,ct);
49: }
50: return;
51: }
52: for(c=0; c<ncol; c++)
53: {
54: if (instead[nl]==0 && fullbot[nl]==0)
55: if (vspen(table[nl][c].col)) vspf=1;
56: if (lf>=0)
57: if (vspen(table[lf][c].col)) vspf=1;
58: }
59: if (vspf)
60: {
61: fprintf(tabout, ".nr #^ \\n(\\*(#du\n");
62: fprintf(tabout, ".nr #- \\n(#^\n"); /* current line position relative to bottom */
63: }
64: vspf=0;
65: chfont=0;
66: for(c=0; c<ncol; c++)
67: {
68: s = table[nl][c].col;
69: if (s==0) continue;
70: chfont |= (int)(font[c][stynum[nl]]);
71: if (point(s) ) continue;
72: lf=prev(nl);
73: if (lf>=0 && vspen(table[lf][c].col))
74: fprintf(tabout, ".if (\\n(%c|+\\n(^%c-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(^%c-\\n(#--1v)\n",s,'a'+c,s,'a'+c);
75: else
76: fprintf(tabout, ".if (\\n(%c|+\\n(#^-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(#^-\\n(#--1v)\n",s,s);
77: }
78: if (allflg && once>0 )
79: fullwide(i,'-');
80: once=1;
81: runtabs(i, nl);
82: if (allh(i) && !pr1403)
83: {
84: fprintf(tabout, ".nr %d \\n(.v\n", SVS);
85: fprintf(tabout, ".vs \\n(.vu-\\n(.sp\n");
86: fprintf(tabout, ".nr 35 \\n(.vu\n");
87: }
88: else
89: fprintf(tabout, ".nr 35 1m\n");
90: if (chfont)
91: fprintf(tabout, ".nr %2d \\n(.f\n", S1);
92: fprintf(tabout, "\\&");
93: vct = 0;
94: for(c=0; c<ncol; c++)
95: {
96: uphalf=0;
97: if (watchout==0 && i+1<nlin && (lf=left(i,c, &lwid))>=0)
98: {
99: tohcol(c);
100: drawvert(lf, i, c, lwid);
101: vct += 2;
102: }
103: if (rightl && c+1==ncol) continue;
104: vforml=i;
105: for(lf=prev(nl); lf>=0 && vspen(table[lf][c].col); lf=prev(lf))
106: vforml= lf;
107: form= ctype(vforml,c);
108: if (form != 's')
109: {
110: ct = reg(c,CLEFT);
111: if (form=='a') ct = reg(c,CMID);
112: if (form=='n' && table[nl][c].rcol && lused[c]==0) ct= reg(c,CMID);
113: fprintf(tabout, "\\h'|\\n(%2su'", ct);
114: }
115: s= table[nl][c].col;
116: fn = font[c][stynum[vforml]];
117: size = csize[c][stynum[vforml]];
118: if (*size==0)size=0;
119: if ((flags[c][stynum[nl]] & HALFUP)!=0 && pr1403 == 0)
120: uphalf=1;
121: switch(ct=ctype(vforml, c))
122: {
123: case 'n':
124: case 'a':
125: if (table[nl][c].rcol)
126: {
127: if (lused[c]) /*Zero field width*/
128: {
129: ip = prev(nl);
130: if (ip>=0)
131: if (vspen(table[ip][c].col))
132: {
133: if (exvspen==0)
134: {
135: fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c+'a');
136: if (cmidx)
137: fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a');
138: vct++;
139: if (pr1403) /* must round to whole lines */
140: fprintf(tabout, "/1v*1v");
141: fprintf(tabout, "'");
142: exvspen=1;
143: }
144: }
145: fprintf(tabout, "%c%c",F1,F2);
146: if (uphalf) fprintf(tabout, "\\u");
147: puttext(s,fn,size);
148: if (uphalf) fprintf(tabout, "\\d");
149: fprintf(tabout, "%c",F1);
150: }
151: s= table[nl][c].rcol;
152: form=1;
153: break;
154: }
155: case 'c':
156: form=3; break;
157: case 'r':
158: form=2; break;
159: case 'l':
160: form=1; break;
161: case '-':
162: case '=':
163: if (real(table[nl][c].col))
164: fprintf(stderr,"%s: line %d: Data ignored on table line %d\n", ifile, iline-1, i+1);
165: makeline(i,c,ct);
166: continue;
167: default:
168: continue;
169: }
170: if (realsplit ? rused[c]: used[c]) /*Zero field width*/
171: {
172: /* form: 1 left, 2 right, 3 center adjust */
173: if (ifline(s))
174: {
175: makeline(i,c,ifline(s));
176: continue;
177: }
178: if (filler(s))
179: {
180: fprintf(tabout, "\\l'|\\n(%2su\\&%s'", reg(c,CRIGHT), s+2);
181: continue;
182: }
183: ip = prev(nl);
184: cmidx = (flags[c][stynum[nl]] & (CTOP|CDOWN))==0;
185: if (ip>=0)
186: if (vspen(table[ip][c].col))
187: {
188: if (exvspen==0)
189: {
190: fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c+'a');
191: if (cmidx)
192: fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a');
193: vct++;
194: if (pr1403) /* round to whole lines */
195: fprintf(tabout, "/1v*1v");
196: fprintf(tabout, "'");
197: }
198: }
199: fprintf(tabout, "%c", F1);
200: if (form!= 1)
201: fprintf(tabout, "%c", F2);
202: if (vspen(s))
203: vspf=1;
204: else
205: {
206: if (uphalf) fprintf(tabout, "\\u");
207: puttext(s, fn, size);
208: if (uphalf) fprintf(tabout, "\\d");
209: }
210: if (form !=2)
211: fprintf(tabout, "%c", F2);
212: fprintf(tabout, "%c", F1);
213: }
214: ip = prev(nl);
215: if (ip>=0)
216: if (vspen(table[ip][c].col))
217: {
218: exvspen = (c+1 < ncol) && vspen(table[ip][c+1].col) &&
219: (topat[c] == topat[c+1]) &&
220: (cmidx == (flags[c+1] [stynum[nl]]&(CTOP|CDOWN)==0)) && (left(i,c+1,&lwid)<0);
221: if (exvspen==0)
222: {
223: fprintf(tabout, "\\v'(\\n(\\*(#du-\\n(^%cu", c+'a');
224: if (cmidx)
225: fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a');
226: vct++;
227: if (pr1403) /* round to whole lines */
228: fprintf(tabout, "/1v*1v");
229: fprintf(tabout, "'");
230: }
231: }
232: else
233: exvspen=0;
234: /* if lines need to be split for gcos here is the place for a backslash */
235: if (vct > 7 && c < ncol)
236: {
237: fprintf(tabout, "\n.sp-1\n\\&");
238: vct=0;
239: }
240: }
241: fprintf(tabout, "\n");
242: if (allh(i) && !pr1403) fprintf(tabout, ".vs \\n(%du\n", SVS);
243: if (watchout)
244: funnies(i,nl);
245: if (vspf)
246: {
247: for(c=0; c<ncol; c++)
248: if (vspen(table[nl][c].col) && (nl==0 || (lf=prev(nl))<0 || !vspen(table[lf][c].col)))
249: {
250: fprintf(tabout, ".nr ^%c \\n(#^u\n", 'a'+c);
251: topat[c]=nl;
252: }
253: }
254: }
255: puttext(s,fn, size)
256: char *s, *size, *fn;
257: {
258: if (point(s))
259: {
260: putfont(fn);
261: putsize(size);
262: fprintf(tabout, "%s",s);
263: if (*fn>0) fprintf(tabout, "\\f\\n(%2d", S1);
264: if (size!=0) putsize("0");
265: }
266: }
267: funnies( stl, lin)
268: {
269: /* write out funny diverted things */
270: int c, s, pl, lwid, dv, lf, ct;
271: char *fn;
272: fprintf(tabout, ".mk ##\n"); /* rmember current vertical position */
273: fprintf(tabout, ".nr %d \\n(##\n", S1); /* bottom position */
274: for(c=0; c<ncol; c++)
275: {
276: s = (int)table[lin][c].col;
277: if (point(s)) continue;
278: if (s==0) continue;
279: fprintf(tabout, ".sp |\\n(##u-1v\n");
280: fprintf(tabout, ".nr %d ", SIND);
281: for(pl=stl; pl>=0 && !isalpha(ct=ctype(pl,c)); pl=prev(pl))
282: ;
283: switch (ct)
284: {
285: case 'n':
286: case 'c':
287: fprintf(tabout, "(\\n(%2su+\\n(%2su-\\n(%c-u)/2u\n",reg(c,CLEFT),reg(c-1+ctspan(lin,c),CRIGHT), s);
288: break;
289: case 'l':
290: fprintf(tabout, "\\n(%2su\n",reg(c,CLEFT));
291: break;
292: case 'a':
293: fprintf(tabout, "\\n(%2su\n",reg(c,CMID));
294: break;
295: case 'r':
296: fprintf(tabout, "\\n(%2su-\\n(%c-u\n", reg(c,CRIGHT), s);
297: break;
298: }
299: fprintf(tabout, ".in +\\n(%du\n", SIND);
300: fn=font[c][stynum[stl]];
301: putfont(fn);
302: pl = prev(stl);
303: if (stl>0 && pl>=0 && vspen(table[pl][c].col))
304: {
305: fprintf(tabout, ".sp |\\n(^%cu\n", 'a'+c);
306: if ((flags[c][stynum[stl]]&(CTOP|CDOWN))==0)
307: {
308: fprintf(tabout, ".nr %d \\n(#-u-\\n(^%c-\\n(%c|+1v\n",TMP, 'a'+c, s);
309: fprintf(tabout, ".if \\n(%d>0 .sp \\n(%du/2u", TMP, TMP);
310: if (pr1403) /* round */
311: fprintf(tabout, "/1v*1v");
312: fprintf(tabout, "\n");
313: }
314: }
315: fprintf(tabout, ".%c+\n",s);
316: fprintf(tabout, ".in -\\n(%du\n", SIND);
317: if (*fn>0) putfont("P");
318: fprintf(tabout, ".mk %d\n", S2);
319: fprintf(tabout, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n", S2, S1, S1, S2);
320: }
321: fprintf(tabout, ".sp |\\n(%du\n", S1);
322: for(c=dv=0; c<ncol; c++)
323: {
324: if (stl+1< nlin && (lf=left(stl,c,&lwid))>=0)
325: {
326: if (dv++ == 0)
327: fprintf(tabout, ".sp -1\n");
328: tohcol(c);
329: dv++;
330: drawvert(lf, stl, c, lwid);
331: }
332: }
333: if (dv)
334: fprintf(tabout,"\n");
335: }
336: putfont(fn)
337: char *fn;
338: {
339: if (fn && *fn)
340: fprintf(tabout, fn[1] ? "\\f(%.2s" : "\\f%.2s", fn);
341: }
342: putsize(s)
343: char *s;
344: {
345: if (s && *s)
346: fprintf(tabout, "\\s%s",s);
347: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.