xref: /titanic_50/usr/src/cmd/troff/ni.c (revision e5190c108bde19ca4d7c03b1d1eab7b00bd3a1ed)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 /*
31  * University Copyright- Copyright (c) 1982, 1986, 1988
32  * The Regents of the University of California
33  * All Rights Reserved
34  *
35  * University Acknowledgment- Portions of this document are derived from
36  * software developed by the University of California, Berkeley, and its
37  * contributors.
38  */
39 
40 #pragma ident	"%Z%%M%	%I%	%E% SMI"
41 
42 #include "tdef.h"
43 
44 /* You may want to change these names */
45 
46 #ifdef NROFF
47 
48 char	termtab[NS] = "/usr/share/lib/nterm/tab.";  /* term type added in ptinit() */
49 char	fontfile[NS] = "";	/* not used */
50 char	devname[20] = "37";
51 
52 #else
53 
54 char	termtab[NS] = "/usr/lib/font"; /* rest added in ptinit() */
55 char	fontfile[NS] = "/usr/lib/font";/* rest added in casefp() */
56 char	devname[20]	 = "post";	/* default typesetter */
57 
58 #endif
59 char	tmp_name[] = "/usr/tmp/trtmpXXXXXX";
60 char	obuf[OBUFSZ];	/* characters collected here for typesetter output */
61 char	*obufp = obuf;
62 struct numtab numtab[NN] = {
63 	{ PAIR('%', 0) },
64 	{ PAIR('n', 'l') },
65 	{ PAIR('y', 'r') },
66 	{ PAIR('h', 'p') },
67 	{ PAIR('c', 't') },
68 	{ PAIR('d', 'n') },
69 	{ PAIR('m', 'o') },
70 	{ PAIR('d', 'y') },
71 	{ PAIR('d', 'w') },
72 	{ PAIR('l', 'n') },
73 	{ PAIR('d', 'l') },
74 	{ PAIR('s', 't') },
75 	{ PAIR('s', 'b') },
76 	{ PAIR('c', '.') },
77 	{ PAIR('$', '$') },
78 };
79 
80 
81 int	pto = 10000;
82 int	pfrom = 1;
83 int	print = 1;
84 char	nextf[NS] = "/usr/share/lib/tmac/";
85 char	mfiles[NMF][NS];
86 int	nmfi = 0;
87 #ifndef NROFF
88 int	oldbits = -1;
89 #endif
90 int	init = 1;
91 int	fc = IMP;	/* field character */
92 int	eschar = '\\';
93 #ifdef	NROFF
94 int	pl = 11*INCH;
95 int	po = PO;
96 #else
97 int	pl;
98 int	po;
99 #endif
100 int	dfact = 1;
101 int	dfactd = 1;
102 int	res = 1;
103 int	smnt = 0;	/* beginning of special fonts */
104 int	ascii = ASCII;
105 int	ptid = PTID;
106 int	lg = LG;
107 int	pnlist[NPN] = { -1 };
108 
109 
110 int	*pnp = pnlist;
111 int	npn = 1;
112 int	npnflg = 1;
113 int	dpn = -1;
114 int	totout = 1;
115 int	ulfont = ULFONT;
116 int	tabch = TAB;
117 int	ldrch = LEADER;
118 extern int caseds(), caseas(), casesp(), caseft(), caseps(), casevs(),
119 casenr(), caseif(), casepo(), casetl(), casetm(), casebp(), casech(),
120 casepn(), tbreak(), caseti(), casene(), casenf(), casece(), casefi(),
121 casein(), casell(), casens(), casemk(), casert(), caseam(),
122 casede(), casedi(), caseda(), casewh(), casedt(), caseit(), caserm(),
123 casern(), casead(), casers(), casena(), casepl(), caseta(), casetr(),
124 caseul(), caselt(), casenx(), caseso(), caseig(), casetc(), casefc(),
125 caseec(), caseeo(), caselc(), caseev(), caserd(), caseab(), casefl(),
126 done(), casess(), casefp(), casecs(), casebd(), caselg(), casehc(),
127 casehy(), casenh(), casenm(), casenn(), casesv(), caseos(), casels(),
128 casecc(), casec2(), caseem(), caseaf(), casehw(), casemc(), casepm(),
129 casecu(), casepi(), caserr(), caseuf(), caseie(), caseel(), casepc(),
130 caseht(), casecf(), casesy(), caself(), casedb();
131 
132 #define	C(a,b)	{a, 0, b, 0}
133 struct contab contab[NM] = {
134 	C(PAIR('d', 's'), caseds),
135 	C(PAIR('a', 's'), caseas),
136 	C(PAIR('s', 'p'), casesp),
137 	C(PAIR('f', 't'), caseft),
138 	C(PAIR('p', 's'), caseps),
139 	C(PAIR('v', 's'), casevs),
140 	C(PAIR('n', 'r'), casenr),
141 	C(PAIR('i', 'f'), caseif),
142 	C(PAIR('i', 'e'), caseie),
143 	C(PAIR('e', 'l'), caseel),
144 	C(PAIR('p', 'o'), casepo),
145 	C(PAIR('t', 'l'), casetl),
146 	C(PAIR('t', 'm'), casetm),
147 	C(PAIR('b', 'p'), casebp),
148 	C(PAIR('c', 'h'), casech),
149 	C(PAIR('p', 'n'), casepn),
150 	C(PAIR('b', 'r'), tbreak),
151 	C(PAIR('t', 'i'), caseti),
152 	C(PAIR('n', 'e'), casene),
153 	C(PAIR('n', 'f'), casenf),
154 	C(PAIR('c', 'e'), casece),
155 	C(PAIR('f', 'i'), casefi),
156 	C(PAIR('i', 'n'), casein),
157 	C(PAIR('l', 'l'), casell),
158 	C(PAIR('n', 's'), casens),
159 	C(PAIR('m', 'k'), casemk),
160 	C(PAIR('r', 't'), casert),
161 	C(PAIR('a', 'm'), caseam),
162 	C(PAIR('d', 'e'), casede),
163 	C(PAIR('d', 'i'), casedi),
164 	C(PAIR('d', 'a'), caseda),
165 	C(PAIR('w', 'h'), casewh),
166 	C(PAIR('d', 't'), casedt),
167 	C(PAIR('i', 't'), caseit),
168 	C(PAIR('r', 'm'), caserm),
169 	C(PAIR('r', 'r'), caserr),
170 	C(PAIR('r', 'n'), casern),
171 	C(PAIR('a', 'd'), casead),
172 	C(PAIR('r', 's'), casers),
173 	C(PAIR('n', 'a'), casena),
174 	C(PAIR('p', 'l'), casepl),
175 	C(PAIR('t', 'a'), caseta),
176 	C(PAIR('t', 'r'), casetr),
177 	C(PAIR('u', 'l'), caseul),
178 	C(PAIR('c', 'u'), casecu),
179 	C(PAIR('l', 't'), caselt),
180 	C(PAIR('n', 'x'), casenx),
181 	C(PAIR('s', 'o'), caseso),
182 	C(PAIR('i', 'g'), caseig),
183 	C(PAIR('t', 'c'), casetc),
184 	C(PAIR('f', 'c'), casefc),
185 	C(PAIR('e', 'c'), caseec),
186 	C(PAIR('e', 'o'), caseeo),
187 	C(PAIR('l', 'c'), caselc),
188 	C(PAIR('e', 'v'), caseev),
189 	C(PAIR('r', 'd'), caserd),
190 	C(PAIR('a', 'b'), caseab),
191 	C(PAIR('f', 'l'), casefl),
192 	C(PAIR('e', 'x'), done),
193 	C(PAIR('s', 's'), casess),
194 	C(PAIR('f', 'p'), casefp),
195 	C(PAIR('c', 's'), casecs),
196 	C(PAIR('b', 'd'), casebd),
197 	C(PAIR('l', 'g'), caselg),
198 	C(PAIR('h', 'c'), casehc),
199 	C(PAIR('h', 'y'), casehy),
200 	C(PAIR('n', 'h'), casenh),
201 	C(PAIR('n', 'm'), casenm),
202 	C(PAIR('n', 'n'), casenn),
203 	C(PAIR('s', 'v'), casesv),
204 	C(PAIR('o', 's'), caseos),
205 	C(PAIR('l', 's'), casels),
206 	C(PAIR('c', 'c'), casecc),
207 	C(PAIR('c', '2'), casec2),
208 	C(PAIR('e', 'm'), caseem),
209 	C(PAIR('a', 'f'), caseaf),
210 	C(PAIR('h', 'w'), casehw),
211 	C(PAIR('m', 'c'), casemc),
212 	C(PAIR('p', 'm'), casepm),
213 	C(PAIR('p', 'i'), casepi),
214 	C(PAIR('u', 'f'), caseuf),
215 	C(PAIR('p', 'c'), casepc),
216 	C(PAIR('h', 't'), caseht),
217 	C(PAIR('c', 'f'), casecf),
218 	C(PAIR('s', 'y'), casesy),
219 	C(PAIR('l', 'f'), caself),
220 	C(PAIR('d', 'b'), casedb),
221 /*	C(PAIR('!', 0), casesy), */	/* synonym for .sy */
222 };
223 
224 
225 tchar oline[LNSIZE+1];
226 
227 /*
228  * troff environment block
229  */
230 
231 struct	env env = {
232 /* int	ics	 */	0,
233 /* int	sps	 */	0,
234 /* int	spacesz	 */	0,
235 /* int	lss	 */	0,
236 /* int	lss1	 */	0,
237 /* int	ll	 */	0,
238 /* int	ll1	 */	0,
239 /* int	lt	 */	0,
240 /* int	lt1	 */	0,
241 /* tchar i	*/	0, 	/* insertion character */
242 /* int	icf	 */	0,
243 /* tchar	chbits	 */	0,	/* size+font bits for current character */
244 /* tchar	spbits	 */	0,
245 /* tchar	nmbits	 */	0,
246 /* int	apts	 */	PS,	/* actual point size -- as requested by user */
247 /* int	apts1	 */	PS,	/* need not match an existent size */
248 /* int	pts	 */	PS,	/* hence, this is the size that really exists */
249 /* int	pts1	 */	PS,
250 /* int	font	 */	FT,
251 /* int	font1	 */	FT,
252 /* int	ls	 */	1,
253 /* int	ls1	 */	1,
254 /* int	ad	 */	1,
255 /* int	nms	 */	1,
256 /* int	ndf	 */	1,
257 /* int	fi	 */	1,
258 /* int	cc	 */	'.',
259 /* int	c2	 */	'\'',
260 /* int	ohc	 */	OHC,
261 /* int	tdelim	 */	IMP,
262 /* int	hyf	 */	0,
263 /* int	hyoff	 */	0,
264 /* int	un1	 */	-1,
265 /* int	tabc	 */	0,
266 /* int	dotc	 */	'.',
267 /* int	adsp	 */	0,
268 /* int	adrem	 */	0,
269 /* int	lastl	 */	0,
270 /* int	nel	 */	0,
271 /* int	admod	 */	0,
272 /* tchar	*wordp	 */	0,
273 /* int	spflg	 */	0,	/* probably to indicate space after punctuation needed */
274 /* tchar	*linep	 */	0,
275 /* tchar	*wdend	 */	0,
276 /* tchar	*wdstart	 */	0,
277 /* int	wne	 */	0,
278 /* int	ne	 */	0,
279 /* int	nc	 */	0,
280 /* int	nb	 */	0,
281 /* int	lnmod	 */	0,
282 /* int	nwd	 */	0,
283 /* int	nn	 */	0,
284 /* int	ni	 */	0,
285 /* int	ul	 */	0,
286 /* int	cu	 */	0,
287 /* int	ce	 */	0,
288 /* int	in	 */	0,
289 /* int	in1	 */	0,
290 /* int	un	 */	0,
291 /* int	wch	 */	0,
292 /* int	pendt	 */	0,
293 /* tchar	*pendw	 */	(tchar *)0,
294 /* int	pendnf	 */	0,
295 /* int	spread	 */	0,
296 /* int	it	 */	0,
297 /* int	itmac	 */	0,
298 /* int	lnsize	 */	LNSIZE,
299 };
300