1 /* $MirOS: src/usr.bin/oldroff/tbl/tg.c,v 1.4 2008/11/08 23:04:54 tg Exp $ */
2
3 /*-
4 * Copyright (c) 1979, 1980, 1981, 1986, 1988, 1990, 1991, 1992
5 * The Regents of the University of California.
6 * Copyright (C) Caldera International Inc. 2001-2002.
7 * Copyright (c) 2003, 2004
8 * Thorsten "mirabilos" Glaser <tg@mirbsd.org>
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms,
12 * with or without modification, are permitted provided
13 * that the following conditions are met:
14 *
15 * Redistributions of source code and documentation must retain
16 * the above copyright notice, this list of conditions and the
17 * following disclaimer. Redistributions in binary form must
18 * reproduce the above copyright notice, this list of conditions
19 * and the following disclaimer in the documentation and/or other
20 * materials provided with the distribution.
21 *
22 * All advertising materials mentioning features or use of this
23 * software must display the following acknowledgement:
24 * This product includes software developed or owned by
25 * Caldera International, Inc.
26 *
27 * Neither the name of Caldera International, Inc. nor the names
28 * of other contributors may be used to endorse or promote products
29 * derived from this software without specific prior written permission.
30 *
31 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
32 * INTERNATIONAL, INC. AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
33 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE
36 * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
37 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
39 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
40 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
41 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
42 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 */
44
45 /* tg.c: process included text blocks */
46
47 # include "t..c"
48 __SCCSID("@(#)tg.c 4.3 (Berkeley) 4/18/91");
49 __RCSID("$MirOS: src/usr.bin/oldroff/tbl/tg.c,v 1.4 2008/11/08 23:04:54 tg Exp $");
50
gettext(sp,ilin,icol,fn,sz)51 gettext(sp, ilin,icol, fn, sz)
52 char *sp, *fn, *sz;
53 {
54 /* get a section of text */
55 char line[BUFSIZ];
56 int oname;
57 char *vs;
58 if (texname==0) error("Too many text block diversions");
59 if (textflg==0)
60 {
61 fprintf(tabout, ".nr %d \\n(.lu\n", SL); /* remember old line length */
62 textflg=1;
63 }
64 fprintf(tabout, ".eo\n");
65 fprintf(tabout, ".am %02d\n", icol+80);
66 fprintf(tabout, ".br\n");
67 fprintf(tabout, ".di %c+\n", texname);
68 rstofill();
69 if (fn && *fn) fprintf(tabout, ".nr %d \\n(.f\n.ft %s\n", S1, fn);
70 fprintf(tabout, ".ft \\n(.f\n"); /* protect font */
71 vs = vsize[stynum[ilin]][icol];
72 if ((sz && *sz) || (vs && *vs))
73 {
74 fprintf(tabout, ".nr %d \\n(.v\n", S2);
75 if (vs==0 || *vs==0) vs= "\\n(.s+2";
76 if (sz && *sz)
77 fprintf(tabout, ".ps %s\n",sz);
78 fprintf(tabout, ".vs %s\n",vs);
79 fprintf(tabout, ".if \\n(%du>\\n(.vu .sp \\n(%du-\\n(.vu\n", S2,S2);
80 }
81 if (cll[icol][0])
82 fprintf(tabout, ".ll %sn\n", cll[icol]);
83 else
84 fprintf(tabout, ".ll \\n(%du*%du/%du\n",SL,ctspan(ilin,icol),ncol+1);
85 fprintf(tabout,".if \\n(.l<\\n(%d .ll \\n(%du\n", icol+CRIGHT, icol+CRIGHT);
86 if (ctype(ilin,icol)=='a')
87 fprintf(tabout, ".ll -2n\n");
88 fprintf(tabout, ".in 0\n");
89 while (gets1(line))
90 {
91 if (line[0]=='T' && line[1]=='}' && line[2]== tab) break;
92 if (match("T}", line)) break;
93 fprintf(tabout, "%s\n", line);
94 }
95 if (fn && *fn) fprintf(tabout, ".ft \\n(%d\n", S1);
96 if (sz && *sz) fprintf(tabout, ".br\n.ps\n.vs\n");
97 fprintf(tabout, ".br\n");
98 fprintf(tabout, ".di\n");
99 fprintf(tabout, ".nr %c| \\n(dn\n", texname);
100 fprintf(tabout, ".nr %c- \\n(dl\n", texname);
101 fprintf(tabout, "..\n");
102 fprintf(tabout, ".ec \\\n");
103 /* copy remainder of line */
104 if (line[2])
105 tcopy (sp, line+3);
106 else
107 *sp=0;
108 oname=texname;
109 texname = texstr[++texct];
110 return(oname);
111 }
untext()112 untext()
113 {
114 rstofill();
115 fprintf(tabout, ".nf\n");
116 fprintf(tabout, ".ll \\n(%du\n", SL);
117 }
118