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