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