xref: /titanic_52/usr/src/cmd/tbl/t8.c (revision b55148877d473978f0b46d593fd6213fa526fcc5)
1*b5514887Smuffin /*
2*b5514887Smuffin  * Copyright 1996 Sun Microsystems, Inc.  All rights reserved.
3*b5514887Smuffin  * Use is subject to license terms.
4*b5514887Smuffin  */
5*b5514887Smuffin 
67c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
77c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
87c478bd9Sstevel@tonic-gate 
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
117c478bd9Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
127c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
137c478bd9Sstevel@tonic-gate  */
147c478bd9Sstevel@tonic-gate 
15*b5514887Smuffin #pragma ident	"%Z%%M%	%I%	%E% SMI"
167c478bd9Sstevel@tonic-gate 
177c478bd9Sstevel@tonic-gate  /* t8.c: write out one line of output table */
187c478bd9Sstevel@tonic-gate # include "t..c"
197c478bd9Sstevel@tonic-gate # include <locale.h>
207c478bd9Sstevel@tonic-gate # define realsplit ((ct=='a'||ct=='n') && table[nl][c].rcol)
21*b5514887Smuffin 
227c478bd9Sstevel@tonic-gate int watchout;
237c478bd9Sstevel@tonic-gate int once;
247c478bd9Sstevel@tonic-gate int topat[MAXCOL];
25*b5514887Smuffin 
26*b5514887Smuffin void	puttext(char *, char *, char *);
27*b5514887Smuffin void	funnies(int, int);
28*b5514887Smuffin void	putfont(char *);
29*b5514887Smuffin void	putsize(char *);
30*b5514887Smuffin 
31*b5514887Smuffin /*
32*b5514887Smuffin  * parameters
33*b5514887Smuffin  *
34*b5514887Smuffin  * i:	line number for deciding format
35*b5514887Smuffin  * nl:	line number for finding data   usually identical
36*b5514887Smuffin  */
37*b5514887Smuffin void
38*b5514887Smuffin putline(int i, int nl)
397c478bd9Sstevel@tonic-gate {
407c478bd9Sstevel@tonic-gate int c, lf, ct, form, lwid, vspf, ip = -1, cmidx, exvspen, vforml;
417c478bd9Sstevel@tonic-gate int vct, chfont;
427c478bd9Sstevel@tonic-gate char *s, *size, *fn;
437c478bd9Sstevel@tonic-gate watchout=vspf=exvspen=0;
447c478bd9Sstevel@tonic-gate if (i==0) once=0;
457c478bd9Sstevel@tonic-gate if (i==0 && ( allflg || boxflg || dboxflg))
467c478bd9Sstevel@tonic-gate 	fullwide(0,   dboxflg? '=' : '-');
477c478bd9Sstevel@tonic-gate if (instead[nl]==0 && fullbot[nl] ==0)
487c478bd9Sstevel@tonic-gate for(c=0; c<ncol; c++)
497c478bd9Sstevel@tonic-gate 	{
507c478bd9Sstevel@tonic-gate 	s = table[nl][c].col;
517c478bd9Sstevel@tonic-gate 	if (s==0) continue;
527c478bd9Sstevel@tonic-gate 	if (vspen(s))
537c478bd9Sstevel@tonic-gate 		{
547c478bd9Sstevel@tonic-gate 		for(ip=nl; ip<nlin; ip=next(ip))
557c478bd9Sstevel@tonic-gate 			if (!vspen(s=table[ip][c].col)) break;
567c478bd9Sstevel@tonic-gate 		if (s>(char *)0 && s<(char *)128)
577c478bd9Sstevel@tonic-gate 		fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n",s);
587c478bd9Sstevel@tonic-gate 		continue;
597c478bd9Sstevel@tonic-gate 		}
607c478bd9Sstevel@tonic-gate 	if (point(s)) continue;
617c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n",s);
627c478bd9Sstevel@tonic-gate 	watchout=1;
637c478bd9Sstevel@tonic-gate 	}
647c478bd9Sstevel@tonic-gate if (linestop[nl])
657c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".mk #%c\n", linestop[nl]+'a'-1);
667c478bd9Sstevel@tonic-gate lf = prev(nl);
677c478bd9Sstevel@tonic-gate if (instead[nl])
687c478bd9Sstevel@tonic-gate 	{
697c478bd9Sstevel@tonic-gate 	puts(instead[nl]);
707c478bd9Sstevel@tonic-gate 	return;
717c478bd9Sstevel@tonic-gate 	}
727c478bd9Sstevel@tonic-gate if (fullbot[nl])
737c478bd9Sstevel@tonic-gate 	{
747c478bd9Sstevel@tonic-gate 	switch (ct=fullbot[nl])
757c478bd9Sstevel@tonic-gate 		{
767c478bd9Sstevel@tonic-gate 		case '=':
777c478bd9Sstevel@tonic-gate 		case '-':
787c478bd9Sstevel@tonic-gate 			fullwide(nl,ct);
797c478bd9Sstevel@tonic-gate 		}
807c478bd9Sstevel@tonic-gate 	return;
817c478bd9Sstevel@tonic-gate 	}
827c478bd9Sstevel@tonic-gate for(c=0; c<ncol; c++)
837c478bd9Sstevel@tonic-gate 	{
847c478bd9Sstevel@tonic-gate 	if (instead[nl]==0 && fullbot[nl]==0)
857c478bd9Sstevel@tonic-gate 	if (vspen(table[nl][c].col)) vspf=1;
867c478bd9Sstevel@tonic-gate 	if (lf>=0)
877c478bd9Sstevel@tonic-gate 		if (vspen(table[lf][c].col)) vspf=1;
887c478bd9Sstevel@tonic-gate 	}
897c478bd9Sstevel@tonic-gate if (vspf)
907c478bd9Sstevel@tonic-gate 	{
917c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".nr #^ \\n(\\*(#du\n");
927c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".nr #- \\n(#^\n"); /* current line position relative to bottom */
937c478bd9Sstevel@tonic-gate 	}
947c478bd9Sstevel@tonic-gate vspf=0;
957c478bd9Sstevel@tonic-gate chfont=0;
967c478bd9Sstevel@tonic-gate for(c=0; c<ncol; c++)
977c478bd9Sstevel@tonic-gate 	{
987c478bd9Sstevel@tonic-gate 	s = table[nl][c].col;
997c478bd9Sstevel@tonic-gate 	if (s==0) continue;
1007c478bd9Sstevel@tonic-gate 	chfont |= (int)(font[stynum[nl]][c]);
1017c478bd9Sstevel@tonic-gate 	if (point(s) ) continue;
1027c478bd9Sstevel@tonic-gate 	lf=prev(nl);
1037c478bd9Sstevel@tonic-gate 	if (lf>=0 && vspen(table[lf][c].col))
1047c478bd9Sstevel@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);
1057c478bd9Sstevel@tonic-gate 	else
1067c478bd9Sstevel@tonic-gate 		fprintf(tabout, ".if (\\n(%c|+\\n(#^-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(#^-\\n(#--1v)\n",s,s);
1077c478bd9Sstevel@tonic-gate 	}
1087c478bd9Sstevel@tonic-gate if (allflg && once>0 )
1097c478bd9Sstevel@tonic-gate 	fullwide(i,'-');
1107c478bd9Sstevel@tonic-gate once=1;
1117c478bd9Sstevel@tonic-gate runtabs(i, nl);
1127c478bd9Sstevel@tonic-gate if (allh(nl) && !pr1403)
1137c478bd9Sstevel@tonic-gate 	{
1147c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".nr %d \\n(.v\n", SVS);
1157c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".vs \\n(.vu-\\n(.sp\n");
1167c478bd9Sstevel@tonic-gate 	}
1177c478bd9Sstevel@tonic-gate if (chfont)
1187c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".nr %2d \\n(.f\n", S1);
1197c478bd9Sstevel@tonic-gate fprintf(tabout, ".nr 35 1m\n");
1207c478bd9Sstevel@tonic-gate fprintf(tabout, "\\&");
1217c478bd9Sstevel@tonic-gate vct = 0;
1227c478bd9Sstevel@tonic-gate for(c=0; c<ncol; c++)
1237c478bd9Sstevel@tonic-gate 	{
1247c478bd9Sstevel@tonic-gate 	if (watchout==0 && i+1<nlin && (lf=left(i,c, &lwid))>=0)
1257c478bd9Sstevel@tonic-gate 		{
1267c478bd9Sstevel@tonic-gate 		tohcol(c);
1277c478bd9Sstevel@tonic-gate 		drawvert(lf, i, c, lwid);
1287c478bd9Sstevel@tonic-gate 		vct += 2;
1297c478bd9Sstevel@tonic-gate 		}
1307c478bd9Sstevel@tonic-gate 	if (rightl && c+1==ncol) continue;
1317c478bd9Sstevel@tonic-gate 	vforml=i;
1327c478bd9Sstevel@tonic-gate 	for(lf=prev(nl); lf>=0 && vspen(table[lf][c].col); lf=prev(lf))
1337c478bd9Sstevel@tonic-gate 		vforml= lf;
1347c478bd9Sstevel@tonic-gate 	form= ctype(vforml,c);
1357c478bd9Sstevel@tonic-gate 	if (form != 's')
1367c478bd9Sstevel@tonic-gate 		{
1377c478bd9Sstevel@tonic-gate 		ct = c+CLEFT;
1387c478bd9Sstevel@tonic-gate 		if (form=='a') ct = c+CMID;
1397c478bd9Sstevel@tonic-gate 		if (form=='n' && table[nl][c].rcol && lused[c]==0) ct= c+CMID;
1407c478bd9Sstevel@tonic-gate 		fprintf(tabout, "\\h'|\\n(%du'", ct);
1417c478bd9Sstevel@tonic-gate 		}
1427c478bd9Sstevel@tonic-gate 	s= table[nl][c].col;
1437c478bd9Sstevel@tonic-gate 	fn = font[stynum[vforml]][c];
1447c478bd9Sstevel@tonic-gate 	size = csize[stynum[vforml]][c];
1457c478bd9Sstevel@tonic-gate 	if (*size==0)size=0;
1467c478bd9Sstevel@tonic-gate 	switch(ct=ctype(vforml, c))
1477c478bd9Sstevel@tonic-gate 		{
1487c478bd9Sstevel@tonic-gate 		case 'n':
1497c478bd9Sstevel@tonic-gate 		case 'a':
1507c478bd9Sstevel@tonic-gate 			if (table[nl][c].rcol)
1517c478bd9Sstevel@tonic-gate 				{
1527c478bd9Sstevel@tonic-gate 			   if (lused[c]) /*Zero field width*/
1537c478bd9Sstevel@tonic-gate 				{
1547c478bd9Sstevel@tonic-gate 				ip = prev(nl);
1557c478bd9Sstevel@tonic-gate 				if (ip>=0)
1567c478bd9Sstevel@tonic-gate 				if (vspen(table[ip][c].col))
1577c478bd9Sstevel@tonic-gate 					{
1587c478bd9Sstevel@tonic-gate 					if (exvspen==0)
1597c478bd9Sstevel@tonic-gate 						{
1607c478bd9Sstevel@tonic-gate 						fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c+'a');
1617c478bd9Sstevel@tonic-gate 						if (cmidx)
1627c478bd9Sstevel@tonic-gate 							fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a');
1637c478bd9Sstevel@tonic-gate 						vct++;
1647c478bd9Sstevel@tonic-gate 						fprintf(tabout, "'");
1657c478bd9Sstevel@tonic-gate 						exvspen=1;
1667c478bd9Sstevel@tonic-gate 						}
1677c478bd9Sstevel@tonic-gate 					}
1687c478bd9Sstevel@tonic-gate 				fprintf(tabout, "%c%c",F1,F2);
1697c478bd9Sstevel@tonic-gate 				puttext(s,fn,size);
1707c478bd9Sstevel@tonic-gate 				fprintf(tabout, "%c",F1);
1717c478bd9Sstevel@tonic-gate 				}
1727c478bd9Sstevel@tonic-gate 				s= table[nl][c].rcol;
1737c478bd9Sstevel@tonic-gate 				form=1;
1747c478bd9Sstevel@tonic-gate 				break;
1757c478bd9Sstevel@tonic-gate 				}
1767c478bd9Sstevel@tonic-gate 		case 'c':
1777c478bd9Sstevel@tonic-gate 			form=3; break;
1787c478bd9Sstevel@tonic-gate 		case 'r':
1797c478bd9Sstevel@tonic-gate 			form=2; break;
1807c478bd9Sstevel@tonic-gate 		case 'l':
1817c478bd9Sstevel@tonic-gate 			form=1; break;
1827c478bd9Sstevel@tonic-gate 		case '-':
1837c478bd9Sstevel@tonic-gate 		case '=':
1847c478bd9Sstevel@tonic-gate 			if (real(table[nl][c].col))
1857c478bd9Sstevel@tonic-gate 				fprintf(stderr,gettext("%s: line %d: Data ignored on table line %d\n"), ifile, iline-1, i+1);
1867c478bd9Sstevel@tonic-gate 			makeline(i,c,ct);
1877c478bd9Sstevel@tonic-gate 			continue;
1887c478bd9Sstevel@tonic-gate 		default:
1897c478bd9Sstevel@tonic-gate 			continue;
1907c478bd9Sstevel@tonic-gate 		}
1917c478bd9Sstevel@tonic-gate 	if (realsplit ? rused[c]: used[c]) /*Zero field width*/
1927c478bd9Sstevel@tonic-gate 		{
1937c478bd9Sstevel@tonic-gate 		/* form: 1 left, 2 right, 3 center adjust */
1947c478bd9Sstevel@tonic-gate 		if (ifline(s))
1957c478bd9Sstevel@tonic-gate 			{
1967c478bd9Sstevel@tonic-gate 			makeline(i,c,ifline(s));
1977c478bd9Sstevel@tonic-gate 			continue;
1987c478bd9Sstevel@tonic-gate 			}
1997c478bd9Sstevel@tonic-gate 		if (filler(s))
2007c478bd9Sstevel@tonic-gate 			{
2017c478bd9Sstevel@tonic-gate 			printf("\\l'|\\n(%du\\&%s'", c+CRIGHT, s+2);
2027c478bd9Sstevel@tonic-gate 			continue;
2037c478bd9Sstevel@tonic-gate 			}
2047c478bd9Sstevel@tonic-gate 		ip = prev(nl);
2057c478bd9Sstevel@tonic-gate 		cmidx = ctop[stynum[nl]][c]==0;
2067c478bd9Sstevel@tonic-gate 		if (ip>=0)
2077c478bd9Sstevel@tonic-gate 		if (vspen(table[ip][c].col))
2087c478bd9Sstevel@tonic-gate 			{
2097c478bd9Sstevel@tonic-gate 			if (exvspen==0)
2107c478bd9Sstevel@tonic-gate 				{
2117c478bd9Sstevel@tonic-gate 				fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c+'a');
2127c478bd9Sstevel@tonic-gate 				if (cmidx)
2137c478bd9Sstevel@tonic-gate 					fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a');
2147c478bd9Sstevel@tonic-gate 				vct++;
2157c478bd9Sstevel@tonic-gate 				fprintf(tabout, "'");
2167c478bd9Sstevel@tonic-gate 				}
2177c478bd9Sstevel@tonic-gate 			}
2187c478bd9Sstevel@tonic-gate 		fprintf(tabout, "%c", F1);
2197c478bd9Sstevel@tonic-gate 		if (form!= 1)
2207c478bd9Sstevel@tonic-gate 			fprintf(tabout, "%c", F2);
2217c478bd9Sstevel@tonic-gate 		if (vspen(s))
2227c478bd9Sstevel@tonic-gate 			vspf=1;
2237c478bd9Sstevel@tonic-gate 		else
2247c478bd9Sstevel@tonic-gate 		puttext(s, fn, size);
2257c478bd9Sstevel@tonic-gate 		if (form !=2)
2267c478bd9Sstevel@tonic-gate 			fprintf(tabout, "%c", F2);
2277c478bd9Sstevel@tonic-gate 		fprintf(tabout, "%c", F1);
2287c478bd9Sstevel@tonic-gate 		}
2297c478bd9Sstevel@tonic-gate 	if (ip>=0)
2307c478bd9Sstevel@tonic-gate 	if (vspen(table[ip][c].col))
2317c478bd9Sstevel@tonic-gate 		{
2327c478bd9Sstevel@tonic-gate 		exvspen = (c+1 < ncol) && vspen(table[ip][c+1].col) &&
2337c478bd9Sstevel@tonic-gate 			(topat[c] == topat[c+1]) &&
2347c478bd9Sstevel@tonic-gate 			(cmidx == (ctop [stynum[nl]][c+1]==0)) && (left(i,c+1,&lwid)<0);
2357c478bd9Sstevel@tonic-gate 		if (exvspen==0)
2367c478bd9Sstevel@tonic-gate 			{
2377c478bd9Sstevel@tonic-gate 			fprintf(tabout, "\\v'(\\n(\\*(#du-\\n(^%cu", c+'a');
2387c478bd9Sstevel@tonic-gate 			if (cmidx)
2397c478bd9Sstevel@tonic-gate 				fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a');
2407c478bd9Sstevel@tonic-gate 			vct++;
2417c478bd9Sstevel@tonic-gate 			fprintf(tabout, "'");
2427c478bd9Sstevel@tonic-gate 			}
2437c478bd9Sstevel@tonic-gate 		}
2447c478bd9Sstevel@tonic-gate 	else
2457c478bd9Sstevel@tonic-gate 		exvspen=0;
2467c478bd9Sstevel@tonic-gate 	/* if lines need to be split for gcos here is the place for a backslash */
2477c478bd9Sstevel@tonic-gate 	if (vct > 7 && c < ncol)
2487c478bd9Sstevel@tonic-gate 		{
2497c478bd9Sstevel@tonic-gate 		fprintf(tabout, "\n.sp-1\n\\&");
2507c478bd9Sstevel@tonic-gate 		vct=0;
2517c478bd9Sstevel@tonic-gate 		}
2527c478bd9Sstevel@tonic-gate 	}
2537c478bd9Sstevel@tonic-gate fprintf(tabout, "\n");
2547c478bd9Sstevel@tonic-gate if (allh(nl) && !pr1403) fprintf(tabout, ".vs \\n(%du\n", SVS);
2557c478bd9Sstevel@tonic-gate if (watchout)
2567c478bd9Sstevel@tonic-gate 	funnies(i,nl);
2577c478bd9Sstevel@tonic-gate if (vspf)
2587c478bd9Sstevel@tonic-gate 	{
2597c478bd9Sstevel@tonic-gate 	for(c=0; c<ncol; c++)
2607c478bd9Sstevel@tonic-gate 		if (vspen(table[nl][c].col) && (nl==0 || (lf=prev(nl))<0 || !vspen(table[lf][c].col)))
2617c478bd9Sstevel@tonic-gate 			{
2627c478bd9Sstevel@tonic-gate 			fprintf(tabout, ".nr ^%c \\n(#^u\n", 'a'+c);
2637c478bd9Sstevel@tonic-gate 			topat[c]=nl;
2647c478bd9Sstevel@tonic-gate 			}
2657c478bd9Sstevel@tonic-gate 	}
2667c478bd9Sstevel@tonic-gate }
267*b5514887Smuffin 
268*b5514887Smuffin void
269*b5514887Smuffin puttext(char *s, char *fn, char *size)
2707c478bd9Sstevel@tonic-gate {
2717c478bd9Sstevel@tonic-gate if (point(s))
2727c478bd9Sstevel@tonic-gate 	{
2737c478bd9Sstevel@tonic-gate 	putfont(fn);
2747c478bd9Sstevel@tonic-gate 	putsize(size);
2757c478bd9Sstevel@tonic-gate 	fprintf(tabout, "%s",s);
2767c478bd9Sstevel@tonic-gate 	if (*fn>0) fprintf(tabout, "\\f\\n(%2d", S1);
2777c478bd9Sstevel@tonic-gate 	if (size!=0) putsize("0");
2787c478bd9Sstevel@tonic-gate 	}
2797c478bd9Sstevel@tonic-gate }
280*b5514887Smuffin 
281*b5514887Smuffin void
282*b5514887Smuffin funnies(int stl, int lin)
2837c478bd9Sstevel@tonic-gate {
2847c478bd9Sstevel@tonic-gate /* write out funny diverted things */
2857c478bd9Sstevel@tonic-gate int c, s, pl, lwid, dv, lf, ct;
2867c478bd9Sstevel@tonic-gate char *fn;
2877c478bd9Sstevel@tonic-gate fprintf(tabout, ".mk ##\n"); /* rmember current vertical position */
2887c478bd9Sstevel@tonic-gate fprintf(tabout, ".nr %d \\n(##\n", S1); /* bottom position */
2897c478bd9Sstevel@tonic-gate for(c=0; c<ncol; c++)
2907c478bd9Sstevel@tonic-gate 	{
2917c478bd9Sstevel@tonic-gate 	s = (int)table[lin][c].col;
2927c478bd9Sstevel@tonic-gate 	if (point(s)) continue;
2937c478bd9Sstevel@tonic-gate 	if (s==0) continue;
2947c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".sp |\\n(##u-1v\n");
2957c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".nr %d ", SIND);
2967c478bd9Sstevel@tonic-gate 	for(pl=stl; pl>=0 && !isalpha(ct=ctype(pl,c)); pl=prev(pl))
2977c478bd9Sstevel@tonic-gate 		;
2987c478bd9Sstevel@tonic-gate 	switch (ct)
2997c478bd9Sstevel@tonic-gate 		{
3007c478bd9Sstevel@tonic-gate 		case 'n':
3017c478bd9Sstevel@tonic-gate 		case 'c':
3027c478bd9Sstevel@tonic-gate 			fprintf(tabout, "(\\n(%du+\\n(%du-\\n(%c-u)/2u\n",c+CLEFT,c-1+ctspan(lin,c)+CRIGHT, s);
3037c478bd9Sstevel@tonic-gate 			break;
3047c478bd9Sstevel@tonic-gate 		case 'l':
3057c478bd9Sstevel@tonic-gate 			fprintf(tabout, "\\n(%du\n",c+CLEFT);
3067c478bd9Sstevel@tonic-gate 			break;
3077c478bd9Sstevel@tonic-gate 		case 'a':
3087c478bd9Sstevel@tonic-gate 			fprintf(tabout, "\\n(%du\n",c+CMID);
3097c478bd9Sstevel@tonic-gate 			break;
3107c478bd9Sstevel@tonic-gate 		case 'r':
3117c478bd9Sstevel@tonic-gate 			fprintf(tabout, "\\n(%du-\\n(%c-u\n", c+CRIGHT, s);
3127c478bd9Sstevel@tonic-gate 			break;
3137c478bd9Sstevel@tonic-gate 		}
3147c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".in +\\n(%du\n", SIND);
3157c478bd9Sstevel@tonic-gate 	fn=font[stynum[stl]][c];
3167c478bd9Sstevel@tonic-gate 	putfont(fn);
3177c478bd9Sstevel@tonic-gate 	pl = prev(stl);
3187c478bd9Sstevel@tonic-gate 	if (stl>0 && pl>=0 && vspen(table[pl][c].col))
3197c478bd9Sstevel@tonic-gate 		{
3207c478bd9Sstevel@tonic-gate 		fprintf(tabout, ".sp |\\n(^%cu\n", 'a'+c);
3217c478bd9Sstevel@tonic-gate 		if (ctop[stynum[stl]][c]==0)
3227c478bd9Sstevel@tonic-gate 			{
3237c478bd9Sstevel@tonic-gate 			fprintf(tabout, ".nr %d \\n(#-u-\\n(^%c-\\n(%c|+1v\n",TMP, 'a'+c, s);
3247c478bd9Sstevel@tonic-gate 			fprintf(tabout, ".if \\n(%d>0 .sp \\n(%du/2u\n", TMP, TMP);
3257c478bd9Sstevel@tonic-gate 			}
3267c478bd9Sstevel@tonic-gate 		}
3277c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".%c+\n",s);
3287c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".in -\\n(%du\n", SIND);
3297c478bd9Sstevel@tonic-gate 	if (*fn>0) putfont("P");
3307c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".mk %d\n", S2);
3317c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n", S2, S1, S1, S2);
3327c478bd9Sstevel@tonic-gate 	}
3337c478bd9Sstevel@tonic-gate fprintf(tabout, ".sp |\\n(%du\n", S1);
3347c478bd9Sstevel@tonic-gate for(c=dv=0; c<ncol; c++)
3357c478bd9Sstevel@tonic-gate 	{
3367c478bd9Sstevel@tonic-gate 	if (stl+1< nlin && (lf=left(stl,c,&lwid))>=0)
3377c478bd9Sstevel@tonic-gate 		{
3387c478bd9Sstevel@tonic-gate 		if (dv++ == 0)
3397c478bd9Sstevel@tonic-gate 			fprintf(tabout, ".sp -1\n");
3407c478bd9Sstevel@tonic-gate 		tohcol(c);
3417c478bd9Sstevel@tonic-gate 		dv++;
3427c478bd9Sstevel@tonic-gate 		drawvert(lf, stl, c, lwid);
3437c478bd9Sstevel@tonic-gate 		}
3447c478bd9Sstevel@tonic-gate 	}
3457c478bd9Sstevel@tonic-gate if (dv)
3467c478bd9Sstevel@tonic-gate 	fprintf(tabout,"\n");
3477c478bd9Sstevel@tonic-gate }
348*b5514887Smuffin 
349*b5514887Smuffin void
350*b5514887Smuffin putfont(char *fn)
3517c478bd9Sstevel@tonic-gate {
3527c478bd9Sstevel@tonic-gate if (fn && *fn)
3537c478bd9Sstevel@tonic-gate 	fprintf(tabout,  fn[1] ? "\\f(%.2s" : "\\f%.2s",  fn);
3547c478bd9Sstevel@tonic-gate }
355*b5514887Smuffin 
356*b5514887Smuffin void
357*b5514887Smuffin putsize(char *s)
3587c478bd9Sstevel@tonic-gate {
3597c478bd9Sstevel@tonic-gate if (s && *s)
3607c478bd9Sstevel@tonic-gate 	fprintf(tabout, "\\s%s",s);
3617c478bd9Sstevel@tonic-gate }
362