xref: /titanic_50/usr/src/cmd/tbl/tg.c (revision ba7866cd2cbdf574f47d4e38a1301b90744dd677)
1 /*
2  * Copyright 1998 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
7 /*	  All Rights Reserved  	*/
8 
9 /*
10  * Copyright (c) 1980 Regents of the University of California.
11  * All rights reserved. The Berkeley software License Agreement
12  * specifies the terms and conditions for redistribution.
13  */
14 
15 #pragma ident	"%Z%%M%	%I%	%E% SMI"
16 
17  /* tg.c: process included text blocks */
18 # include "t..c"
19 /* get_text was originally gettext and was renamed */
20 
21 int
22 get_text(char *sp, int ilin, int icol, char *fn, char *sz)
23 {
24 /* get a section of text */
25 char line[BIGBUF];
26 int oname;
27 char *vs;
28 if (texname==0) error(gettext("Too many text block diversions"));
29 if (textflg==0)
30 	{
31 	fprintf(tabout, ".nr %d \\n(.lu\n", SL); /* remember old line length */
32 	textflg=1;
33 	}
34 fprintf(tabout, ".eo\n");
35 fprintf(tabout, ".am %02d\n", icol+80);
36 fprintf(tabout, ".br\n");
37 fprintf(tabout, ".di %c+\n", texname);
38 rstofill();
39 if (fn && *fn) fprintf(tabout, ".nr %d \\n(.f\n.ft %s\n", S1, fn);
40 fprintf(tabout, ".ft \\n(.f\n"); /* protect font */
41 vs = vsize[stynum[ilin]][icol];
42 if ((sz && *sz) || (vs && *vs))
43 	{
44 	fprintf(tabout, ".nr %d \\n(.v\n", S2);
45 	if (vs==0 || *vs==0) vs= "\\n(.s+2";
46 	if (sz && *sz)
47 		fprintf(tabout, ".ps %s\n",sz);
48 	fprintf(tabout, ".vs %s\n",vs);
49 	fprintf(tabout, ".if \\n(%du>\\n(.vu .sp \\n(%du-\\n(.vu\n", S2,S2);
50 	}
51 if (cll[icol][0])
52 	fprintf(tabout, ".ll %sn\n", cll[icol]);
53 else
54 	fprintf(tabout, ".ll \\n(%du*%du/%du\n",SL,ctspan(ilin,icol),ncol+1);
55 fprintf(tabout,".if \\n(.l<\\n(%d .ll \\n(%du\n", icol+CRIGHT, icol+CRIGHT);
56 if (ctype(ilin,icol)=='a')
57 	fprintf(tabout, ".ll -2n\n");
58 fprintf(tabout, ".in 0\n");
59 while (gets1(line, sizeof line))
60 	{
61 	if (line[0]=='T' && line[1]=='}' && line[2]== tab) break;
62 	if (match("T}", line)) break;
63 	fprintf(tabout, "%s\n", line);
64 	}
65 if (fn && *fn) fprintf(tabout, ".ft \\n(%d\n", S1);
66 if (sz && *sz) fprintf(tabout, ".br\n.ps\n.vs\n");
67 fprintf(tabout, ".br\n");
68 fprintf(tabout, ".di\n");
69 fprintf(tabout, ".nr %c| \\n(dn\n", texname);
70 fprintf(tabout, ".nr %c- \\n(dl\n", texname);
71 fprintf(tabout, "..\n");
72 fprintf(tabout, ".ec \\\n");
73 /* copy remainder of line */
74 if (line[2])
75 	tcopy (sp, line+3);
76 else
77 	*sp=0;
78 oname=texname;
79 texname = texstr[++texct];
80 return(oname);
81 }
82 
83 void
84 untext(void)
85 {
86 rstofill();
87 fprintf(tabout, ".nf\n");
88 fprintf(tabout, ".ll \\n(%du\n", SL);
89 }
90