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