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 2003 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 /*	from OpenSolaris "tdef.h	1.11	05/06/08 SMI"	*/
32 
33 /*
34  * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
35  *
36  * Sccsid @(#)tdef.h	1.165 (gritter) 10/23/09
37  *
38  * Portions Copyright (c) 2014 Carsten Kunze <carsten.kunze@arcor.de>
39  */
40 
41 /*
42  * University Copyright- Copyright (c) 1982, 1986, 1988
43  * The Regents of the University of California
44  * All Rights Reserved
45  *
46  * University Acknowledgment- Portions of this document are derived from
47  * software developed by the University of California, Berkeley, and its
48  * contributors.
49  */
50 
51 #include "global.h"
52 
53 /* starting values for typesetting parameters: */
54 
55 #define	PS	10	/* default point size */
56 #define	FT	1	/* default font position */
57 #define ULFONT	2	/* default underline font */
58 #define	BDFONT	3	/* default emboldening font */
59 #define	BIFONT	4	/* default bold italic font */
60 #define	LL	(unsigned) 65*INCH/10	/* line length; 39picas=6.5in */
61 #define	VS	((12*INCH)/72)	/* initial vert space */
62 
63 #ifdef	NROFF
64 #	define	EM	t.Em
65 #	define	HOR	t.Adj
66 #	define	VERT	t.Vert
67 #	define	INCH	240	/* increments per inch */
68 #	define	SPS	INCH/10	/* space size */
69 #	define	SS	INCH/10	/* " */
70 #	define	SES	SPS	/* sentence space size */
71 #	define	SSS	SS	/* " */
72 #	define	TRAILER	0
73 #	define	PO	0 /* page offset */
74 #	define	ASCII	1
75 #	define	PTID	1
76 #	define	LG	0
77 #	define	DTAB	0	/* set at 8 Ems at init time */
78 #	define	ICS	2*SPS
79 #endif
80 #ifndef NROFF	/* TROFF */
81 	/* Inch is set by ptinit() when troff started. */
82 	/* all derived values set then too
83 	*/
84 #	define	INCH	Inch	/* troff resolution -- number of goobies/inch  */
85 #	define	POINT	(INCH/72)	/* goobies per point (1/72 inch) */
86 #	define	HOR	Hor	/* horizontal resolution in goobies */
87 #	define	VERT	Vert	/* vertical resolution in goobies */
88 #	define	SPS	(EM/3)	/* space size  */
89 #	define	SES	SPS	/* sentence space size */
90 #	define	SS	12	/* space size in 36ths of an em */
91 #	define	SSS	SS	/* sentence space size in 36ths of an em */
92 #	define	PO	(INCH)	/* page offset 1 inch */
93 /* #	define	EM	(POINT * pts) */
94 #define	EM	(((long) INCH * u2pts(pts) + 36) / 72)	/* don't lose significance */
95 #define	EMPTS(pts)	(((long) INCH * u2pts(pts) + 36) / 72)
96 #	define	ASCII	0
97 #	define	PTID	1
98 #	define	LG	1
99 #	define	DTAB	(INCH/2)
100 #	define	ICS	3*SPS
101 #endif
102 
103 /* These "characters" are used to encode various internal functions
104  * Some make use of the fact that most ascii characters between
105  * 0 and 040 don't have any graphic or other function.
106  * The few that do have a purpose (e.g., \n, \b, \t, ...
107  * are avoided by the ad hoc choices here.
108  * See ifilt[] in n1.c for others -- 1, 2, 3, 5, 6, 7, 010, 011, 012
109  */
110 
111 #define	LEADER	001
112 #define	IMP	004	/* impossible char; glues things together */
113 #define	TAB	011
114 #define	RPT	014	/* next character is to be repeated many times */
115 #define	CHARHT	015	/* size field sets character height */
116 #define	SLANT	016	/* size field sets amount of slant */
117 #define	DRAWFCN	017	/* next several chars describe arb drawing fcn */
118 			/* line: 'l' dx dy char */
119 			/* circle: 'c' r */
120 			/* ellipse: 'e' rx ry */
121 			/* arc: 'a' dx dy r */
122 			/* wiggly line '~' x y x y ... */
123 #define	DRAWLINE	'l'
124 #define	DRAWCIRCLE	'c'	/* circle */
125 #define	DRAWCIRCLEFI	'C'	/* filled circle */
126 #define	DRAWELLIPSE	'e'
127 #define	DRAWELLIPSEFI	'E'	/* filled ellipse */
128 #define	DRAWARC		'a'	/* arbitrary arc */
129 #define	DRAWSPLINE	'~'	/* quadratic B spline */
130 #define	DRAWTHICKNESS	't'	/* line thickness */
131 #define	DRAWPOLYGON	'p'	/* polygon */
132 #define	DRAWPOLYGONFI	'P'	/* filled polygon */
133 
134 #define	LEFT	020	/* \{ */
135 #define	RIGHT	021	/* \} */
136 #define	FILLER	022	/* \& and similar purposes */
137 #define	XON	023	/* \X'...' starts here */
138 #define	OHC	024	/* optional hyphenation character \% */
139 #define	CONT	025	/* \c character */
140 #define	PRESC	026	/* printable escape */
141 #define	UNPAD	027	/* unpaddable blank */
142 #define	STRETCH	037	/* stretchable but unbreakable blank */
143 #define	XPAR	030	/* transparent mode indicator */
144 #define	FLSS	031
145 #define	WORDSP	032	/* paddable word space */
146 #define	ESC	033
147 #define	XOFF	034	/* \X'...' ends here */
148 
149 #define	iscontrol(n)	(n==035 || n==036)	/* used to test the next two */
150 #define	HX	035	/* next character is value of \x'...' */
151 #define	FONTPOS	036	/* position of font \f(XX encoded in top */
152 
153 #define	XFUNC	013	/* extended function codes, type in fbits: */
154 #define	ANCHOR	0001	/* anchor definition */
155 #define	LINKON	0002	/* link start */
156 #define	LINKOFF	0003	/* link end */
157 #define	LETSP	0004	/* positive letter spacing */
158 #define	NLETSP	0005	/* negative letter spacing */
159 #define	FLDMARK	0006	/* field marker */
160 #define	LETSH	0007	/* expanded letter shapes */
161 #define	NLETSH	0010	/* condensed letter shapes */
162 #define	HYPHED	0011	/* previous character is an automatic hyphen */
163 #define	OLT	0012	/* output line trap */
164 #define	YON	0013	/* indirect copy through */
165 #define	CC	0014	/* unchangeable control character */
166 #define	RQ	0015	/* request number */
167 #define	CHAR	0022	/* formatted result of a .char execution */
168 #define	INDENT	0023	/* current indent (informational only, no move) */
169 #define	PENALTY	0024	/* line breaking penalty */
170 #define	DPENAL	0025	/* default line breaking penalty change */
171 #define	ULINKON	0026	/* ulink start */
172 #define	ULINKOFF 0027	/* ulink end */
173 
174 #define	isxfunc(c, x)	(cbits(c) == XFUNC && fbits(c) == (x))
175 
176 #define	LAFACT	1000	/* letter adjustment float-to-int conversion factor */
177 
178 #define	HYPHEN	c_hyphen
179 #define	EMDASH	c_emdash	/* \(em */
180 #define	RULE	c_rule		/* \(ru */
181 #define	MINUS	c_minus		/* minus sign on current font */
182 #define	LIG_FI	c_fi		/* \(ff */
183 #define	LIG_FL	c_fl		/* \(fl */
184 #define	LIG_FF	c_ff		/* \(ff */
185 #define	LIG_FFI	c_ffi		/* \(Fi */
186 #define	LIG_FFL	c_ffl		/* \(Fl */
187 #define	ACUTE	c_acute		/* acute accent \(aa */
188 #define	GRAVE	c_grave		/* grave accent \(ga */
189 #define	UNDERLINE c_under	/* \(ul */
190 #define	ROOTEN	c_rooten	/* root en \(rn */
191 #define	BOXRULE	c_boxrule	/* box rule \(br */
192 #define	LEFTHAND c_lefthand	/* left hand for word overflow */
193 #define	DAGGER	c_dagger	/* dagger for footnotes */
194 
195 /* array sizes, and similar limits: */
196 
197 #define	NFONT	10	/* maximum number of fonts (including specials, !afm) */
198 #define	EXTRAFONT 500	/* extra space for swapping a font */
199 extern	int	NN;	/* number registers */
200 #define	NNAMES	15	 /* predefined reg names */
201 extern	int	NS;	/* name buffer */
202 #define	NTM	4096	/* tm buffer */
203 #define	NEV	3	/* environments */
204 #define	EVLSZ	10	/* size of ev stack */
205 #define	DSIZE	512	/* disk sector size in chars */
206 
207 extern	int	NM;	/* requests + macros */
208 #define	NHYP	40	/* max hyphens per word */
209 #define	NTAB	40	/* tab stops */
210 #define	NSO	5	/* "so" depth */
211 extern	int	NMF;	/* size of space for -m flags */
212 #define	WDSIZE	540	/* default word buffer size */
213 #define	LNSIZE	680	/* default line buffer size */
214 extern	int	NDI;	/* number of diversions */
215 extern	int	NCHARS;	/* maximum size of troff character set */
216 #define	NTRTAB	NCHARS	/* number of items in trtab[] */
217 #define	NWIDCACHE NCHARS	/* number of items in widcache */
218 #define	NTRAP	20	/* number of traps */
219 #define	NPN	20	/* numbers in "-o" */
220 #define	FBUFSZ	512	/* field buf size words */
221 #define	OBUFSZ	4096	/* bytes */
222 #define	IBUFSZ	4096L	/* bytes */
223 #define	NC	1024	/* cbuf size words */
224 #define	NOV	10	/* number of overstrike chars */
225 #define	NPP	10	/* pads per field */
226 #define	NSENT	40	/* number of sentence end characters */
227 
228 /*
229 	Internal character representation:
230 	Internally, every character is carried around as
231 	a 64 bit cookie, called a "tchar" (typedef int64_t).
232 	Bits are numbered 63..0 from left to right.
233 	If bit 21 is 1, the character is motion, with
234 		if bit 22 it's vertical motion
235 		if bit 23 it's negative motion
236 	If bit 21 is 0, the character is a real character.
237 		if bit 63	zero motion
238 		bits 62..40	size
239 		bits 39..32	font
240 */
241 
242 /* in the following, "LL" should really be a tchar, but ... */
243 
244 #define	MOT	(01LL<<21)	/* motion character indicator */
245 #define	VMOT	(01LL<<22)	/* vert motion bit */
246 #define	NMOT	(01LL<<23)	/* negative motion indicator*/
247 #define	BMBITS	0x001FFFFFLL	/* basic absolute motion bits */
248 #define	XMBITS	0x03000000LL	/* extended absolute motion bits */
249 #define	XMSHIFT	3		/* extended absolute motion shift */
250 #define	MAXMOT	0x007FFFFFLL	/* bad way to write this!!! */
251 
252 #define	ismot(n)	((n) & MOT)
253 #define	isvmot(n)	((n) & VMOT)	/* must have tested MOT previously */
254 #define	isnmot(n)	((n) & NMOT)	/* ditto */
255 #define	absmot(n)	(unsigned long)((BMBITS&(n)) | ((n)&XMBITS)>>XMSHIFT)
256 #define	sabsmot(n)	(!xflag || (n) <= MAXMOT ? ((n)&BMBITS) | ((n)&~BMBITS)<<XMSHIFT : moflo(n))
257 
258 #define	ZBIT		(01ULL << 63) 	/* zero width char */
259 #define	iszbit(n)	((n) & ZBIT)
260 #define	BLBIT		(01ULL << 31)	/* optional break-line char */
261 #define	isblbit(n)	((n) & BLBIT)
262 #define	COPYBIT		(01ULL << 30)	/* wide character in copy mode */
263 #define	iscopy(n)	((n) & COPYBIT && !ismot(n) && cbits(n) & ~0177)
264 #define	ADJBIT		(01ULL << 30)	/* adjusted space */
265 #define	isadjspc(n)	((n) & ADJBIT && !ismot(n) && (cbits(n) & ~0177) == 0 \
266 				&& cbits(n) != FILLER)
267 #define	isadjmot(n)	((n) & ADJBIT && ismot(n))
268 #define	TRANBIT		(01ULL << 30)	/* transparent filler */
269 #define	istrans(n)	((n) & TRANBIT && cbits(n) == FILLER)
270 #define	AUTOLIG		(01ULL << 29)	/* ligature substituted automatically */
271 #define	islig(n)	((n) & AUTOLIG)
272 #define	TAILBIT		(01ULL << 29)	/* tail recursion */
273 #define	istail(n)	(((n) & (TAILBIT|MOT|'\n')) == (TAILBIT|'\n'))
274 #define	SENTSP		(01ULL << 29)	/* sentence space */
275 #define	issentsp(n)	((n) & SENTSP)
276 #define	DIBIT		(01ULL << 28)	/* written in a diversion */
277 #define	isdi(n)		((n) & DIBIT)
278 
279 #define	SMASK		(037777777LL << 40)
280 #define	FMASK		(0377LL << 32)
281 #define	SFMASK		(SMASK|FMASK)	/* size and font in a tchar */
282 #define	sbits(n)	(unsigned)(((n) >> 40) & 037777777)
283 #define	fbits(n)	(((n) >> 32) & 0377)
284 #define	sfbits(n)	(unsigned)(037777777777UL & (((n) & SFMASK) >> 32))
285 #define	cbits(n)	(unsigned)(0x003FFFFFLL & (n))	/* isolate bottom 22 bits  */
286 
287 #define	setsbits(n,s)	n = (n & ~SMASK) | (tchar)(s) << 40
288 #define	setfbits(n,f)	n = (n & ~FMASK) | (tchar)(f) << 32
289 #define	setsfbits(n,sf)	n = (n & ~SFMASK) | (tchar)(sf) << 32
290 #define	setcbits(n,c)	n = ((n & ~0x001FFFFFLL) | (c))	/* set character bits */
291 
292 #define	BYTEMASK	0377
293 #define	BYTE	8
294 
295 #define	ischar(n)	(((n) & ~BYTEMASK) == 0)
296 
297 #if defined (NROFF) && defined (EUC) && defined (ZWDELIMS)
298 #define ZWDELIM1	ZBIT | FIRSTOFMB | ' '	/* non-ASCII word delimiter 1 */
299 #define ZWDELIM2	ZBIT | MIDDLEOFMB | ' '	/* non-ASCII word delimiter 2 */
300 #define ZWDELIM(c)	((c) == 0) ? ' ' : ((c) == 1) ? ZWDELIM1 : ZWDELIM2
301 #endif	/* NROFF && EUC && ZWDELIMS */
302 
303 #define	ZONE	5	/* 5 hrs for EST */
304 #define	TABMASK	0x3FFFFFFF
305 #define	RTAB	(unsigned) 0x80000000
306 #define	CTAB	0x40000000
307 
308 #define	TABBIT	02		/* bits in gchtab */
309 #define	LDRBIT	04
310 #define	FCBIT	010
311 #define	LGBIT	020
312 #define	CHBIT	040
313 
314 #define	INFPENALTY0	(1e6)
315 #define	INFPENALTY	(1e9)
316 #define	MAXPENALTY	(1e6)
317 #define	PENALSCALE	(1.0/50)
318 
319 #define	PAIR(A,B)	(A|(B<<BYTE))
320 #define	LOOP		(-4)
321 
322 #ifndef EUC
323 #define	oput(c)	if ((*obufp++ = (c)), obufp >= &obuf[OBUFSZ]) flusho(); else
324 #else
325 #define	oput(c)	if ((*obufp++ = cbits(c) & BYTEMASK), obufp >= &obuf[OBUFSZ]) flusho(); else
326 #endif /* EUC */
327 
328 #ifdef	NROFF
329 #define	ftrans(f, c)	(c)
330 #else
331 #define	ftrans(f, c)	(f >= 0 && f <= nfonts ? ftrtab[f][ftrtab[f][c]] : (c))
332 #endif
333 
334 #define hex2nibble(x) ((x)>='0' && (x)<='9' ? (x)-'0'    : \
335                        (x)>='A' && (x)<='F' ? (x)-'A'+10 : \
336                                               (x)-'a'+10 )
337 
338 /*
339  * "temp file" parameters.  macros and strings
340  * are stored in an array of linked blocks,
341  * which may be in memory and an array called
342  * corebuf[].
343 
344  * The numerology is delicate if filep is 16 bits:
345 	#define BLK 128
346 	#define NBLIST 512
347  * i.e., the product is 16 bits long.
348 
349  * If filep is a long then NBLIST
350  * can be a lot bigger.  Of course that makes
351  * the file or core image a lot bigger too,
352  * and means you don't detect missing diversion
353  * terminations as quickly... .
354  * It also means that you may have trouble running
355  * on non-swapping systems, since the core image
356  * will be over 1Mb.
357 
358  * Note: As of 8/14/05, NBLIST has gone, and corebuf is
359  * grown dynamically as needed.
360 
361  * filep must be a signed integer since the value -1
362  * is special (it indicates that input is read from tty).
363 
364  * filep must be an int for LP64 platforms since it is
365  * casted to unsigned at some places (or changed there)
366 
367  * BLK must be a power of 2
368  */
369 
370 typedef int filep;
371 
372 #define	BLK	128	/* alloc block in tchars */
373 
374 /* Other things are stored in the temp file or corebuf:
375  *	a single block for .rd input, at offset RD_OFFSET
376  *	NEV copies of the environment block, at offset ENV_OFFSET
377 
378  * The existing implementation assumes very strongly that
379  * these are respectively NBLIST*BLK and 0.
380 
381  */
382 
383 #define	RD_OFFSET	(NBLIST * BLK)
384 #define ENV_OFFSET	0
385 #define	ENV_BLK		((NEV * sizeof(env) / sizeof(tchar) + BLK-1) / BLK)
386 				/* rounded up to even BLK */
387 
388 #include <setjmp.h>
389 #include <inttypes.h>
390 typedef	int64_t		tchar;
391 
392 extern	int	Inch, Hor, Vert, Unitwidth;
393 
394 /* BSD systems have a function devname(); avoid a collision */
395 #define	devname	troff_devname
396 
397 /* these characters are used as various signals or values
398  * in miscellaneous places.
399  * values are set in specnames in t10.c
400  */
401 
402 extern int	c_hyphen;
403 extern int	c_emdash;
404 extern int	c_rule;
405 extern int	c_minus;
406 extern int	c_fi;
407 extern int	c_fl;
408 extern int	c_ff;
409 extern int	c_ffi;
410 extern int	c_ffl;
411 extern int	c_acute;
412 extern int	c_grave;
413 extern int	c_under;
414 extern int	c_rooten;
415 extern int	c_boxrule;
416 extern int	c_lefthand;
417 extern int	c_dagger;
418 
419 struct lgtab {
420 	struct lgtab	*next;
421 	struct lgtab	*link;
422 	int	from;
423 	int	to;
424 };
425 
426 #ifdef	DEBUG
427 extern	int	debug;	/*debug flag*/
428 #define	DB_MAC	01	/*print out macro calls*/
429 #define	DB_ALLC	02	/*print out message from alloc()*/
430 #define	DB_GETC	04	/*print out message from getch()*/
431 #define	DB_LOOP	010	/*print out message before "Eileen's loop" fix*/
432 #define	DB_ABRT	020	/*abort on errprint()*/
433 #endif	/* DEBUG */
434 
435 extern enum warn {
436 	WARN_NONE	= 0,
437 	WARN_CHAR	= 1,
438 	WARN_NUMBER	= 2,
439 	WARN_BREAK	= 4,
440 	WARN_DELIM	= 8,
441 	WARN_EL		= 16,
442 	WARN_SCALE	= 32,
443 	WARN_RANGE	= 64,
444 	WARN_SYNTAX	= 128,
445 	WARN_DI		= 256,
446 	WARN_MAC	= 512,
447 	WARN_REG	= 1024,
448 	WARN_RIGHT_BRACE= 4096,
449 	WARN_MISSING	= 8192,
450 	WARN_INPUT	= 16384,
451 	WARN_ESCAPE	= 32768,
452 	WARN_SPACE	= 65536,
453 	WARN_FONT	= 131072,
454 	WARN_ALL	= 2147481855,	/* all except di, mac, reg */
455 	WARN_W		= 2147483647
456 } warn;
457 
458 enum flags {
459 	FLAG_WATCH	= 01,
460 	FLAG_STRING	= 02,
461 	FLAG_USED	= 04,
462 	FLAG_DIVERSION	= 010,
463 	FLAG_LOCAL	= 020,
464 	FLAG_PARAGRAPH	= 040
465 };
466 
467 enum {
468 	PG_NONE		= 00,
469 	PG_NEWIN	= 01,
470 	PG_NEWLL	= 02
471 };
472 
473 struct	d {	/* diversion */
474 	filep	op;
475 	int	dnl;
476 	int	dimac;
477 	int	ditrap;
478 	int	ditf;
479 	int	alss;
480 	int	blss;
481 	int	nls;
482 	int	mkline;
483 	int	maxl;
484 	int	hnl;
485 	int	curd;
486 	int	flss;
487 	struct contab	*soff;
488 	int	mlist[NTRAP];
489 	int	nlist[NTRAP];
490 	struct env	*boxenv;
491 };
492 
493 struct	charout {	/* formatted result of .char */
494 	filep	op;
495 	int	width;
496 	int	height;
497 	int	depth;
498 	tchar	ch;
499 };
500 
501 struct	s {	/* stack frame */
502 	int	nargs;
503 	struct s *pframe;
504 	filep	pip;
505 	filep	newip;
506 	int	*argt;
507 	tchar	*argsp;
508 	int	ppendt;
509 	tchar	pch;
510 	int	lastpbp;
511 	int	mname;
512 	int	frame_cnt;
513 	int	tail_cnt;
514 	struct contab	*contp;
515 	struct numtab	*numtab;
516 	struct numtab	**nhash;
517 	struct contab	*contab;
518 	struct contab	**mhash;
519 	int	NN;
520 	int	NM;
521 	enum {
522 		LOOP_FREE = 01,
523 		LOOP_NEXT = 02,
524 		LOOP_EVAL = 04
525 	} loopf;
526 	enum flags	flags;
527 	jmp_buf	*jmp;
528 };
529 
530 extern struct contab {
531 	unsigned int	rq;
532 	struct	contab *link;
533 	void	(*f)(int);
534 	unsigned mx;
535 	unsigned int	als;
536 	int	nlink;
537 	enum flags	flags;
538 } *contab;
539 extern const struct contab initcontab[];
540 
541 extern struct numtab {
542 	int	r;		/* name */
543 	short	fmt;
544 	int	inc;
545 	int	val;
546 	struct	numtab *link;
547 	int	aln;
548 	int	nlink;
549 	float	fval;
550 	float	finc;
551 	enum flags	flags;
552 } *numtab;
553 extern const struct numtab initnumtab[];
554 
555 #define	PN	0
556 #define	NL	1
557 #define	YR	2
558 #define	HP	3
559 #define	CT	4
560 #define	DN	5
561 #define	MO	6
562 #define	DY	7
563 #define	DW	8
564 #define	LN	9
565 #define	DL	10
566 #define	ST	11
567 #define	SB	12
568 #define	CD	13
569 #define	PID	14
570 
571 struct acc {
572 	long long	n;
573 	double	f;
574 };
575 
576 /* inline environment */
577 struct inlev {
578 	int	_apts;
579 	int	_apts1;
580 	int	_pts;
581 	int	_pts1;
582 	int	_font;
583 	int	_font1;
584 	int	_cc;
585 	int	_c2;
586 	int	_ohc;
587 	int	_hyf;
588 	int	_tabc;
589 	int	_dotc;
590 	int	_dpenal;
591 };
592 
593 /* the infamous environment block */
594 
595 #define	ics	env._ics
596 #define	sps	env._sps
597 #define	ses	env._ses
598 #define	spacesz	env._spacesz
599 #define	sesspsz	env._sesspsz
600 #ifndef	NROFF
601 #define	minsps	env._minsps
602 #define	minspsz	env._minspsz
603 #define	letspsz	env._letspsz
604 #define	letsps	env._letsps
605 #define	lspmin	env._lspmin
606 #define	lspmax	env._lspmax
607 #define	lspnc	env._lspnc
608 #define	lsplow	env._lsplow
609 #define	lsphigh	env._lsphigh
610 #define	lspcur	env._lspcur
611 #define	lsplast	env._lsplast
612 #define	lshmin	env._lshmin
613 #define	lshmax	env._lshmax
614 #define	lshwid	env._lshwid
615 #define	lshlow	env._lshlow
616 #define	lshhigh	env._lshhigh
617 #define	lshcur	env._lshcur
618 #else	/* NROFF */
619 #define	minsps	0
620 #define	minspsz	0
621 #define	letspsz	0
622 #define	letsps	0
623 #define	lspmin	0
624 #define	lspmax	0
625 #define	lspnc	0
626 #define	lsplow	0
627 #define	lsphigh	0
628 #define	lspcur	0
629 #define	lsplast	0
630 #define	lshmin	0
631 #define	lshmax	0
632 #define	lshwid	0
633 #define	lshlow	0
634 #define	lshhigh	0
635 #define	lshcur	0
636 #endif	/* NROFF */
637 #define	fldcnt	env._fldcnt
638 #define	lss	env._lss
639 #define	lss1	env._lss1
640 #define	ll	env._ll
641 #define	ll1	env._ll1
642 #define	lt	env._lt
643 #define	lt1	env._lt1
644 #define	ic	env._ic
645 #define	icf	env._icf
646 #define	chbits	env._chbits
647 #define	spbits	env._spbits
648 #define	nmbits	env._nmbits
649 #define	apts	env._apts
650 #define	apts1	env._apts1
651 #define	pts	env._pts
652 #define	pts1	env._pts1
653 #define	font	env._font
654 #define	font1	env._font1
655 #define	ls	env._ls
656 #define	ls1	env._ls1
657 #define	ad	env._ad
658 #define	nms	env._nms
659 #define	ndf	env._ndf
660 #define	fi	env._fi
661 #define	cc	env._cc
662 #define	c2	env._c2
663 #define	ohc	env._ohc
664 #define	tdelim	env._tdelim
665 #define	hyf	env._hyf
666 #define	hyoff	env._hyoff
667 #define	hlm	env._hlm
668 #define	hlc	env._hlc
669 #define	hylen	env._hylen
670 #define	hypp	env._hypp
671 #define	hypp2	env._hypp2
672 #define	hypp3	env._hypp3
673 #define	un1	env._un1
674 #define	tabc	env._tabc
675 #define	dotc	env._dotc
676 #define	adsp	env._adsp
677 #define	adrem	env._adrem
678 #define	lastl	env._lastl
679 #define	nel	env._nel
680 #define	admod	env._admod
681 #define	adflg	env._adflg
682 #define	adspc	env._adspc
683 #define	pa	env._pa
684 #define	wordp	env._wordp
685 #define	spflg	env._spflg
686 #define	seflg	env._seflg
687 #define	linep	env._linep
688 #define	wdend	env._wdend
689 #define	wdstart	env._wdstart
690 #define	wne	env._wne
691 #define	wsp	env._wsp
692 #define	ne	env._ne
693 #define	nc	env._nc
694 #define	nb	env._nb
695 #define	lnmod	env._lnmod
696 #define	nwd	env._nwd
697 #define	nn	env._nn
698 #define	ni	env._ni
699 #define	ul	env._ul
700 #define	cu	env._cu
701 #define	ce	env._ce
702 #define	rj	env._rj
703 #define	brnl	env._brnl
704 #define	brpnl	env._brpnl
705 #define	in	env._in
706 #define	in1	env._in1
707 #define	un	env._un
708 #define	wch	env._wch
709 #define	rhang	env._rhang
710 #define	pendt	env._pendt
711 #define	pendw	env._pendw
712 #define	pendnf	env._pendnf
713 #define	spread	env._spread
714 #define	dpenal	env._dpenal
715 #define	it	env._it
716 #define	itc	env._itc
717 #define	itmac	env._itmac
718 #define	lnsize	env._lnsize
719 #define	wdsize	env._wdsize
720 #define	pgsize	env._pgsize
721 #define	pgcsize	env._pgcsize
722 #define	pgssize	env._pgssize
723 #define	pgchars	env._pgchars
724 #define	pgspacs	env._pgspacs
725 #define	pgwords	env._pgwords
726 #define	pglines	env._pglines
727 #define	pglnout	env._pglnout
728 #define	pshapes	env._pshapes
729 #define	pgne	env._pgne
730 #define	pglastw	env._pglastw
731 #define	linkin	env._linkin
732 #define	linkout	env._linkout
733 #define	linkhp	env._linkhp
734 #define	hylang	env._hylang
735 #define	dicthnj	env._dicthnj
736 #define	hyext	env._hyext
737 #define	hcode	env._hcode
738 #define	nhcode	env._nhcode
739 #define	shc	env._shc
740 #define	lpfx	env._lpfx
741 #define	nlpfx	env._nlpfx
742 #define	stopch	env._stopch
743 #define	cht	env._cht
744 #define	cdp	env._cdp
745 #define	maxcht	env._maxcht
746 #define	maxcdp	env._maxcdp
747 #define	wdhyf	env._wdhyf
748 #define	hyptr	env._hyptr
749 #define	tabtab	env._tabtab
750 #define	line	env._line
751 #define	word	env._word
752 #define	wdpenal	env._wdpenal
753 #define	sentch	env._sentch
754 #define	transch	env._transch
755 #define	breakch	env._breakch
756 #define	nhych	env._nhych
757 #define	connectch	env._connectch
758 #define	para	env._para
759 #define	parsp	env._parsp
760 #define	pgwordp	env._pgwordp
761 #define	pgspacp	env._pgspacp
762 #define	pgwordw	env._pgwordw
763 #define	pghyphw	env._pghyphw
764 #define	pgadspc	env._pgadspc
765 #define	pglsphc	env._pglsphc
766 #define	pgopt	env._pgopt
767 #define	pgspacw	env._pgspacw
768 #define	pglgsc	env._pglgsc
769 #define	pglgec	env._pglgec
770 #define	pglgsw	env._pglgsw
771 #define	pglgew	env._pglgew
772 #define	pglgsh	env._pglgsh
773 #define	pglgeh	env._pglgeh
774 #define	pgin	env._pgin
775 #define	pgll	env._pgll
776 #define	pgwdin	env._pgwdin
777 #define	pgwdll	env._pgwdll
778 #define	pgflags	env._pgflags
779 #define	pglno	env._pglno
780 #define	pgpenal	env._pgpenal
781 #define	ninlev	env._ninlev
782 #define	ainlev	env._ainlev
783 #define	inlevp	env._inlevp
784 #define	evname	env._evname
785 
786 extern struct env {
787 	int	_ics;
788 	int	_sps;
789 	int	_ses;
790 	int	_spacesz;
791 	int	_sesspsz;
792 #ifndef	NROFF
793 	int	_minsps;
794 	int	_minspsz;
795 	int	_letspsz;
796 	int	_letsps;
797 	int	_lspmin;
798 	int	_lspmax;
799 	int	_lspnc;
800 	int	_lsplow;
801 	int	_lsphigh;
802 	int	_lspcur;
803 	int	_lsplast;
804 	int	_lshmin;
805 	int	_lshmax;
806 	int	_lshwid;
807 	int	_lshlow;
808 	int	_lshhigh;
809 	int	_lshcur;
810 #endif	/* !NROFF */
811 	int	_fldcnt;
812 	int	_lss;
813 	int	_lss1;
814 	int	_ll;
815 	int	_ll1;
816 	int	_lt;
817 	int	_lt1;
818 	tchar	_ic;
819 	int	_icf;
820 	tchar	_chbits;
821 	tchar	_spbits;
822 	tchar	_nmbits;
823 	int	_apts;
824 	int	_apts1;
825 	int	_pts;
826 	int	_pts1;
827 	int	_font;
828 	int	_font1;
829 	int	_ls;
830 	int	_ls1;
831 	int	_ad;
832 	int	_nms;
833 	int	_ndf;
834 	int	_fi;
835 	int	_cc;
836 	int	_c2;
837 	int	_ohc;
838 	int	_tdelim;
839 	int	_hyf;
840 	int	_hyoff;
841 	int	_hlm;
842 	int	_hlc;
843 	int	_hylen;
844 	float	_hypp;
845 	float	_hypp2;
846 	float	_hypp3;
847 	int	_un1;
848 	int	_tabc;
849 	int	_dotc;
850 	int	_adsp;
851 	int	_adrem;
852 	int	_lastl;
853 	int	_nel;
854 	int	_admod;
855 	int	_adflg;
856 	int	_adspc;
857 	int	_pa;
858 	tchar	*_wordp;
859 	int	_spflg;
860 	int	_seflg;
861 	tchar	*_linep;
862 	tchar	*_wdend;
863 	tchar	*_wdstart;
864 	int	_wne;
865 	int	_wsp;
866 	int	_ne;
867 	int	_nc;
868 	int	_nb;
869 	int	_lnmod;
870 	int	_nwd;
871 	int	_nn;
872 	int	_ni;
873 	int	_ul;
874 	int	_cu;
875 	int	_ce;
876 	int	_rj;
877 	int	_brnl;
878 	int	_brpnl;
879 	int	_in;
880 	int	_in1;
881 	int	_un;
882 	int	_wch;
883 	int	_rhang;
884 	int	_pendt;
885 	tchar	*_pendw;
886 	int	_pendnf;
887 	int	_spread;
888 	int	_dpenal;
889 	int	_it;
890 	int	_itc;
891 	int	_itmac;
892 	int	_lnsize;
893 	int	_wdsize;
894 	int	_pgsize;
895 	int	_pgcsize;
896 	int	_pgssize;
897 	int	_pgchars;
898 	int	_pgspacs;
899 	int	_pgwords;
900 	int	_pglines;
901 	int	_pglnout;
902 	int	_pshapes;
903 	int	_pgne;
904 	int	_pglastw;
905 	int	_linkin;
906 	int	_linkout;
907 	int	_linkhp;
908 	char	*_hylang;
909 	void	*_dicthnj;
910 	int	_hyext;
911 	int	*_hcode;
912 	int	_nhcode;
913 	tchar	*_lpfx;
914 	int	_nlpfx;
915 	int	_shc;
916 	tchar	_stopch;
917 	int	_cht;
918 	int	_cdp;
919 	int	_maxcht;
920 	int	_maxcdp;
921 	int	_wdhyf;
922 	tchar	*_hyptr[NHYP];
923 	int	_tabtab[NTAB];
924 	int	_sentch[NSENT];
925 	int	_transch[NSENT];
926 	int	_breakch[NSENT];
927 	int	_nhych[NSENT];
928 	int	_connectch[NSENT];
929 	tchar	*_line;
930 	tchar	*_word;
931 	int	*_wdpenal;
932 	tchar	*_para;
933 	tchar	*_parsp;
934 	int	*_pgwordp;
935 	int	*_pgspacp;
936 	int	*_pgwordw;
937 	int	*_pghyphw;
938 	int	*_pgadspc;
939 	int	*_pglsphc;
940 	int	*_pgopt;
941 	int	*_pgspacw;
942 	tchar	*_pglgsc;
943 	tchar	*_pglgec;
944 	tchar	*_pglgsw;
945 	tchar	*_pglgew;
946 	tchar	*_pglgsh;
947 	tchar	*_pglgeh;
948 	int	*_pgin;
949 	int	*_pgll;
950 	int	*_pgwdin;
951 	int	*_pgwdll;
952 	int	*_pglno;
953 	int	*_pgflags;
954 	float	*_pgpenal;
955 	int	_ninlev;
956 	int	_ainlev;
957 	struct inlev	*_inlevp;
958 	char	*_evname;
959 } env, initenv;
960