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