xref: /titanic_50/usr/src/cmd/tbl/tg.c (revision b55148877d473978f0b46d593fd6213fa526fcc5)
1*b5514887Smuffin /*
2*b5514887Smuffin  * Copyright 1998 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  /* tg.c: process included text blocks */
187c478bd9Sstevel@tonic-gate # include "t..c"
197c478bd9Sstevel@tonic-gate /* get_text was originally gettext and was renamed */
20*b5514887Smuffin 
21*b5514887Smuffin int
get_text(char * sp,int ilin,int icol,char * fn,char * sz)22*b5514887Smuffin get_text(char *sp, int ilin, int icol, char *fn, char *sz)
237c478bd9Sstevel@tonic-gate {
247c478bd9Sstevel@tonic-gate /* get a section of text */
257c478bd9Sstevel@tonic-gate char line[BIGBUF];
267c478bd9Sstevel@tonic-gate int oname;
277c478bd9Sstevel@tonic-gate char *vs;
287c478bd9Sstevel@tonic-gate if (texname==0) error(gettext("Too many text block diversions"));
297c478bd9Sstevel@tonic-gate if (textflg==0)
307c478bd9Sstevel@tonic-gate 	{
317c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".nr %d \\n(.lu\n", SL); /* remember old line length */
327c478bd9Sstevel@tonic-gate 	textflg=1;
337c478bd9Sstevel@tonic-gate 	}
347c478bd9Sstevel@tonic-gate fprintf(tabout, ".eo\n");
357c478bd9Sstevel@tonic-gate fprintf(tabout, ".am %02d\n", icol+80);
367c478bd9Sstevel@tonic-gate fprintf(tabout, ".br\n");
377c478bd9Sstevel@tonic-gate fprintf(tabout, ".di %c+\n", texname);
387c478bd9Sstevel@tonic-gate rstofill();
397c478bd9Sstevel@tonic-gate if (fn && *fn) fprintf(tabout, ".nr %d \\n(.f\n.ft %s\n", S1, fn);
407c478bd9Sstevel@tonic-gate fprintf(tabout, ".ft \\n(.f\n"); /* protect font */
417c478bd9Sstevel@tonic-gate vs = vsize[stynum[ilin]][icol];
427c478bd9Sstevel@tonic-gate if ((sz && *sz) || (vs && *vs))
437c478bd9Sstevel@tonic-gate 	{
447c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".nr %d \\n(.v\n", S2);
457c478bd9Sstevel@tonic-gate 	if (vs==0 || *vs==0) vs= "\\n(.s+2";
467c478bd9Sstevel@tonic-gate 	if (sz && *sz)
477c478bd9Sstevel@tonic-gate 		fprintf(tabout, ".ps %s\n",sz);
487c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".vs %s\n",vs);
497c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".if \\n(%du>\\n(.vu .sp \\n(%du-\\n(.vu\n", S2,S2);
507c478bd9Sstevel@tonic-gate 	}
517c478bd9Sstevel@tonic-gate if (cll[icol][0])
527c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".ll %sn\n", cll[icol]);
537c478bd9Sstevel@tonic-gate else
547c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".ll \\n(%du*%du/%du\n",SL,ctspan(ilin,icol),ncol+1);
557c478bd9Sstevel@tonic-gate fprintf(tabout,".if \\n(.l<\\n(%d .ll \\n(%du\n", icol+CRIGHT, icol+CRIGHT);
567c478bd9Sstevel@tonic-gate if (ctype(ilin,icol)=='a')
577c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".ll -2n\n");
587c478bd9Sstevel@tonic-gate fprintf(tabout, ".in 0\n");
597c478bd9Sstevel@tonic-gate while (gets1(line, sizeof line))
607c478bd9Sstevel@tonic-gate 	{
617c478bd9Sstevel@tonic-gate 	if (line[0]=='T' && line[1]=='}' && line[2]== tab) break;
627c478bd9Sstevel@tonic-gate 	if (match("T}", line)) break;
637c478bd9Sstevel@tonic-gate 	fprintf(tabout, "%s\n", line);
647c478bd9Sstevel@tonic-gate 	}
657c478bd9Sstevel@tonic-gate if (fn && *fn) fprintf(tabout, ".ft \\n(%d\n", S1);
667c478bd9Sstevel@tonic-gate if (sz && *sz) fprintf(tabout, ".br\n.ps\n.vs\n");
677c478bd9Sstevel@tonic-gate fprintf(tabout, ".br\n");
687c478bd9Sstevel@tonic-gate fprintf(tabout, ".di\n");
697c478bd9Sstevel@tonic-gate fprintf(tabout, ".nr %c| \\n(dn\n", texname);
707c478bd9Sstevel@tonic-gate fprintf(tabout, ".nr %c- \\n(dl\n", texname);
717c478bd9Sstevel@tonic-gate fprintf(tabout, "..\n");
727c478bd9Sstevel@tonic-gate fprintf(tabout, ".ec \\\n");
737c478bd9Sstevel@tonic-gate /* copy remainder of line */
747c478bd9Sstevel@tonic-gate if (line[2])
757c478bd9Sstevel@tonic-gate 	tcopy (sp, line+3);
767c478bd9Sstevel@tonic-gate else
777c478bd9Sstevel@tonic-gate 	*sp=0;
787c478bd9Sstevel@tonic-gate oname=texname;
797c478bd9Sstevel@tonic-gate texname = texstr[++texct];
807c478bd9Sstevel@tonic-gate return(oname);
817c478bd9Sstevel@tonic-gate }
82*b5514887Smuffin 
83*b5514887Smuffin void
untext(void)84*b5514887Smuffin untext(void)
857c478bd9Sstevel@tonic-gate {
867c478bd9Sstevel@tonic-gate rstofill();
877c478bd9Sstevel@tonic-gate fprintf(tabout, ".nf\n");
887c478bd9Sstevel@tonic-gate fprintf(tabout, ".ll \\n(%du\n", SL);
897c478bd9Sstevel@tonic-gate }
90