xref: /illumos-gate/usr/src/cmd/troff/tdef.h (revision e5190c10)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
287c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
327c478bd9Sstevel@tonic-gate  * The Regents of the University of California
337c478bd9Sstevel@tonic-gate  * All Rights Reserved
347c478bd9Sstevel@tonic-gate  *
357c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
367c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
377c478bd9Sstevel@tonic-gate  * contributors.
387c478bd9Sstevel@tonic-gate  */
40*e5190c10Smuffin #pragma ident	"%Z%%M%	%I%	%E% SMI"
427c478bd9Sstevel@tonic-gate /* starting values for typesetting parameters: */
447c478bd9Sstevel@tonic-gate #define	PS	10	/* default point size */
457c478bd9Sstevel@tonic-gate #define	FT	1	/* default font position */
467c478bd9Sstevel@tonic-gate #define ULFONT	2	/* default underline font */
477c478bd9Sstevel@tonic-gate #define	BDFONT	3	/* default emboldening font */
487c478bd9Sstevel@tonic-gate #define	BIFONT	4	/* default bold italic font */
497c478bd9Sstevel@tonic-gate #define	LL	(unsigned) 65*INCH/10	/* line length; 39picas=6.5in */
507c478bd9Sstevel@tonic-gate #define	VS	((12*INCH)/72)	/* initial vert space */
527c478bd9Sstevel@tonic-gate #ifdef	NROFF
537c478bd9Sstevel@tonic-gate #	define	EM	t.Em
547c478bd9Sstevel@tonic-gate #	define	HOR	t.Adj
557c478bd9Sstevel@tonic-gate #	define	VERT	t.Vert
567c478bd9Sstevel@tonic-gate #	define	INCH	240	/* increments per inch */
577c478bd9Sstevel@tonic-gate #	define	SPS	INCH/10	/* space size */
587c478bd9Sstevel@tonic-gate #	define	SS	INCH/10	/* " */
597c478bd9Sstevel@tonic-gate #	define	TRAILER	0
607c478bd9Sstevel@tonic-gate #	define	PO	0 /* page offset */
617c478bd9Sstevel@tonic-gate #	define	ASCII	1
627c478bd9Sstevel@tonic-gate #	define	PTID	1
637c478bd9Sstevel@tonic-gate #	define	LG	0
647c478bd9Sstevel@tonic-gate #	define	DTAB	0	/* set at 8 Ems at init time */
657c478bd9Sstevel@tonic-gate #	define	ICS	2*SPS
667c478bd9Sstevel@tonic-gate #endif
677c478bd9Sstevel@tonic-gate #ifndef NROFF	/* TROFF */
687c478bd9Sstevel@tonic-gate 	/* Inch is set by ptinit() when troff started. */
697c478bd9Sstevel@tonic-gate 	/* all derived values set then too
707c478bd9Sstevel@tonic-gate 	*/
717c478bd9Sstevel@tonic-gate #	define	INCH	Inch	/* troff resolution -- number of goobies/inch  */
727c478bd9Sstevel@tonic-gate #	define	POINT	(INCH/72)	/* goobies per point (1/72 inch) */
737c478bd9Sstevel@tonic-gate #	define	HOR	Hor	/* horizontal resolution in goobies */
747c478bd9Sstevel@tonic-gate #	define	VERT	Vert	/* vertical resolution in goobies */
757c478bd9Sstevel@tonic-gate #	define	SPS	(EM/3)	/* space size  */
767c478bd9Sstevel@tonic-gate #	define	SS	12	/* space size in 36ths of an em */
777c478bd9Sstevel@tonic-gate #	define	PO	(INCH)	/* page offset 1 inch */
787c478bd9Sstevel@tonic-gate /* #	define	EM	(POINT * pts) */
797c478bd9Sstevel@tonic-gate #define	EM	(((long) INCH * pts + 36) / 72)	/* don't lose significance */
807c478bd9Sstevel@tonic-gate #define	EMPTS(pts)	(((long) INCH * (pts) + 36) / 72)
817c478bd9Sstevel@tonic-gate #	define	ASCII	0
827c478bd9Sstevel@tonic-gate #	define	PTID	1
837c478bd9Sstevel@tonic-gate #	define	LG	1
847c478bd9Sstevel@tonic-gate #	define	DTAB	(INCH/2)
857c478bd9Sstevel@tonic-gate #	define	ICS	3*SPS
867c478bd9Sstevel@tonic-gate #endif
887c478bd9Sstevel@tonic-gate /* These "characters" are used to encode various internal functions
897c478bd9Sstevel@tonic-gate  * Some make use of the fact that most ascii characters between
907c478bd9Sstevel@tonic-gate  * 0 and 040 don't have any graphic or other function.
917c478bd9Sstevel@tonic-gate  * The few that do have a purpose (e.g., \n, \b, \t, ...
927c478bd9Sstevel@tonic-gate  * are avoided by the ad hoc choices here.
937c478bd9Sstevel@tonic-gate  * See ifilt[] in n1.c for others -- 1, 2, 3, 5, 6, 7, 010, 011, 012
947c478bd9Sstevel@tonic-gate  */
967c478bd9Sstevel@tonic-gate #define	LEADER	001
977c478bd9Sstevel@tonic-gate #define	IMP	004	/* impossible char; glues things together */
987c478bd9Sstevel@tonic-gate #define	TAB	011
997c478bd9Sstevel@tonic-gate #define	RPT	014	/* next character is to be repeated many times */
1007c478bd9Sstevel@tonic-gate #define	CHARHT	015	/* size field sets character height */
1017c478bd9Sstevel@tonic-gate #define	SLANT	016	/* size field sets amount of slant */
1027c478bd9Sstevel@tonic-gate #define	DRAWFCN	017	/* next several chars describe arb drawing fcn */
1037c478bd9Sstevel@tonic-gate 			/* line: 'l' dx dy char */
1047c478bd9Sstevel@tonic-gate 			/* circle: 'c' r */
1057c478bd9Sstevel@tonic-gate 			/* ellipse: 'e' rx ry */
1067c478bd9Sstevel@tonic-gate 			/* arc: 'a' dx dy r */
1077c478bd9Sstevel@tonic-gate 			/* wiggly line '~' x y x y ... */
1087c478bd9Sstevel@tonic-gate #define	DRAWLINE	'l'
1097c478bd9Sstevel@tonic-gate #define	DRAWCIRCLE	'c'	/* circle */
1107c478bd9Sstevel@tonic-gate #define	DRAWELLIPSE	'e'
1117c478bd9Sstevel@tonic-gate #define	DRAWARC		'a'	/* arbitrary arc */
1127c478bd9Sstevel@tonic-gate #define	DRAWSPLINE	'~'	/* quadratic B spline */
1147c478bd9Sstevel@tonic-gate #define	LEFT	020	/* \{ */
1157c478bd9Sstevel@tonic-gate #define	RIGHT	021	/* \} */
1167c478bd9Sstevel@tonic-gate #define	FILLER	022	/* \& and similar purposes */
1177c478bd9Sstevel@tonic-gate #define	XON	023	/* \X'...' starts here */
1187c478bd9Sstevel@tonic-gate #define	OHC	024	/* optional hyphenation character \% */
1197c478bd9Sstevel@tonic-gate #define	CONT	025	/* \c character */
1207c478bd9Sstevel@tonic-gate #define	PRESC	026	/* printable escape */
1217c478bd9Sstevel@tonic-gate #define	UNPAD	027	/* unpaddable blank */
1227c478bd9Sstevel@tonic-gate #define	XPAR	030	/* transparent mode indicator */
1237c478bd9Sstevel@tonic-gate #define	FLSS	031
1247c478bd9Sstevel@tonic-gate #define	WORDSP	032	/* paddable word space */
1257c478bd9Sstevel@tonic-gate #define	ESC	033
1267c478bd9Sstevel@tonic-gate #define	XOFF	034	/* \X'...' ends here */
1287c478bd9Sstevel@tonic-gate #define	iscontrol(n)	(n==035 || n==036)	/* used to test the next two */
1297c478bd9Sstevel@tonic-gate #define	HX	035	/* next character is value of \x'...' */
1307c478bd9Sstevel@tonic-gate #define	FONTPOS	036	/* position of font \f(XX encoded in top */
1327c478bd9Sstevel@tonic-gate #define	HYPHEN	c_hyphen
1337c478bd9Sstevel@tonic-gate #define	EMDASH	c_emdash	/* \(em */
1347c478bd9Sstevel@tonic-gate #define	RULE	c_rule		/* \(ru */
1357c478bd9Sstevel@tonic-gate #define	MINUS	c_minus		/* minus sign on current font */
1367c478bd9Sstevel@tonic-gate #define	LIG_FI	c_fi		/* \(ff */
1377c478bd9Sstevel@tonic-gate #define	LIG_FL	c_fl		/* \(fl */
1387c478bd9Sstevel@tonic-gate #define	LIG_FF	c_ff		/* \(ff */
1397c478bd9Sstevel@tonic-gate #define	LIG_FFI	c_ffi		/* \(Fi */
1407c478bd9Sstevel@tonic-gate #define	LIG_FFL	c_ffl		/* \(Fl */
1417c478bd9Sstevel@tonic-gate #define	ACUTE	c_acute		/* acute accent \(aa */
1427c478bd9Sstevel@tonic-gate #define	GRAVE	c_grave		/* grave accent \(ga */
1437c478bd9Sstevel@tonic-gate #define	UNDERLINE c_under	/* \(ul */
1447c478bd9Sstevel@tonic-gate #define	ROOTEN	c_rooten	/* root en \(rn */
1457c478bd9Sstevel@tonic-gate #define	BOXRULE	c_boxrule	/* box rule \(br */
1467c478bd9Sstevel@tonic-gate #define	LEFTHAND c_lefthand	/* left hand for word overflow */
1477c478bd9Sstevel@tonic-gate #define	DAGGER	c_dagger	/* dagger for footnotes */
1497c478bd9Sstevel@tonic-gate /* array sizes, and similar limits: */
1517c478bd9Sstevel@tonic-gate #define	NFONT	10	/* maximum number of fonts (including specials) */
1527c478bd9Sstevel@tonic-gate #define	EXTRAFONT 500	/* extra space for swapping a font */
1537c478bd9Sstevel@tonic-gate #define	NN	400	/* number registers */
1547c478bd9Sstevel@tonic-gate #define	NNAMES	15	 /* predefined reg names */
1557c478bd9Sstevel@tonic-gate #define	NIF	15	/* if-else nesting */
1567c478bd9Sstevel@tonic-gate #define	NS	128	/* name buffer */
1577c478bd9Sstevel@tonic-gate #define	NTM	256	/* tm buffer */
1587c478bd9Sstevel@tonic-gate #define	NEV	3	/* environments */
1597c478bd9Sstevel@tonic-gate #define	EVLSZ	10	/* size of ev stack */
1607c478bd9Sstevel@tonic-gate #define	DSIZE	512	/* disk sector size in chars */
1627c478bd9Sstevel@tonic-gate #define	NM	500	/* requests + macros */
1637c478bd9Sstevel@tonic-gate #define	DELTA	1024	/* delta core bytes */
1647c478bd9Sstevel@tonic-gate #define	NHYP	10	/* max hyphens per word */
1657c478bd9Sstevel@tonic-gate #define	NHEX	128	/* byte size of exception word list */
1667c478bd9Sstevel@tonic-gate #define	NTAB	40	/* tab stops */
1677c478bd9Sstevel@tonic-gate #define	NSO	5	/* "so" depth */
1687c478bd9Sstevel@tonic-gate #define	NMF	5	/* number of -m flags */
1697c478bd9Sstevel@tonic-gate #define	WDSIZE	540	/* word buffer size */
1707c478bd9Sstevel@tonic-gate #define	LNSIZE	680	/* line buffer size */
1717c478bd9Sstevel@tonic-gate #define	NDI	5	/* number of diversions */
1727c478bd9Sstevel@tonic-gate #define	NCHARS	512	/* maximum size of troff character set */
1737c478bd9Sstevel@tonic-gate #define	NTRTAB	NCHARS	/* number of items in trtab[] */
1747c478bd9Sstevel@tonic-gate #define	NWIDCACHE NCHARS	/* number of items in widcache */
1757c478bd9Sstevel@tonic-gate #define	NTRAP	20	/* number of traps */
1767c478bd9Sstevel@tonic-gate #define	NPN	20	/* numbers in "-o" */
1777c478bd9Sstevel@tonic-gate #define	FBUFSZ	256	/* field buf size words */
1787c478bd9Sstevel@tonic-gate #define	OBUFSZ	4096	/* bytes */
1797c478bd9Sstevel@tonic-gate #define	IBUFSZ	4096	/* bytes */
1807c478bd9Sstevel@tonic-gate #define	NC	1024	/* cbuf size words */
1817c478bd9Sstevel@tonic-gate #define	NOV	10	/* number of overstrike chars */
1827c478bd9Sstevel@tonic-gate #define	NPP	10	/* pads per field */
1847c478bd9Sstevel@tonic-gate /*
1857c478bd9Sstevel@tonic-gate 	Internal character representation:
1867c478bd9Sstevel@tonic-gate 	Internally, every character is carried around as
1877c478bd9Sstevel@tonic-gate 	a 32 bit cookie, called a "tchar" (typedef long).
1887c478bd9Sstevel@tonic-gate 	Bits are numbered 31..0 from left to right.
1897c478bd9Sstevel@tonic-gate 	If bit 15 is 1, the character is motion, with
1907c478bd9Sstevel@tonic-gate 		if bit 16 it's vertical motion
1917c478bd9Sstevel@tonic-gate 		if bit 17 it's negative motion
1927c478bd9Sstevel@tonic-gate 	If bit 15 is 0, the character is a real character.
1937c478bd9Sstevel@tonic-gate 		if bit 31	zero motion
1947c478bd9Sstevel@tonic-gate 		bits 30..24	size
1957c478bd9Sstevel@tonic-gate 		bits 23..16	font
1967c478bd9Sstevel@tonic-gate ifndef EUC
1977c478bd9Sstevel@tonic-gate 		bit 8		absolute char number in 7..0
1987c478bd9Sstevel@tonic-gate 	This implies at most 256-32 characters in a single font,
1997c478bd9Sstevel@tonic-gate 	which is going to be a problem somewhere
2007c478bd9Sstevel@tonic-gate else
2017c478bd9Sstevel@tonic-gate 		bits 14,13	identifier for the colunm of print of character.
2027c478bd9Sstevel@tonic-gate 		bits 12,11	multibyte position identifier
2037c478bd9Sstevel@tonic-gate 	Currently, this applies only to nroff.
2047c478bd9Sstevel@tonic-gate endif EUC
2057c478bd9Sstevel@tonic-gate */
2077c478bd9Sstevel@tonic-gate /* in the following, "L" should really be a tchar, but ... */
2097c478bd9Sstevel@tonic-gate #define	MOT	(01L<<15)	/* motion character indicator */
2107c478bd9Sstevel@tonic-gate #define	MOTV	(07L<<15)	/* clear for motion part */
2117c478bd9Sstevel@tonic-gate #define	VMOT	(01L<<16)	/* vert motion bit */
2127c478bd9Sstevel@tonic-gate #define	NMOT	(01L<<17)	/* negative motion indicator*/
2137c478bd9Sstevel@tonic-gate #define	MAXMOT	32767	/* bad way to write this!!! */
2147c478bd9Sstevel@tonic-gate #define	ismot(n)	((n) & MOT)
2157c478bd9Sstevel@tonic-gate #define	isvmot(n)	((n) & VMOT)	/* must have tested MOT previously */
2167c478bd9Sstevel@tonic-gate #define	isnmot(n)	((n) & NMOT)	/* ditto */
2177c478bd9Sstevel@tonic-gate #define	absmot(n)	(unsigned)(0177777 & (n) & ~MOT)	/* (short) is cheap mask */
2197c478bd9Sstevel@tonic-gate #define	ZBIT	0x80000000 	/*  (01L << 31) */	/* zero width char */
2207c478bd9Sstevel@tonic-gate #define	iszbit(n)	((n) & ZBIT)
2217c478bd9Sstevel@tonic-gate #define	ABSCHAR		0400	/* absolute char number in this font */
2237c478bd9Sstevel@tonic-gate #define	SMASK		(0177L << 24)
2247c478bd9Sstevel@tonic-gate #define	FMASK		(0377L << 16)
2257c478bd9Sstevel@tonic-gate #define	SFMASK		(SMASK|FMASK)	/* size and font in a tchar */
2267c478bd9Sstevel@tonic-gate #define	sbits(n)	(unsigned)(((n) >> 24) & 0177)
2277c478bd9Sstevel@tonic-gate #define	fbits(n)	(((n) >> 16) & 0377)
2287c478bd9Sstevel@tonic-gate #define	sfbits(n)	(unsigned)(0177777 & (((n) & SFMASK) >> 16))
2297c478bd9Sstevel@tonic-gate #define	cbits(n)	(unsigned)(0177777 & (n))	/* isolate bottom 16 bits  */
2307c478bd9Sstevel@tonic-gate #define	absbits(n)	(cbits(n) & ~ABSCHAR)
2327c478bd9Sstevel@tonic-gate #define	setsbits(n,s)	n = (n & ~SMASK) | (tchar)(s) << 24
2337c478bd9Sstevel@tonic-gate #define	setfbits(n,f)	n = (n & ~FMASK) | (tchar)(f) << 16
2347c478bd9Sstevel@tonic-gate #define	setsfbits(n,sf)	n = (n & ~SFMASK) | (tchar)(sf) << 16
2357c478bd9Sstevel@tonic-gate #define	setcbits(n,c)	n = (n & ~077777L | (c))	/* set character bits */
2377c478bd9Sstevel@tonic-gate #define	BYTEMASK	0377
2387c478bd9Sstevel@tonic-gate #define	BYTE	8
2407c478bd9Sstevel@tonic-gate #define	ischar(n)	(((n) & ~BYTEMASK) == 0)
2427c478bd9Sstevel@tonic-gate #ifdef EUC
2437c478bd9Sstevel@tonic-gate #ifdef NROFF
2447c478bd9Sstevel@tonic-gate #define CSMASK	0x6000	/* colunm of print identifier */
2457c478bd9Sstevel@tonic-gate #define MBMASK	0x1c00	/* bits identifying position in a multibyte char */
2467c478bd9Sstevel@tonic-gate #define MBMASK1	0x1800
2477c478bd9Sstevel@tonic-gate #define FIRSTOFMB	0x1000
2487c478bd9Sstevel@tonic-gate #define MIDDLEOFMB	0x0800
2497c478bd9Sstevel@tonic-gate #define LASTOFMB	0x0400
2507c478bd9Sstevel@tonic-gate #define BYTE_CHR	0x0000
2517c478bd9Sstevel@tonic-gate #define	cs(n)	(((n) & CSMASK) >> 13)	/* colum of print of character */
2527c478bd9Sstevel@tonic-gate #define	setcsbits(n,c)	n = ((n & ~CSMASK) | ((c) << 13))
2537c478bd9Sstevel@tonic-gate #define CHMASK	(BYTEMASK | CSMASK | MBMASK)
2547c478bd9Sstevel@tonic-gate #define ZWDELIM1	ZBIT | FIRSTOFMB | ' '	/* non-ASCII word delimiter 1 */
2557c478bd9Sstevel@tonic-gate #define ZWDELIM2	ZBIT | MIDDLEOFMB | ' '	/* non-ASCII word delimiter 2 */
2567c478bd9Sstevel@tonic-gate #define ZWDELIM(c)	((c) == 0) ? ' ' : ((c) == 1) ? ZWDELIM1 : ZWDELIM2
2577c478bd9Sstevel@tonic-gate #endif /* NROFF */
2587c478bd9Sstevel@tonic-gate #endif /* EUC */
2607c478bd9Sstevel@tonic-gate #define	ZONE	5	/* 5 hrs for EST */
2617c478bd9Sstevel@tonic-gate #define	TABMASK	 037777
2627c478bd9Sstevel@tonic-gate #define	RTAB	(unsigned) 0100000
2637c478bd9Sstevel@tonic-gate #define	CTAB	040000
2657c478bd9Sstevel@tonic-gate #define	TABBIT	02		/* bits in gchtab */
2667c478bd9Sstevel@tonic-gate #define	LDRBIT	04
2677c478bd9Sstevel@tonic-gate #define	FCBIT	010
2697c478bd9Sstevel@tonic-gate #define	PAIR(A,B)	(A|(B<<BYTE))
2717c478bd9Sstevel@tonic-gate #ifndef EUC
2727c478bd9Sstevel@tonic-gate #define	oput(c)	if ((*obufp++ = (c)), obufp >= &obuf[OBUFSZ]) flusho(); else
2737c478bd9Sstevel@tonic-gate #else
2747c478bd9Sstevel@tonic-gate #ifndef NROFF
2757c478bd9Sstevel@tonic-gate #define	oput(c)	if ((*obufp++ = (c)), obufp >= &obuf[OBUFSZ]) flusho(); else
2767c478bd9Sstevel@tonic-gate #endif /* NROFF */
2777c478bd9Sstevel@tonic-gate #define	oput(c)	if ((*obufp++ = cbits(c) & BYTEMASK), obufp >= &obuf[OBUFSZ]) flusho(); else
2787c478bd9Sstevel@tonic-gate #endif /* EUC */
2807c478bd9Sstevel@tonic-gate /*
2817c478bd9Sstevel@tonic-gate  * "temp file" parameters.  macros and strings
2827c478bd9Sstevel@tonic-gate  * are stored in an array of linked blocks,
2837c478bd9Sstevel@tonic-gate  * which may be in memory and an array called
2847c478bd9Sstevel@tonic-gate  * corebuf[], if INCORE is set during
2857c478bd9Sstevel@tonic-gate  * compilation, or otherwise in a file called trtmp$$.
2877c478bd9Sstevel@tonic-gate  * The numerology is delicate if filep is 16 bits:
2887c478bd9Sstevel@tonic-gate 	#define BLK 128
2897c478bd9Sstevel@tonic-gate 	#define NBLIST 512
2907c478bd9Sstevel@tonic-gate  * i.e., the product is 16 bits long.
2927c478bd9Sstevel@tonic-gate  * If filep is an unsigned long (and if your
2937c478bd9Sstevel@tonic-gate  * compiler will let you say that) then NBLIST
2947c478bd9Sstevel@tonic-gate  * can be a lot bigger.  Of course that makes
2957c478bd9Sstevel@tonic-gate  * the file or core image a lot bigger too,
2967c478bd9Sstevel@tonic-gate  * and means you don't detect missing diversion
2977c478bd9Sstevel@tonic-gate  * terminations as quickly... .
2987c478bd9Sstevel@tonic-gate  * It also means that you may have trouble running
2997c478bd9Sstevel@tonic-gate  * on non-swapping systems, since the core image
3007c478bd9Sstevel@tonic-gate  * will be over 1Mb.
3027c478bd9Sstevel@tonic-gate  * BLK must be a power of 2
3037c478bd9Sstevel@tonic-gate  */
3057c478bd9Sstevel@tonic-gate typedef unsigned int filep;	/* this is good for 32 bit machines */
3077c478bd9Sstevel@tonic-gate #define	BLK	128	/* alloc block in tchars */
3097c478bd9Sstevel@tonic-gate #ifdef SMALLER
3107c478bd9Sstevel@tonic-gate #	define	NBLIST	512
3117c478bd9Sstevel@tonic-gate #else
3127c478bd9Sstevel@tonic-gate #	define	NBLIST	1024	/* allocation list.  smallish machines use 512 */
3137c478bd9Sstevel@tonic-gate 				/* machines with paging can use 2048 */
3147c478bd9Sstevel@tonic-gate #endif
3167c478bd9Sstevel@tonic-gate /* Other things are stored in the temp file or corebuf:
3177c478bd9Sstevel@tonic-gate  *	a single block for .rd input, at offset RD_OFFSET
3187c478bd9Sstevel@tonic-gate  *	NEV copies of the environment block, at offset ENV_OFFSET
3207c478bd9Sstevel@tonic-gate  * The existing implementation assumes very strongly that
3217c478bd9Sstevel@tonic-gate  * these are respectively NBLIST*BLK and 0.
3237c478bd9Sstevel@tonic-gate  */
3257c478bd9Sstevel@tonic-gate #define	RD_OFFSET	(NBLIST * BLK)
3267c478bd9Sstevel@tonic-gate #define ENV_OFFSET	0
3277c478bd9Sstevel@tonic-gate #define	ENV_BLK		((NEV * sizeof(env) / sizeof(tchar) + BLK-1) / BLK)
3287c478bd9Sstevel@tonic-gate 				/* rounded up to even BLK */
3307c478bd9Sstevel@tonic-gate typedef	long	tchar;
3327c478bd9Sstevel@tonic-gate extern	tchar	getch(), getch0();
3337c478bd9Sstevel@tonic-gate extern	tchar	rbf(), rbf0();
3347c478bd9Sstevel@tonic-gate extern	tchar	mot(), hmot(), vmot();
3357c478bd9Sstevel@tonic-gate extern	tchar	makem(), sethl();
3367c478bd9Sstevel@tonic-gate extern	tchar	popi();
3377c478bd9Sstevel@tonic-gate extern	tchar	getlg();
3387c478bd9Sstevel@tonic-gate extern	tchar	xlss();
3397c478bd9Sstevel@tonic-gate extern	tchar	setfield();
3407c478bd9Sstevel@tonic-gate extern	tchar	setz();
3417c478bd9Sstevel@tonic-gate extern	tchar	setch();
3427c478bd9Sstevel@tonic-gate extern	tchar	setht(), setslant();
3447c478bd9Sstevel@tonic-gate #define	atoi(i)		((int) atoi0(i))
3457c478bd9Sstevel@tonic-gate extern	long	atoi0();
3477c478bd9Sstevel@tonic-gate extern	int	Inch, Hor, Vert, Unitwidth;
3497c478bd9Sstevel@tonic-gate /* these characters are used as various signals or values
3507c478bd9Sstevel@tonic-gate  * in miscellaneous places.
3517c478bd9Sstevel@tonic-gate  * values are set in specnames in t10.c
3527c478bd9Sstevel@tonic-gate  */
3547c478bd9Sstevel@tonic-gate extern int	c_hyphen;
3557c478bd9Sstevel@tonic-gate extern int	c_emdash;
3567c478bd9Sstevel@tonic-gate extern int	c_rule;
3577c478bd9Sstevel@tonic-gate extern int	c_minus;
3587c478bd9Sstevel@tonic-gate extern int	c_fi;
3597c478bd9Sstevel@tonic-gate extern int	c_fl;
3607c478bd9Sstevel@tonic-gate extern int	c_ff;
3617c478bd9Sstevel@tonic-gate extern int	c_ffi;
3627c478bd9Sstevel@tonic-gate extern int	c_ffl;
3637c478bd9Sstevel@tonic-gate extern int	c_acute;
3647c478bd9Sstevel@tonic-gate extern int	c_grave;
3657c478bd9Sstevel@tonic-gate extern int	c_under;
3667c478bd9Sstevel@tonic-gate extern int	c_rooten;
3677c478bd9Sstevel@tonic-gate extern int	c_boxrule;
3687c478bd9Sstevel@tonic-gate extern int	c_lefthand;
3697c478bd9Sstevel@tonic-gate extern int	c_dagger;
3717c478bd9Sstevel@tonic-gate /*
3727c478bd9Sstevel@tonic-gate  * <widec.h> includes <stdio.h> which defines
3737c478bd9Sstevel@tonic-gate  * stderr. So undef it if it is already defined.
3747c478bd9Sstevel@tonic-gate  */
3757c478bd9Sstevel@tonic-gate #ifdef stderr
3767c478bd9Sstevel@tonic-gate #	undef stderr
3777c478bd9Sstevel@tonic-gate #endif
3787c478bd9Sstevel@tonic-gate extern int	stderr;	/* this is NOT the stdio value! */
3807c478bd9Sstevel@tonic-gate #ifdef	DEBUG
3817c478bd9Sstevel@tonic-gate extern	int	debug;	/*debug flag*/
3827c478bd9Sstevel@tonic-gate #define	DB_MAC	01	/*print out macro calls*/
3837c478bd9Sstevel@tonic-gate #define	DB_ALLC	02	/*print out message from alloc()*/
3847c478bd9Sstevel@tonic-gate #define	DB_GETC	04	/*print out message from getch()*/
3857c478bd9Sstevel@tonic-gate #define	DB_LOOP	010	/*print out message before "Eileen's loop" fix*/
386*e5190c10Smuffin #endif	/* DEBUG */
388*e5190c10Smuffin struct	d {	/* diversion */
3897c478bd9Sstevel@tonic-gate 	filep	op;
3907c478bd9Sstevel@tonic-gate 	int	dnl;
3917c478bd9Sstevel@tonic-gate 	int	dimac;
3927c478bd9Sstevel@tonic-gate 	int	ditrap;
3937c478bd9Sstevel@tonic-gate 	int	ditf;
3947c478bd9Sstevel@tonic-gate 	int	alss;
3957c478bd9Sstevel@tonic-gate 	int	blss;
3967c478bd9Sstevel@tonic-gate 	int	nls;
3977c478bd9Sstevel@tonic-gate 	int	mkline;
3987c478bd9Sstevel@tonic-gate 	int	maxl;
3997c478bd9Sstevel@tonic-gate 	int	hnl;
4007c478bd9Sstevel@tonic-gate 	int	curd;
4017c478bd9Sstevel@tonic-gate };
403*e5190c10Smuffin struct	s {	/* stack frame */
4047c478bd9Sstevel@tonic-gate 	int	nargs;
4057c478bd9Sstevel@tonic-gate 	struct s *pframe;
4067c478bd9Sstevel@tonic-gate 	filep	pip;
4077c478bd9Sstevel@tonic-gate 	int	pnchar;
4087c478bd9Sstevel@tonic-gate 	tchar	prchar;
4097c478bd9Sstevel@tonic-gate 	int	ppendt;
4107c478bd9Sstevel@tonic-gate 	tchar	pch;
4117c478bd9Sstevel@tonic-gate 	tchar	*lastpbp;
4127c478bd9Sstevel@tonic-gate 	int	mname;
4137c478bd9Sstevel@tonic-gate };
4157c478bd9Sstevel@tonic-gate extern struct contab {
4167c478bd9Sstevel@tonic-gate 	unsigned short	rq;
4177c478bd9Sstevel@tonic-gate 	struct	contab *link;
4187c478bd9Sstevel@tonic-gate 	int	(*f)();
4197c478bd9Sstevel@tonic-gate 	unsigned mx;
4207c478bd9Sstevel@tonic-gate } contab[NM];
4227c478bd9Sstevel@tonic-gate extern struct numtab {
4237c478bd9Sstevel@tonic-gate 	short	r;		/* name */
4247c478bd9Sstevel@tonic-gate 	short	fmt;
4257c478bd9Sstevel@tonic-gate 	short	inc;
4267c478bd9Sstevel@tonic-gate 	int	val;
4277c478bd9Sstevel@tonic-gate 	struct	numtab *link;
4287c478bd9Sstevel@tonic-gate } numtab[NN];
4307c478bd9Sstevel@tonic-gate #define	PN	0
4317c478bd9Sstevel@tonic-gate #define	NL	1
4327c478bd9Sstevel@tonic-gate #define	YR	2
4337c478bd9Sstevel@tonic-gate #define	HP	3
4347c478bd9Sstevel@tonic-gate #define	CT	4
4357c478bd9Sstevel@tonic-gate #define	DN	5
4367c478bd9Sstevel@tonic-gate #define	MO	6
4377c478bd9Sstevel@tonic-gate #define	DY	7
4387c478bd9Sstevel@tonic-gate #define	DW	8
4397c478bd9Sstevel@tonic-gate #define	LN	9
4407c478bd9Sstevel@tonic-gate #define	DL	10
4417c478bd9Sstevel@tonic-gate #define	ST	11
4427c478bd9Sstevel@tonic-gate #define	SB	12
4437c478bd9Sstevel@tonic-gate #define	CD	13
4447c478bd9Sstevel@tonic-gate #define	PID	14
4467c478bd9Sstevel@tonic-gate /* the infamous environment block */
4487c478bd9Sstevel@tonic-gate #define	ics	env._ics
4497c478bd9Sstevel@tonic-gate #define	sps	env._sps
4507c478bd9Sstevel@tonic-gate #define	spacesz	env._spacesz
4517c478bd9Sstevel@tonic-gate #define	lss	env._lss
4527c478bd9Sstevel@tonic-gate #define	lss1	env._lss1
4537c478bd9Sstevel@tonic-gate #define	ll	env._ll
4547c478bd9Sstevel@tonic-gate #define	ll1	env._ll1
4557c478bd9Sstevel@tonic-gate #define	lt	env._lt
4567c478bd9Sstevel@tonic-gate #define	lt1	env._lt1
4577c478bd9Sstevel@tonic-gate #define	ic	env._ic
4587c478bd9Sstevel@tonic-gate #define	icf	env._icf
4597c478bd9Sstevel@tonic-gate #define	chbits	env._chbits
4607c478bd9Sstevel@tonic-gate #define	spbits	env._spbits
4617c478bd9Sstevel@tonic-gate #define	nmbits	env._nmbits
4627c478bd9Sstevel@tonic-gate #define	apts	env._apts
4637c478bd9Sstevel@tonic-gate #define	apts1	env._apts1
4647c478bd9Sstevel@tonic-gate #define	pts	env._pts
4657c478bd9Sstevel@tonic-gate #define	pts1	env._pts1
4667c478bd9Sstevel@tonic-gate #define	font	env._font
4677c478bd9Sstevel@tonic-gate #define	font1	env._font1
4687c478bd9Sstevel@tonic-gate #define	ls	env._ls
4697c478bd9Sstevel@tonic-gate #define	ls1	env._ls1
4707c478bd9Sstevel@tonic-gate #define	ad	env._ad
4717c478bd9Sstevel@tonic-gate #define	nms	env._nms
4727c478bd9Sstevel@tonic-gate #define	ndf	env._ndf
4737c478bd9Sstevel@tonic-gate #define	fi	env._fi
4747c478bd9Sstevel@tonic-gate #define	cc	env._cc
4757c478bd9Sstevel@tonic-gate #define	c2	env._c2
4767c478bd9Sstevel@tonic-gate #define	ohc	env._ohc
4777c478bd9Sstevel@tonic-gate #define	tdelim	env._tdelim
4787c478bd9Sstevel@tonic-gate #define	hyf	env._hyf
4797c478bd9Sstevel@tonic-gate #define	hyoff	env._hyoff
4807c478bd9Sstevel@tonic-gate #define	un1	env._un1
4817c478bd9Sstevel@tonic-gate #define	tabc	env._tabc
4827c478bd9Sstevel@tonic-gate #define	dotc	env._dotc
4837c478bd9Sstevel@tonic-gate #define	adsp	env._adsp
4847c478bd9Sstevel@tonic-gate #define	adrem	env._adrem
4857c478bd9Sstevel@tonic-gate #define	lastl	env._lastl
4867c478bd9Sstevel@tonic-gate #define	nel	env._nel
4877c478bd9Sstevel@tonic-gate #define	admod	env._admod
4887c478bd9Sstevel@tonic-gate #define	wordp	env._wordp
4897c478bd9Sstevel@tonic-gate #define	spflg	env._spflg
4907c478bd9Sstevel@tonic-gate #define	linep	env._linep
4917c478bd9Sstevel@tonic-gate #define	wdend	env._wdend
4927c478bd9Sstevel@tonic-gate #define	wdstart	env._wdstart
4937c478bd9Sstevel@tonic-gate #define	wne	env._wne
4947c478bd9Sstevel@tonic-gate #define	ne	env._ne
4957c478bd9Sstevel@tonic-gate #define	nc	env._nc
4967c478bd9Sstevel@tonic-gate #define	nb	env._nb
4977c478bd9Sstevel@tonic-gate #define	lnmod	env._lnmod
4987c478bd9Sstevel@tonic-gate #define	nwd	env._nwd
4997c478bd9Sstevel@tonic-gate #define	nn	env._nn
5007c478bd9Sstevel@tonic-gate #define	ni	env._ni
5017c478bd9Sstevel@tonic-gate #define	ul	env._ul
5027c478bd9Sstevel@tonic-gate #define	cu	env._cu
5037c478bd9Sstevel@tonic-gate #define	ce	env._ce
5047c478bd9Sstevel@tonic-gate #define	in	env._in
5057c478bd9Sstevel@tonic-gate #define	in1	env._in1
5067c478bd9Sstevel@tonic-gate #define	un	env._un
5077c478bd9Sstevel@tonic-gate #define	wch	env._wch
5087c478bd9Sstevel@tonic-gate #define	pendt	env._pendt
5097c478bd9Sstevel@tonic-gate #define	pendw	env._pendw
5107c478bd9Sstevel@tonic-gate #define	pendnf	env._pendnf
5117c478bd9Sstevel@tonic-gate #define	spread	env._spread
5127c478bd9Sstevel@tonic-gate #define	it	env._it
5137c478bd9Sstevel@tonic-gate #define	itmac	env._itmac
5147c478bd9Sstevel@tonic-gate #define	lnsize	env._lnsize
5157c478bd9Sstevel@tonic-gate #define	hyptr	env._hyptr
5167c478bd9Sstevel@tonic-gate #define	tabtab	env._tabtab
5177c478bd9Sstevel@tonic-gate #define	line	env._line
5187c478bd9Sstevel@tonic-gate #define	word	env._word
5207c478bd9Sstevel@tonic-gate extern struct env {
5217c478bd9Sstevel@tonic-gate 	int	_ics;
5227c478bd9Sstevel@tonic-gate 	int	_sps;
5237c478bd9Sstevel@tonic-gate 	int	_spacesz;
5247c478bd9Sstevel@tonic-gate 	int	_lss;
5257c478bd9Sstevel@tonic-gate 	int	_lss1;
5267c478bd9Sstevel@tonic-gate 	int	_ll;
5277c478bd9Sstevel@tonic-gate 	int	_ll1;
5287c478bd9Sstevel@tonic-gate 	int	_lt;
5297c478bd9Sstevel@tonic-gate 	int	_lt1;
5307c478bd9Sstevel@tonic-gate 	tchar	_ic;
5317c478bd9Sstevel@tonic-gate 	int	_icf;
5327c478bd9Sstevel@tonic-gate 	tchar	_chbits;
5337c478bd9Sstevel@tonic-gate 	tchar	_spbits;
5347c478bd9Sstevel@tonic-gate 	tchar	_nmbits;
5357c478bd9Sstevel@tonic-gate 	int	_apts;
5367c478bd9Sstevel@tonic-gate 	int	_apts1;
5377c478bd9Sstevel@tonic-gate 	int	_pts;
5387c478bd9Sstevel@tonic-gate 	int	_pts1;
5397c478bd9Sstevel@tonic-gate 	int	_font;
5407c478bd9Sstevel@tonic-gate 	int	_font1;
5417c478bd9Sstevel@tonic-gate 	int	_ls;
5427c478bd9Sstevel@tonic-gate 	int	_ls1;
5437c478bd9Sstevel@tonic-gate 	int	_ad;
5447c478bd9Sstevel@tonic-gate 	int	_nms;
5457c478bd9Sstevel@tonic-gate 	int	_ndf;
5467c478bd9Sstevel@tonic-gate 	int	_fi;
5477c478bd9Sstevel@tonic-gate 	int	_cc;
5487c478bd9Sstevel@tonic-gate 	int	_c2;
5497c478bd9Sstevel@tonic-gate 	int	_ohc;
5507c478bd9Sstevel@tonic-gate 	int	_tdelim;
5517c478bd9Sstevel@tonic-gate 	int	_hyf;
5527c478bd9Sstevel@tonic-gate 	int	_hyoff;
5537c478bd9Sstevel@tonic-gate 	int	_un1;
5547c478bd9Sstevel@tonic-gate 	int	_tabc;
5557c478bd9Sstevel@tonic-gate 	int	_dotc;
5567c478bd9Sstevel@tonic-gate 	int	_adsp;
5577c478bd9Sstevel@tonic-gate 	int	_adrem;
5587c478bd9Sstevel@tonic-gate 	int	_lastl;
5597c478bd9Sstevel@tonic-gate 	int	_nel;
5607c478bd9Sstevel@tonic-gate 	int	_admod;
5617c478bd9Sstevel@tonic-gate 	tchar	*_wordp;
5627c478bd9Sstevel@tonic-gate 	int	_spflg;
5637c478bd9Sstevel@tonic-gate 	tchar	*_linep;
5647c478bd9Sstevel@tonic-gate 	tchar	*_wdend;
5657c478bd9Sstevel@tonic-gate 	tchar	*_wdstart;
5667c478bd9Sstevel@tonic-gate 	int	_wne;
5677c478bd9Sstevel@tonic-gate 	int	_ne;
5687c478bd9Sstevel@tonic-gate 	int	_nc;
5697c478bd9Sstevel@tonic-gate 	int	_nb;
5707c478bd9Sstevel@tonic-gate 	int	_lnmod;
5717c478bd9Sstevel@tonic-gate 	int	_nwd;
5727c478bd9Sstevel@tonic-gate 	int	_nn;
5737c478bd9Sstevel@tonic-gate 	int	_ni;
5747c478bd9Sstevel@tonic-gate 	int	_ul;
5757c478bd9Sstevel@tonic-gate 	int	_cu;
5767c478bd9Sstevel@tonic-gate 	int	_ce;
5777c478bd9Sstevel@tonic-gate 	int	_in;
5787c478bd9Sstevel@tonic-gate 	int	_in1;
5797c478bd9Sstevel@tonic-gate 	int	_un;
5807c478bd9Sstevel@tonic-gate 	int	_wch;
5817c478bd9Sstevel@tonic-gate 	int	_pendt;
5827c478bd9Sstevel@tonic-gate 	tchar	*_pendw;
5837c478bd9Sstevel@tonic-gate 	int	_pendnf;
5847c478bd9Sstevel@tonic-gate 	int	_spread;
5857c478bd9Sstevel@tonic-gate 	int	_it;
5867c478bd9Sstevel@tonic-gate 	int	_itmac;
5877c478bd9Sstevel@tonic-gate 	int	_lnsize;
5887c478bd9Sstevel@tonic-gate 	tchar	*_hyptr[NHYP];
5897c478bd9Sstevel@tonic-gate 	int	_tabtab[NTAB];
5907c478bd9Sstevel@tonic-gate 	tchar	_line[LNSIZE];
5917c478bd9Sstevel@tonic-gate 	tchar	_word[WDSIZE];
5927c478bd9Sstevel@tonic-gate } env;