xref: /titanic_44/usr/src/cmd/tbl/tg.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  /* tg.c: process included text blocks */
19*7c478bd9Sstevel@tonic-gate # include "t..c"
20*7c478bd9Sstevel@tonic-gate /* get_text was originally gettext and was renamed */
21*7c478bd9Sstevel@tonic-gate get_text(sp, ilin,icol, fn, sz)
22*7c478bd9Sstevel@tonic-gate 	char *sp, *fn, *sz;
23*7c478bd9Sstevel@tonic-gate {
24*7c478bd9Sstevel@tonic-gate /* get a section of text */
25*7c478bd9Sstevel@tonic-gate char line[BIGBUF];
26*7c478bd9Sstevel@tonic-gate int oname;
27*7c478bd9Sstevel@tonic-gate char *vs;
28*7c478bd9Sstevel@tonic-gate if (texname==0) error(gettext("Too many text block diversions"));
29*7c478bd9Sstevel@tonic-gate if (textflg==0)
30*7c478bd9Sstevel@tonic-gate 	{
31*7c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".nr %d \\n(.lu\n", SL); /* remember old line length */
32*7c478bd9Sstevel@tonic-gate 	textflg=1;
33*7c478bd9Sstevel@tonic-gate 	}
34*7c478bd9Sstevel@tonic-gate fprintf(tabout, ".eo\n");
35*7c478bd9Sstevel@tonic-gate fprintf(tabout, ".am %02d\n", icol+80);
36*7c478bd9Sstevel@tonic-gate fprintf(tabout, ".br\n");
37*7c478bd9Sstevel@tonic-gate fprintf(tabout, ".di %c+\n", texname);
38*7c478bd9Sstevel@tonic-gate rstofill();
39*7c478bd9Sstevel@tonic-gate if (fn && *fn) fprintf(tabout, ".nr %d \\n(.f\n.ft %s\n", S1, fn);
40*7c478bd9Sstevel@tonic-gate fprintf(tabout, ".ft \\n(.f\n"); /* protect font */
41*7c478bd9Sstevel@tonic-gate vs = vsize[stynum[ilin]][icol];
42*7c478bd9Sstevel@tonic-gate if ((sz && *sz) || (vs && *vs))
43*7c478bd9Sstevel@tonic-gate 	{
44*7c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".nr %d \\n(.v\n", S2);
45*7c478bd9Sstevel@tonic-gate 	if (vs==0 || *vs==0) vs= "\\n(.s+2";
46*7c478bd9Sstevel@tonic-gate 	if (sz && *sz)
47*7c478bd9Sstevel@tonic-gate 		fprintf(tabout, ".ps %s\n",sz);
48*7c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".vs %s\n",vs);
49*7c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".if \\n(%du>\\n(.vu .sp \\n(%du-\\n(.vu\n", S2,S2);
50*7c478bd9Sstevel@tonic-gate 	}
51*7c478bd9Sstevel@tonic-gate if (cll[icol][0])
52*7c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".ll %sn\n", cll[icol]);
53*7c478bd9Sstevel@tonic-gate else
54*7c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".ll \\n(%du*%du/%du\n",SL,ctspan(ilin,icol),ncol+1);
55*7c478bd9Sstevel@tonic-gate fprintf(tabout,".if \\n(.l<\\n(%d .ll \\n(%du\n", icol+CRIGHT, icol+CRIGHT);
56*7c478bd9Sstevel@tonic-gate if (ctype(ilin,icol)=='a')
57*7c478bd9Sstevel@tonic-gate 	fprintf(tabout, ".ll -2n\n");
58*7c478bd9Sstevel@tonic-gate fprintf(tabout, ".in 0\n");
59*7c478bd9Sstevel@tonic-gate while (gets1(line, sizeof line))
60*7c478bd9Sstevel@tonic-gate 	{
61*7c478bd9Sstevel@tonic-gate 	if (line[0]=='T' && line[1]=='}' && line[2]== tab) break;
62*7c478bd9Sstevel@tonic-gate 	if (match("T}", line)) break;
63*7c478bd9Sstevel@tonic-gate 	fprintf(tabout, "%s\n", line);
64*7c478bd9Sstevel@tonic-gate 	}
65*7c478bd9Sstevel@tonic-gate if (fn && *fn) fprintf(tabout, ".ft \\n(%d\n", S1);
66*7c478bd9Sstevel@tonic-gate if (sz && *sz) fprintf(tabout, ".br\n.ps\n.vs\n");
67*7c478bd9Sstevel@tonic-gate fprintf(tabout, ".br\n");
68*7c478bd9Sstevel@tonic-gate fprintf(tabout, ".di\n");
69*7c478bd9Sstevel@tonic-gate fprintf(tabout, ".nr %c| \\n(dn\n", texname);
70*7c478bd9Sstevel@tonic-gate fprintf(tabout, ".nr %c- \\n(dl\n", texname);
71*7c478bd9Sstevel@tonic-gate fprintf(tabout, "..\n");
72*7c478bd9Sstevel@tonic-gate fprintf(tabout, ".ec \\\n");
73*7c478bd9Sstevel@tonic-gate /* copy remainder of line */
74*7c478bd9Sstevel@tonic-gate if (line[2])
75*7c478bd9Sstevel@tonic-gate 	tcopy (sp, line+3);
76*7c478bd9Sstevel@tonic-gate else
77*7c478bd9Sstevel@tonic-gate 	*sp=0;
78*7c478bd9Sstevel@tonic-gate oname=texname;
79*7c478bd9Sstevel@tonic-gate texname = texstr[++texct];
80*7c478bd9Sstevel@tonic-gate return(oname);
81*7c478bd9Sstevel@tonic-gate }
82*7c478bd9Sstevel@tonic-gate untext()
83*7c478bd9Sstevel@tonic-gate {
84*7c478bd9Sstevel@tonic-gate rstofill();
85*7c478bd9Sstevel@tonic-gate fprintf(tabout, ".nf\n");
86*7c478bd9Sstevel@tonic-gate fprintf(tabout, ".ll \\n(%du\n", SL);
87*7c478bd9Sstevel@tonic-gate }
88