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