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