1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate /* 34*7c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 35*7c478bd9Sstevel@tonic-gate * The Regents of the University of California 36*7c478bd9Sstevel@tonic-gate * All Rights Reserved 37*7c478bd9Sstevel@tonic-gate * 38*7c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 39*7c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 40*7c478bd9Sstevel@tonic-gate * contributors. 41*7c478bd9Sstevel@tonic-gate */ 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate /* starting values for typesetting parameters: */ 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate #define PS 10 /* default point size */ 46*7c478bd9Sstevel@tonic-gate #define FT 1 /* default font position */ 47*7c478bd9Sstevel@tonic-gate #define ULFONT 2 /* default underline font */ 48*7c478bd9Sstevel@tonic-gate #define BDFONT 3 /* default emboldening font */ 49*7c478bd9Sstevel@tonic-gate #define BIFONT 4 /* default bold italic font */ 50*7c478bd9Sstevel@tonic-gate #define LL (unsigned) 65*INCH/10 /* line length; 39picas=6.5in */ 51*7c478bd9Sstevel@tonic-gate #define VS ((12*INCH)/72) /* initial vert space */ 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate #ifdef NROFF 54*7c478bd9Sstevel@tonic-gate # define EM t.Em 55*7c478bd9Sstevel@tonic-gate # define HOR t.Adj 56*7c478bd9Sstevel@tonic-gate # define VERT t.Vert 57*7c478bd9Sstevel@tonic-gate # define INCH 240 /* increments per inch */ 58*7c478bd9Sstevel@tonic-gate # define SPS INCH/10 /* space size */ 59*7c478bd9Sstevel@tonic-gate # define SS INCH/10 /* " */ 60*7c478bd9Sstevel@tonic-gate # define TRAILER 0 61*7c478bd9Sstevel@tonic-gate # define PO 0 /* page offset */ 62*7c478bd9Sstevel@tonic-gate # define ASCII 1 63*7c478bd9Sstevel@tonic-gate # define PTID 1 64*7c478bd9Sstevel@tonic-gate # define LG 0 65*7c478bd9Sstevel@tonic-gate # define DTAB 0 /* set at 8 Ems at init time */ 66*7c478bd9Sstevel@tonic-gate # define ICS 2*SPS 67*7c478bd9Sstevel@tonic-gate #endif 68*7c478bd9Sstevel@tonic-gate #ifndef NROFF /* TROFF */ 69*7c478bd9Sstevel@tonic-gate /* Inch is set by ptinit() when troff started. */ 70*7c478bd9Sstevel@tonic-gate /* all derived values set then too 71*7c478bd9Sstevel@tonic-gate */ 72*7c478bd9Sstevel@tonic-gate # define INCH Inch /* troff resolution -- number of goobies/inch */ 73*7c478bd9Sstevel@tonic-gate # define POINT (INCH/72) /* goobies per point (1/72 inch) */ 74*7c478bd9Sstevel@tonic-gate # define HOR Hor /* horizontal resolution in goobies */ 75*7c478bd9Sstevel@tonic-gate # define VERT Vert /* vertical resolution in goobies */ 76*7c478bd9Sstevel@tonic-gate # define SPS (EM/3) /* space size */ 77*7c478bd9Sstevel@tonic-gate # define SS 12 /* space size in 36ths of an em */ 78*7c478bd9Sstevel@tonic-gate # define PO (INCH) /* page offset 1 inch */ 79*7c478bd9Sstevel@tonic-gate /* # define EM (POINT * pts) */ 80*7c478bd9Sstevel@tonic-gate #define EM (((long) INCH * pts + 36) / 72) /* don't lose significance */ 81*7c478bd9Sstevel@tonic-gate #define EMPTS(pts) (((long) INCH * (pts) + 36) / 72) 82*7c478bd9Sstevel@tonic-gate # define ASCII 0 83*7c478bd9Sstevel@tonic-gate # define PTID 1 84*7c478bd9Sstevel@tonic-gate # define LG 1 85*7c478bd9Sstevel@tonic-gate # define DTAB (INCH/2) 86*7c478bd9Sstevel@tonic-gate # define ICS 3*SPS 87*7c478bd9Sstevel@tonic-gate #endif 88*7c478bd9Sstevel@tonic-gate 89*7c478bd9Sstevel@tonic-gate /* These "characters" are used to encode various internal functions 90*7c478bd9Sstevel@tonic-gate * Some make use of the fact that most ascii characters between 91*7c478bd9Sstevel@tonic-gate * 0 and 040 don't have any graphic or other function. 92*7c478bd9Sstevel@tonic-gate * The few that do have a purpose (e.g., \n, \b, \t, ... 93*7c478bd9Sstevel@tonic-gate * are avoided by the ad hoc choices here. 94*7c478bd9Sstevel@tonic-gate * See ifilt[] in n1.c for others -- 1, 2, 3, 5, 6, 7, 010, 011, 012 95*7c478bd9Sstevel@tonic-gate */ 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate #define LEADER 001 98*7c478bd9Sstevel@tonic-gate #define IMP 004 /* impossible char; glues things together */ 99*7c478bd9Sstevel@tonic-gate #define TAB 011 100*7c478bd9Sstevel@tonic-gate #define RPT 014 /* next character is to be repeated many times */ 101*7c478bd9Sstevel@tonic-gate #define CHARHT 015 /* size field sets character height */ 102*7c478bd9Sstevel@tonic-gate #define SLANT 016 /* size field sets amount of slant */ 103*7c478bd9Sstevel@tonic-gate #define DRAWFCN 017 /* next several chars describe arb drawing fcn */ 104*7c478bd9Sstevel@tonic-gate /* line: 'l' dx dy char */ 105*7c478bd9Sstevel@tonic-gate /* circle: 'c' r */ 106*7c478bd9Sstevel@tonic-gate /* ellipse: 'e' rx ry */ 107*7c478bd9Sstevel@tonic-gate /* arc: 'a' dx dy r */ 108*7c478bd9Sstevel@tonic-gate /* wiggly line '~' x y x y ... */ 109*7c478bd9Sstevel@tonic-gate #define DRAWLINE 'l' 110*7c478bd9Sstevel@tonic-gate #define DRAWCIRCLE 'c' /* circle */ 111*7c478bd9Sstevel@tonic-gate #define DRAWELLIPSE 'e' 112*7c478bd9Sstevel@tonic-gate #define DRAWARC 'a' /* arbitrary arc */ 113*7c478bd9Sstevel@tonic-gate #define DRAWSPLINE '~' /* quadratic B spline */ 114*7c478bd9Sstevel@tonic-gate 115*7c478bd9Sstevel@tonic-gate #define LEFT 020 /* \{ */ 116*7c478bd9Sstevel@tonic-gate #define RIGHT 021 /* \} */ 117*7c478bd9Sstevel@tonic-gate #define FILLER 022 /* \& and similar purposes */ 118*7c478bd9Sstevel@tonic-gate #define XON 023 /* \X'...' starts here */ 119*7c478bd9Sstevel@tonic-gate #define OHC 024 /* optional hyphenation character \% */ 120*7c478bd9Sstevel@tonic-gate #define CONT 025 /* \c character */ 121*7c478bd9Sstevel@tonic-gate #define PRESC 026 /* printable escape */ 122*7c478bd9Sstevel@tonic-gate #define UNPAD 027 /* unpaddable blank */ 123*7c478bd9Sstevel@tonic-gate #define XPAR 030 /* transparent mode indicator */ 124*7c478bd9Sstevel@tonic-gate #define FLSS 031 125*7c478bd9Sstevel@tonic-gate #define WORDSP 032 /* paddable word space */ 126*7c478bd9Sstevel@tonic-gate #define ESC 033 127*7c478bd9Sstevel@tonic-gate #define XOFF 034 /* \X'...' ends here */ 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate #define iscontrol(n) (n==035 || n==036) /* used to test the next two */ 130*7c478bd9Sstevel@tonic-gate #define HX 035 /* next character is value of \x'...' */ 131*7c478bd9Sstevel@tonic-gate #define FONTPOS 036 /* position of font \f(XX encoded in top */ 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate #define HYPHEN c_hyphen 134*7c478bd9Sstevel@tonic-gate #define EMDASH c_emdash /* \(em */ 135*7c478bd9Sstevel@tonic-gate #define RULE c_rule /* \(ru */ 136*7c478bd9Sstevel@tonic-gate #define MINUS c_minus /* minus sign on current font */ 137*7c478bd9Sstevel@tonic-gate #define LIG_FI c_fi /* \(ff */ 138*7c478bd9Sstevel@tonic-gate #define LIG_FL c_fl /* \(fl */ 139*7c478bd9Sstevel@tonic-gate #define LIG_FF c_ff /* \(ff */ 140*7c478bd9Sstevel@tonic-gate #define LIG_FFI c_ffi /* \(Fi */ 141*7c478bd9Sstevel@tonic-gate #define LIG_FFL c_ffl /* \(Fl */ 142*7c478bd9Sstevel@tonic-gate #define ACUTE c_acute /* acute accent \(aa */ 143*7c478bd9Sstevel@tonic-gate #define GRAVE c_grave /* grave accent \(ga */ 144*7c478bd9Sstevel@tonic-gate #define UNDERLINE c_under /* \(ul */ 145*7c478bd9Sstevel@tonic-gate #define ROOTEN c_rooten /* root en \(rn */ 146*7c478bd9Sstevel@tonic-gate #define BOXRULE c_boxrule /* box rule \(br */ 147*7c478bd9Sstevel@tonic-gate #define LEFTHAND c_lefthand /* left hand for word overflow */ 148*7c478bd9Sstevel@tonic-gate #define DAGGER c_dagger /* dagger for footnotes */ 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate /* array sizes, and similar limits: */ 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate #define NFONT 10 /* maximum number of fonts (including specials) */ 153*7c478bd9Sstevel@tonic-gate #define EXTRAFONT 500 /* extra space for swapping a font */ 154*7c478bd9Sstevel@tonic-gate #define NN 400 /* number registers */ 155*7c478bd9Sstevel@tonic-gate #define NNAMES 15 /* predefined reg names */ 156*7c478bd9Sstevel@tonic-gate #define NIF 15 /* if-else nesting */ 157*7c478bd9Sstevel@tonic-gate #define NS 128 /* name buffer */ 158*7c478bd9Sstevel@tonic-gate #define NTM 256 /* tm buffer */ 159*7c478bd9Sstevel@tonic-gate #define NEV 3 /* environments */ 160*7c478bd9Sstevel@tonic-gate #define EVLSZ 10 /* size of ev stack */ 161*7c478bd9Sstevel@tonic-gate #define DSIZE 512 /* disk sector size in chars */ 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate #define NM 500 /* requests + macros */ 164*7c478bd9Sstevel@tonic-gate #define DELTA 1024 /* delta core bytes */ 165*7c478bd9Sstevel@tonic-gate #define NHYP 10 /* max hyphens per word */ 166*7c478bd9Sstevel@tonic-gate #define NHEX 128 /* byte size of exception word list */ 167*7c478bd9Sstevel@tonic-gate #define NTAB 40 /* tab stops */ 168*7c478bd9Sstevel@tonic-gate #define NSO 5 /* "so" depth */ 169*7c478bd9Sstevel@tonic-gate #define NMF 5 /* number of -m flags */ 170*7c478bd9Sstevel@tonic-gate #define WDSIZE 540 /* word buffer size */ 171*7c478bd9Sstevel@tonic-gate #define LNSIZE 680 /* line buffer size */ 172*7c478bd9Sstevel@tonic-gate #define NDI 5 /* number of diversions */ 173*7c478bd9Sstevel@tonic-gate #define NCHARS 512 /* maximum size of troff character set */ 174*7c478bd9Sstevel@tonic-gate #define NTRTAB NCHARS /* number of items in trtab[] */ 175*7c478bd9Sstevel@tonic-gate #define NWIDCACHE NCHARS /* number of items in widcache */ 176*7c478bd9Sstevel@tonic-gate #define NTRAP 20 /* number of traps */ 177*7c478bd9Sstevel@tonic-gate #define NPN 20 /* numbers in "-o" */ 178*7c478bd9Sstevel@tonic-gate #define FBUFSZ 256 /* field buf size words */ 179*7c478bd9Sstevel@tonic-gate #define OBUFSZ 4096 /* bytes */ 180*7c478bd9Sstevel@tonic-gate #define IBUFSZ 4096 /* bytes */ 181*7c478bd9Sstevel@tonic-gate #define NC 1024 /* cbuf size words */ 182*7c478bd9Sstevel@tonic-gate #define NOV 10 /* number of overstrike chars */ 183*7c478bd9Sstevel@tonic-gate #define NPP 10 /* pads per field */ 184*7c478bd9Sstevel@tonic-gate 185*7c478bd9Sstevel@tonic-gate /* 186*7c478bd9Sstevel@tonic-gate Internal character representation: 187*7c478bd9Sstevel@tonic-gate Internally, every character is carried around as 188*7c478bd9Sstevel@tonic-gate a 32 bit cookie, called a "tchar" (typedef long). 189*7c478bd9Sstevel@tonic-gate Bits are numbered 31..0 from left to right. 190*7c478bd9Sstevel@tonic-gate If bit 15 is 1, the character is motion, with 191*7c478bd9Sstevel@tonic-gate if bit 16 it's vertical motion 192*7c478bd9Sstevel@tonic-gate if bit 17 it's negative motion 193*7c478bd9Sstevel@tonic-gate If bit 15 is 0, the character is a real character. 194*7c478bd9Sstevel@tonic-gate if bit 31 zero motion 195*7c478bd9Sstevel@tonic-gate bits 30..24 size 196*7c478bd9Sstevel@tonic-gate bits 23..16 font 197*7c478bd9Sstevel@tonic-gate ifndef EUC 198*7c478bd9Sstevel@tonic-gate bit 8 absolute char number in 7..0 199*7c478bd9Sstevel@tonic-gate This implies at most 256-32 characters in a single font, 200*7c478bd9Sstevel@tonic-gate which is going to be a problem somewhere 201*7c478bd9Sstevel@tonic-gate else 202*7c478bd9Sstevel@tonic-gate bits 14,13 identifier for the colunm of print of character. 203*7c478bd9Sstevel@tonic-gate bits 12,11 multibyte position identifier 204*7c478bd9Sstevel@tonic-gate Currently, this applies only to nroff. 205*7c478bd9Sstevel@tonic-gate endif EUC 206*7c478bd9Sstevel@tonic-gate */ 207*7c478bd9Sstevel@tonic-gate 208*7c478bd9Sstevel@tonic-gate /* in the following, "L" should really be a tchar, but ... */ 209*7c478bd9Sstevel@tonic-gate 210*7c478bd9Sstevel@tonic-gate #define MOT (01L<<15) /* motion character indicator */ 211*7c478bd9Sstevel@tonic-gate #define MOTV (07L<<15) /* clear for motion part */ 212*7c478bd9Sstevel@tonic-gate #define VMOT (01L<<16) /* vert motion bit */ 213*7c478bd9Sstevel@tonic-gate #define NMOT (01L<<17) /* negative motion indicator*/ 214*7c478bd9Sstevel@tonic-gate #define MAXMOT 32767 /* bad way to write this!!! */ 215*7c478bd9Sstevel@tonic-gate #define ismot(n) ((n) & MOT) 216*7c478bd9Sstevel@tonic-gate #define isvmot(n) ((n) & VMOT) /* must have tested MOT previously */ 217*7c478bd9Sstevel@tonic-gate #define isnmot(n) ((n) & NMOT) /* ditto */ 218*7c478bd9Sstevel@tonic-gate #define absmot(n) (unsigned)(0177777 & (n) & ~MOT) /* (short) is cheap mask */ 219*7c478bd9Sstevel@tonic-gate 220*7c478bd9Sstevel@tonic-gate #define ZBIT 0x80000000 /* (01L << 31) */ /* zero width char */ 221*7c478bd9Sstevel@tonic-gate #define iszbit(n) ((n) & ZBIT) 222*7c478bd9Sstevel@tonic-gate #define ABSCHAR 0400 /* absolute char number in this font */ 223*7c478bd9Sstevel@tonic-gate 224*7c478bd9Sstevel@tonic-gate #define SMASK (0177L << 24) 225*7c478bd9Sstevel@tonic-gate #define FMASK (0377L << 16) 226*7c478bd9Sstevel@tonic-gate #define SFMASK (SMASK|FMASK) /* size and font in a tchar */ 227*7c478bd9Sstevel@tonic-gate #define sbits(n) (unsigned)(((n) >> 24) & 0177) 228*7c478bd9Sstevel@tonic-gate #define fbits(n) (((n) >> 16) & 0377) 229*7c478bd9Sstevel@tonic-gate #define sfbits(n) (unsigned)(0177777 & (((n) & SFMASK) >> 16)) 230*7c478bd9Sstevel@tonic-gate #define cbits(n) (unsigned)(0177777 & (n)) /* isolate bottom 16 bits */ 231*7c478bd9Sstevel@tonic-gate #define absbits(n) (cbits(n) & ~ABSCHAR) 232*7c478bd9Sstevel@tonic-gate 233*7c478bd9Sstevel@tonic-gate #define setsbits(n,s) n = (n & ~SMASK) | (tchar)(s) << 24 234*7c478bd9Sstevel@tonic-gate #define setfbits(n,f) n = (n & ~FMASK) | (tchar)(f) << 16 235*7c478bd9Sstevel@tonic-gate #define setsfbits(n,sf) n = (n & ~SFMASK) | (tchar)(sf) << 16 236*7c478bd9Sstevel@tonic-gate #define setcbits(n,c) n = (n & ~077777L | (c)) /* set character bits */ 237*7c478bd9Sstevel@tonic-gate 238*7c478bd9Sstevel@tonic-gate #define BYTEMASK 0377 239*7c478bd9Sstevel@tonic-gate #define BYTE 8 240*7c478bd9Sstevel@tonic-gate 241*7c478bd9Sstevel@tonic-gate #define ischar(n) (((n) & ~BYTEMASK) == 0) 242*7c478bd9Sstevel@tonic-gate 243*7c478bd9Sstevel@tonic-gate #ifdef EUC 244*7c478bd9Sstevel@tonic-gate #ifdef NROFF 245*7c478bd9Sstevel@tonic-gate #define CSMASK 0x6000 /* colunm of print identifier */ 246*7c478bd9Sstevel@tonic-gate #define MBMASK 0x1c00 /* bits identifying position in a multibyte char */ 247*7c478bd9Sstevel@tonic-gate #define MBMASK1 0x1800 248*7c478bd9Sstevel@tonic-gate #define FIRSTOFMB 0x1000 249*7c478bd9Sstevel@tonic-gate #define MIDDLEOFMB 0x0800 250*7c478bd9Sstevel@tonic-gate #define LASTOFMB 0x0400 251*7c478bd9Sstevel@tonic-gate #define BYTE_CHR 0x0000 252*7c478bd9Sstevel@tonic-gate #define cs(n) (((n) & CSMASK) >> 13) /* colum of print of character */ 253*7c478bd9Sstevel@tonic-gate #define setcsbits(n,c) n = ((n & ~CSMASK) | ((c) << 13)) 254*7c478bd9Sstevel@tonic-gate #define CHMASK (BYTEMASK | CSMASK | MBMASK) 255*7c478bd9Sstevel@tonic-gate #define ZWDELIM1 ZBIT | FIRSTOFMB | ' ' /* non-ASCII word delimiter 1 */ 256*7c478bd9Sstevel@tonic-gate #define ZWDELIM2 ZBIT | MIDDLEOFMB | ' ' /* non-ASCII word delimiter 2 */ 257*7c478bd9Sstevel@tonic-gate #define ZWDELIM(c) ((c) == 0) ? ' ' : ((c) == 1) ? ZWDELIM1 : ZWDELIM2 258*7c478bd9Sstevel@tonic-gate #endif /* NROFF */ 259*7c478bd9Sstevel@tonic-gate #endif /* EUC */ 260*7c478bd9Sstevel@tonic-gate 261*7c478bd9Sstevel@tonic-gate #define ZONE 5 /* 5 hrs for EST */ 262*7c478bd9Sstevel@tonic-gate #define TABMASK 037777 263*7c478bd9Sstevel@tonic-gate #define RTAB (unsigned) 0100000 264*7c478bd9Sstevel@tonic-gate #define CTAB 040000 265*7c478bd9Sstevel@tonic-gate 266*7c478bd9Sstevel@tonic-gate #define TABBIT 02 /* bits in gchtab */ 267*7c478bd9Sstevel@tonic-gate #define LDRBIT 04 268*7c478bd9Sstevel@tonic-gate #define FCBIT 010 269*7c478bd9Sstevel@tonic-gate 270*7c478bd9Sstevel@tonic-gate #define PAIR(A,B) (A|(B<<BYTE)) 271*7c478bd9Sstevel@tonic-gate 272*7c478bd9Sstevel@tonic-gate #ifndef EUC 273*7c478bd9Sstevel@tonic-gate #define oput(c) if ((*obufp++ = (c)), obufp >= &obuf[OBUFSZ]) flusho(); else 274*7c478bd9Sstevel@tonic-gate #else 275*7c478bd9Sstevel@tonic-gate #ifndef NROFF 276*7c478bd9Sstevel@tonic-gate #define oput(c) if ((*obufp++ = (c)), obufp >= &obuf[OBUFSZ]) flusho(); else 277*7c478bd9Sstevel@tonic-gate #endif /* NROFF */ 278*7c478bd9Sstevel@tonic-gate #define oput(c) if ((*obufp++ = cbits(c) & BYTEMASK), obufp >= &obuf[OBUFSZ]) flusho(); else 279*7c478bd9Sstevel@tonic-gate #endif /* EUC */ 280*7c478bd9Sstevel@tonic-gate 281*7c478bd9Sstevel@tonic-gate /* 282*7c478bd9Sstevel@tonic-gate * "temp file" parameters. macros and strings 283*7c478bd9Sstevel@tonic-gate * are stored in an array of linked blocks, 284*7c478bd9Sstevel@tonic-gate * which may be in memory and an array called 285*7c478bd9Sstevel@tonic-gate * corebuf[], if INCORE is set during 286*7c478bd9Sstevel@tonic-gate * compilation, or otherwise in a file called trtmp$$. 287*7c478bd9Sstevel@tonic-gate 288*7c478bd9Sstevel@tonic-gate * The numerology is delicate if filep is 16 bits: 289*7c478bd9Sstevel@tonic-gate #define BLK 128 290*7c478bd9Sstevel@tonic-gate #define NBLIST 512 291*7c478bd9Sstevel@tonic-gate * i.e., the product is 16 bits long. 292*7c478bd9Sstevel@tonic-gate 293*7c478bd9Sstevel@tonic-gate * If filep is an unsigned long (and if your 294*7c478bd9Sstevel@tonic-gate * compiler will let you say that) then NBLIST 295*7c478bd9Sstevel@tonic-gate * can be a lot bigger. Of course that makes 296*7c478bd9Sstevel@tonic-gate * the file or core image a lot bigger too, 297*7c478bd9Sstevel@tonic-gate * and means you don't detect missing diversion 298*7c478bd9Sstevel@tonic-gate * terminations as quickly... . 299*7c478bd9Sstevel@tonic-gate * It also means that you may have trouble running 300*7c478bd9Sstevel@tonic-gate * on non-swapping systems, since the core image 301*7c478bd9Sstevel@tonic-gate * will be over 1Mb. 302*7c478bd9Sstevel@tonic-gate 303*7c478bd9Sstevel@tonic-gate * BLK must be a power of 2 304*7c478bd9Sstevel@tonic-gate */ 305*7c478bd9Sstevel@tonic-gate 306*7c478bd9Sstevel@tonic-gate typedef unsigned int filep; /* this is good for 32 bit machines */ 307*7c478bd9Sstevel@tonic-gate 308*7c478bd9Sstevel@tonic-gate #define BLK 128 /* alloc block in tchars */ 309*7c478bd9Sstevel@tonic-gate 310*7c478bd9Sstevel@tonic-gate #ifdef SMALLER 311*7c478bd9Sstevel@tonic-gate # define NBLIST 512 312*7c478bd9Sstevel@tonic-gate #else 313*7c478bd9Sstevel@tonic-gate # define NBLIST 1024 /* allocation list. smallish machines use 512 */ 314*7c478bd9Sstevel@tonic-gate /* machines with paging can use 2048 */ 315*7c478bd9Sstevel@tonic-gate #endif 316*7c478bd9Sstevel@tonic-gate 317*7c478bd9Sstevel@tonic-gate /* Other things are stored in the temp file or corebuf: 318*7c478bd9Sstevel@tonic-gate * a single block for .rd input, at offset RD_OFFSET 319*7c478bd9Sstevel@tonic-gate * NEV copies of the environment block, at offset ENV_OFFSET 320*7c478bd9Sstevel@tonic-gate 321*7c478bd9Sstevel@tonic-gate * The existing implementation assumes very strongly that 322*7c478bd9Sstevel@tonic-gate * these are respectively NBLIST*BLK and 0. 323*7c478bd9Sstevel@tonic-gate 324*7c478bd9Sstevel@tonic-gate */ 325*7c478bd9Sstevel@tonic-gate 326*7c478bd9Sstevel@tonic-gate #define RD_OFFSET (NBLIST * BLK) 327*7c478bd9Sstevel@tonic-gate #define ENV_OFFSET 0 328*7c478bd9Sstevel@tonic-gate #define ENV_BLK ((NEV * sizeof(env) / sizeof(tchar) + BLK-1) / BLK) 329*7c478bd9Sstevel@tonic-gate /* rounded up to even BLK */ 330*7c478bd9Sstevel@tonic-gate 331*7c478bd9Sstevel@tonic-gate typedef long tchar; 332*7c478bd9Sstevel@tonic-gate 333*7c478bd9Sstevel@tonic-gate extern tchar getch(), getch0(); 334*7c478bd9Sstevel@tonic-gate extern tchar rbf(), rbf0(); 335*7c478bd9Sstevel@tonic-gate extern tchar mot(), hmot(), vmot(); 336*7c478bd9Sstevel@tonic-gate extern tchar makem(), sethl(); 337*7c478bd9Sstevel@tonic-gate extern tchar popi(); 338*7c478bd9Sstevel@tonic-gate extern tchar getlg(); 339*7c478bd9Sstevel@tonic-gate extern tchar xlss(); 340*7c478bd9Sstevel@tonic-gate extern tchar setfield(); 341*7c478bd9Sstevel@tonic-gate extern tchar setz(); 342*7c478bd9Sstevel@tonic-gate extern tchar setch(); 343*7c478bd9Sstevel@tonic-gate extern tchar setht(), setslant(); 344*7c478bd9Sstevel@tonic-gate 345*7c478bd9Sstevel@tonic-gate #define atoi(i) ((int) atoi0(i)) 346*7c478bd9Sstevel@tonic-gate extern long atoi0(); 347*7c478bd9Sstevel@tonic-gate 348*7c478bd9Sstevel@tonic-gate extern int Inch, Hor, Vert, Unitwidth; 349*7c478bd9Sstevel@tonic-gate 350*7c478bd9Sstevel@tonic-gate /* these characters are used as various signals or values 351*7c478bd9Sstevel@tonic-gate * in miscellaneous places. 352*7c478bd9Sstevel@tonic-gate * values are set in specnames in t10.c 353*7c478bd9Sstevel@tonic-gate */ 354*7c478bd9Sstevel@tonic-gate 355*7c478bd9Sstevel@tonic-gate extern int c_hyphen; 356*7c478bd9Sstevel@tonic-gate extern int c_emdash; 357*7c478bd9Sstevel@tonic-gate extern int c_rule; 358*7c478bd9Sstevel@tonic-gate extern int c_minus; 359*7c478bd9Sstevel@tonic-gate extern int c_fi; 360*7c478bd9Sstevel@tonic-gate extern int c_fl; 361*7c478bd9Sstevel@tonic-gate extern int c_ff; 362*7c478bd9Sstevel@tonic-gate extern int c_ffi; 363*7c478bd9Sstevel@tonic-gate extern int c_ffl; 364*7c478bd9Sstevel@tonic-gate extern int c_acute; 365*7c478bd9Sstevel@tonic-gate extern int c_grave; 366*7c478bd9Sstevel@tonic-gate extern int c_under; 367*7c478bd9Sstevel@tonic-gate extern int c_rooten; 368*7c478bd9Sstevel@tonic-gate extern int c_boxrule; 369*7c478bd9Sstevel@tonic-gate extern int c_lefthand; 370*7c478bd9Sstevel@tonic-gate extern int c_dagger; 371*7c478bd9Sstevel@tonic-gate 372*7c478bd9Sstevel@tonic-gate /* 373*7c478bd9Sstevel@tonic-gate * <widec.h> includes <stdio.h> which defines 374*7c478bd9Sstevel@tonic-gate * stderr. So undef it if it is already defined. 375*7c478bd9Sstevel@tonic-gate */ 376*7c478bd9Sstevel@tonic-gate #ifdef stderr 377*7c478bd9Sstevel@tonic-gate # undef stderr 378*7c478bd9Sstevel@tonic-gate #endif 379*7c478bd9Sstevel@tonic-gate extern int stderr; /* this is NOT the stdio value! */ 380*7c478bd9Sstevel@tonic-gate 381*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 382*7c478bd9Sstevel@tonic-gate extern int debug; /*debug flag*/ 383*7c478bd9Sstevel@tonic-gate #define DB_MAC 01 /*print out macro calls*/ 384*7c478bd9Sstevel@tonic-gate #define DB_ALLC 02 /*print out message from alloc()*/ 385*7c478bd9Sstevel@tonic-gate #define DB_GETC 04 /*print out message from getch()*/ 386*7c478bd9Sstevel@tonic-gate #define DB_LOOP 010 /*print out message before "Eileen's loop" fix*/ 387*7c478bd9Sstevel@tonic-gate #endif DEBUG 388*7c478bd9Sstevel@tonic-gate 389*7c478bd9Sstevel@tonic-gate extern struct d { /* diversion */ 390*7c478bd9Sstevel@tonic-gate filep op; 391*7c478bd9Sstevel@tonic-gate int dnl; 392*7c478bd9Sstevel@tonic-gate int dimac; 393*7c478bd9Sstevel@tonic-gate int ditrap; 394*7c478bd9Sstevel@tonic-gate int ditf; 395*7c478bd9Sstevel@tonic-gate int alss; 396*7c478bd9Sstevel@tonic-gate int blss; 397*7c478bd9Sstevel@tonic-gate int nls; 398*7c478bd9Sstevel@tonic-gate int mkline; 399*7c478bd9Sstevel@tonic-gate int maxl; 400*7c478bd9Sstevel@tonic-gate int hnl; 401*7c478bd9Sstevel@tonic-gate int curd; 402*7c478bd9Sstevel@tonic-gate }; 403*7c478bd9Sstevel@tonic-gate 404*7c478bd9Sstevel@tonic-gate extern struct s { /* stack frame */ 405*7c478bd9Sstevel@tonic-gate int nargs; 406*7c478bd9Sstevel@tonic-gate struct s *pframe; 407*7c478bd9Sstevel@tonic-gate filep pip; 408*7c478bd9Sstevel@tonic-gate int pnchar; 409*7c478bd9Sstevel@tonic-gate tchar prchar; 410*7c478bd9Sstevel@tonic-gate int ppendt; 411*7c478bd9Sstevel@tonic-gate tchar pch; 412*7c478bd9Sstevel@tonic-gate tchar *lastpbp; 413*7c478bd9Sstevel@tonic-gate int mname; 414*7c478bd9Sstevel@tonic-gate }; 415*7c478bd9Sstevel@tonic-gate 416*7c478bd9Sstevel@tonic-gate extern struct contab { 417*7c478bd9Sstevel@tonic-gate unsigned short rq; 418*7c478bd9Sstevel@tonic-gate struct contab *link; 419*7c478bd9Sstevel@tonic-gate int (*f)(); 420*7c478bd9Sstevel@tonic-gate unsigned mx; 421*7c478bd9Sstevel@tonic-gate } contab[NM]; 422*7c478bd9Sstevel@tonic-gate 423*7c478bd9Sstevel@tonic-gate extern struct numtab { 424*7c478bd9Sstevel@tonic-gate short r; /* name */ 425*7c478bd9Sstevel@tonic-gate short fmt; 426*7c478bd9Sstevel@tonic-gate short inc; 427*7c478bd9Sstevel@tonic-gate int val; 428*7c478bd9Sstevel@tonic-gate struct numtab *link; 429*7c478bd9Sstevel@tonic-gate } numtab[NN]; 430*7c478bd9Sstevel@tonic-gate 431*7c478bd9Sstevel@tonic-gate #define PN 0 432*7c478bd9Sstevel@tonic-gate #define NL 1 433*7c478bd9Sstevel@tonic-gate #define YR 2 434*7c478bd9Sstevel@tonic-gate #define HP 3 435*7c478bd9Sstevel@tonic-gate #define CT 4 436*7c478bd9Sstevel@tonic-gate #define DN 5 437*7c478bd9Sstevel@tonic-gate #define MO 6 438*7c478bd9Sstevel@tonic-gate #define DY 7 439*7c478bd9Sstevel@tonic-gate #define DW 8 440*7c478bd9Sstevel@tonic-gate #define LN 9 441*7c478bd9Sstevel@tonic-gate #define DL 10 442*7c478bd9Sstevel@tonic-gate #define ST 11 443*7c478bd9Sstevel@tonic-gate #define SB 12 444*7c478bd9Sstevel@tonic-gate #define CD 13 445*7c478bd9Sstevel@tonic-gate #define PID 14 446*7c478bd9Sstevel@tonic-gate 447*7c478bd9Sstevel@tonic-gate /* the infamous environment block */ 448*7c478bd9Sstevel@tonic-gate 449*7c478bd9Sstevel@tonic-gate #define ics env._ics 450*7c478bd9Sstevel@tonic-gate #define sps env._sps 451*7c478bd9Sstevel@tonic-gate #define spacesz env._spacesz 452*7c478bd9Sstevel@tonic-gate #define lss env._lss 453*7c478bd9Sstevel@tonic-gate #define lss1 env._lss1 454*7c478bd9Sstevel@tonic-gate #define ll env._ll 455*7c478bd9Sstevel@tonic-gate #define ll1 env._ll1 456*7c478bd9Sstevel@tonic-gate #define lt env._lt 457*7c478bd9Sstevel@tonic-gate #define lt1 env._lt1 458*7c478bd9Sstevel@tonic-gate #define ic env._ic 459*7c478bd9Sstevel@tonic-gate #define icf env._icf 460*7c478bd9Sstevel@tonic-gate #define chbits env._chbits 461*7c478bd9Sstevel@tonic-gate #define spbits env._spbits 462*7c478bd9Sstevel@tonic-gate #define nmbits env._nmbits 463*7c478bd9Sstevel@tonic-gate #define apts env._apts 464*7c478bd9Sstevel@tonic-gate #define apts1 env._apts1 465*7c478bd9Sstevel@tonic-gate #define pts env._pts 466*7c478bd9Sstevel@tonic-gate #define pts1 env._pts1 467*7c478bd9Sstevel@tonic-gate #define font env._font 468*7c478bd9Sstevel@tonic-gate #define font1 env._font1 469*7c478bd9Sstevel@tonic-gate #define ls env._ls 470*7c478bd9Sstevel@tonic-gate #define ls1 env._ls1 471*7c478bd9Sstevel@tonic-gate #define ad env._ad 472*7c478bd9Sstevel@tonic-gate #define nms env._nms 473*7c478bd9Sstevel@tonic-gate #define ndf env._ndf 474*7c478bd9Sstevel@tonic-gate #define fi env._fi 475*7c478bd9Sstevel@tonic-gate #define cc env._cc 476*7c478bd9Sstevel@tonic-gate #define c2 env._c2 477*7c478bd9Sstevel@tonic-gate #define ohc env._ohc 478*7c478bd9Sstevel@tonic-gate #define tdelim env._tdelim 479*7c478bd9Sstevel@tonic-gate #define hyf env._hyf 480*7c478bd9Sstevel@tonic-gate #define hyoff env._hyoff 481*7c478bd9Sstevel@tonic-gate #define un1 env._un1 482*7c478bd9Sstevel@tonic-gate #define tabc env._tabc 483*7c478bd9Sstevel@tonic-gate #define dotc env._dotc 484*7c478bd9Sstevel@tonic-gate #define adsp env._adsp 485*7c478bd9Sstevel@tonic-gate #define adrem env._adrem 486*7c478bd9Sstevel@tonic-gate #define lastl env._lastl 487*7c478bd9Sstevel@tonic-gate #define nel env._nel 488*7c478bd9Sstevel@tonic-gate #define admod env._admod 489*7c478bd9Sstevel@tonic-gate #define wordp env._wordp 490*7c478bd9Sstevel@tonic-gate #define spflg env._spflg 491*7c478bd9Sstevel@tonic-gate #define linep env._linep 492*7c478bd9Sstevel@tonic-gate #define wdend env._wdend 493*7c478bd9Sstevel@tonic-gate #define wdstart env._wdstart 494*7c478bd9Sstevel@tonic-gate #define wne env._wne 495*7c478bd9Sstevel@tonic-gate #define ne env._ne 496*7c478bd9Sstevel@tonic-gate #define nc env._nc 497*7c478bd9Sstevel@tonic-gate #define nb env._nb 498*7c478bd9Sstevel@tonic-gate #define lnmod env._lnmod 499*7c478bd9Sstevel@tonic-gate #define nwd env._nwd 500*7c478bd9Sstevel@tonic-gate #define nn env._nn 501*7c478bd9Sstevel@tonic-gate #define ni env._ni 502*7c478bd9Sstevel@tonic-gate #define ul env._ul 503*7c478bd9Sstevel@tonic-gate #define cu env._cu 504*7c478bd9Sstevel@tonic-gate #define ce env._ce 505*7c478bd9Sstevel@tonic-gate #define in env._in 506*7c478bd9Sstevel@tonic-gate #define in1 env._in1 507*7c478bd9Sstevel@tonic-gate #define un env._un 508*7c478bd9Sstevel@tonic-gate #define wch env._wch 509*7c478bd9Sstevel@tonic-gate #define pendt env._pendt 510*7c478bd9Sstevel@tonic-gate #define pendw env._pendw 511*7c478bd9Sstevel@tonic-gate #define pendnf env._pendnf 512*7c478bd9Sstevel@tonic-gate #define spread env._spread 513*7c478bd9Sstevel@tonic-gate #define it env._it 514*7c478bd9Sstevel@tonic-gate #define itmac env._itmac 515*7c478bd9Sstevel@tonic-gate #define lnsize env._lnsize 516*7c478bd9Sstevel@tonic-gate #define hyptr env._hyptr 517*7c478bd9Sstevel@tonic-gate #define tabtab env._tabtab 518*7c478bd9Sstevel@tonic-gate #define line env._line 519*7c478bd9Sstevel@tonic-gate #define word env._word 520*7c478bd9Sstevel@tonic-gate 521*7c478bd9Sstevel@tonic-gate extern struct env { 522*7c478bd9Sstevel@tonic-gate int _ics; 523*7c478bd9Sstevel@tonic-gate int _sps; 524*7c478bd9Sstevel@tonic-gate int _spacesz; 525*7c478bd9Sstevel@tonic-gate int _lss; 526*7c478bd9Sstevel@tonic-gate int _lss1; 527*7c478bd9Sstevel@tonic-gate int _ll; 528*7c478bd9Sstevel@tonic-gate int _ll1; 529*7c478bd9Sstevel@tonic-gate int _lt; 530*7c478bd9Sstevel@tonic-gate int _lt1; 531*7c478bd9Sstevel@tonic-gate tchar _ic; 532*7c478bd9Sstevel@tonic-gate int _icf; 533*7c478bd9Sstevel@tonic-gate tchar _chbits; 534*7c478bd9Sstevel@tonic-gate tchar _spbits; 535*7c478bd9Sstevel@tonic-gate tchar _nmbits; 536*7c478bd9Sstevel@tonic-gate int _apts; 537*7c478bd9Sstevel@tonic-gate int _apts1; 538*7c478bd9Sstevel@tonic-gate int _pts; 539*7c478bd9Sstevel@tonic-gate int _pts1; 540*7c478bd9Sstevel@tonic-gate int _font; 541*7c478bd9Sstevel@tonic-gate int _font1; 542*7c478bd9Sstevel@tonic-gate int _ls; 543*7c478bd9Sstevel@tonic-gate int _ls1; 544*7c478bd9Sstevel@tonic-gate int _ad; 545*7c478bd9Sstevel@tonic-gate int _nms; 546*7c478bd9Sstevel@tonic-gate int _ndf; 547*7c478bd9Sstevel@tonic-gate int _fi; 548*7c478bd9Sstevel@tonic-gate int _cc; 549*7c478bd9Sstevel@tonic-gate int _c2; 550*7c478bd9Sstevel@tonic-gate int _ohc; 551*7c478bd9Sstevel@tonic-gate int _tdelim; 552*7c478bd9Sstevel@tonic-gate int _hyf; 553*7c478bd9Sstevel@tonic-gate int _hyoff; 554*7c478bd9Sstevel@tonic-gate int _un1; 555*7c478bd9Sstevel@tonic-gate int _tabc; 556*7c478bd9Sstevel@tonic-gate int _dotc; 557*7c478bd9Sstevel@tonic-gate int _adsp; 558*7c478bd9Sstevel@tonic-gate int _adrem; 559*7c478bd9Sstevel@tonic-gate int _lastl; 560*7c478bd9Sstevel@tonic-gate int _nel; 561*7c478bd9Sstevel@tonic-gate int _admod; 562*7c478bd9Sstevel@tonic-gate tchar *_wordp; 563*7c478bd9Sstevel@tonic-gate int _spflg; 564*7c478bd9Sstevel@tonic-gate tchar *_linep; 565*7c478bd9Sstevel@tonic-gate tchar *_wdend; 566*7c478bd9Sstevel@tonic-gate tchar *_wdstart; 567*7c478bd9Sstevel@tonic-gate int _wne; 568*7c478bd9Sstevel@tonic-gate int _ne; 569*7c478bd9Sstevel@tonic-gate int _nc; 570*7c478bd9Sstevel@tonic-gate int _nb; 571*7c478bd9Sstevel@tonic-gate int _lnmod; 572*7c478bd9Sstevel@tonic-gate int _nwd; 573*7c478bd9Sstevel@tonic-gate int _nn; 574*7c478bd9Sstevel@tonic-gate int _ni; 575*7c478bd9Sstevel@tonic-gate int _ul; 576*7c478bd9Sstevel@tonic-gate int _cu; 577*7c478bd9Sstevel@tonic-gate int _ce; 578*7c478bd9Sstevel@tonic-gate int _in; 579*7c478bd9Sstevel@tonic-gate int _in1; 580*7c478bd9Sstevel@tonic-gate int _un; 581*7c478bd9Sstevel@tonic-gate int _wch; 582*7c478bd9Sstevel@tonic-gate int _pendt; 583*7c478bd9Sstevel@tonic-gate tchar *_pendw; 584*7c478bd9Sstevel@tonic-gate int _pendnf; 585*7c478bd9Sstevel@tonic-gate int _spread; 586*7c478bd9Sstevel@tonic-gate int _it; 587*7c478bd9Sstevel@tonic-gate int _itmac; 588*7c478bd9Sstevel@tonic-gate int _lnsize; 589*7c478bd9Sstevel@tonic-gate tchar *_hyptr[NHYP]; 590*7c478bd9Sstevel@tonic-gate int _tabtab[NTAB]; 591*7c478bd9Sstevel@tonic-gate tchar _line[LNSIZE]; 592*7c478bd9Sstevel@tonic-gate tchar _word[WDSIZE]; 593*7c478bd9Sstevel@tonic-gate } env; 594