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