tdef.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <limits.h>
  4. #include <ctype.h>
  5. #include <string.h>
  6. #define NROFF (!TROFF)
  7. /* Site dependent definitions */
  8. #ifndef TMACDIR
  9. #define TMACDIR "lib/tmac/tmac."
  10. #endif
  11. #ifndef FONTDIR
  12. #define FONTDIR "lib/font"
  13. #endif
  14. #ifndef NTERMDIR
  15. #define NTERMDIR "lib/term/tab."
  16. #endif
  17. #ifndef TDEVNAME
  18. #define TDEVNAME "post"
  19. #endif
  20. #ifndef NDEVNAME
  21. #define NDEVNAME "37"
  22. #endif
  23. #ifndef TEXHYPHENS
  24. #define TEXHYPHENS "/usr/lib/tex/macros/hyphen.tex"
  25. #endif
  26. #ifndef ALTHYPHENS
  27. #define ALTHYPHENS "lib/tmac/hyphen.tex" /* another place to look */
  28. #endif
  29. typedef unsigned char Uchar;
  30. typedef unsigned short Ushort;
  31. typedef /*unsigned*/ long Tchar;
  32. typedef struct Blockp Blockp;
  33. typedef struct Diver Diver;
  34. typedef struct Stack Stack;
  35. typedef struct Divsiz Divsiz;
  36. typedef struct Contab Contab;
  37. typedef struct Numtab Numtab;
  38. typedef struct Numerr Numerr;
  39. typedef struct Env Env;
  40. typedef struct Term Term;
  41. typedef struct Chwid Chwid;
  42. typedef struct Font Font;
  43. typedef struct Spnames Spnames;
  44. typedef struct Wcache Wcache;
  45. typedef struct Tbuf Tbuf;
  46. /* this simulates printf into a buffer that gets flushed sporadically */
  47. /* the BSD goo is because SunOS sprintf doesn't return anything useful */
  48. #ifdef BSD4_2
  49. #define OUT (obufp += strlen(sprintf(obufp,
  50. #define PUT ))) > obuf+BUFSIZ ? flusho() : 1
  51. #else
  52. #define OUT (obufp += sprintf(obufp,
  53. #define PUT )) > obuf+BUFSIZ ? flusho() : 1
  54. #endif
  55. #define oputs(a) OUT "%s", a PUT
  56. #define oput(c) ( *obufp++ = (c), obufp > obuf+BUFSIZ ? flusho() : 1 )
  57. extern char errbuf[];
  58. #define ERROR sprintf(errbuf,
  59. #define WARN ), errprint()
  60. #define FATAL ), errprint(), exit(1)
  61. /* starting values for typesetting parameters: */
  62. #define PS 10 /* default point size */
  63. #define FT 1 /* default font position */
  64. #define ULFONT 2 /* default underline font */
  65. #define BDFONT 3 /* default emboldening font */
  66. #define BIFONT 4 /* default bold italic font */
  67. #define LL (unsigned) 65*INCH/10 /* line length; 39picas=6.5in */
  68. #define VS ((12*INCH)/72) /* initial vert space */
  69. #define EMPTS(pts) (((long)Inch*(pts) + 36) / 72)
  70. #define EM (TROFF? EMPTS(pts): t.Em)
  71. #define INCH (TROFF? Inch: 240)
  72. #define HOR (TROFF? Hor: t.Adj)
  73. #define VERT (TROFF? Vert: t.Vert)
  74. #define PO (TROFF? Inch: 0)
  75. #define SPS (TROFF? EMPTS(pts)/3: INCH/10)
  76. #define SS (TROFF? 12: INCH/10)
  77. #define ICS (TROFF? EMPTS(pts): 2*INCH/10)
  78. #define DTAB (TROFF? (INCH/2): 0)
  79. /* These "characters" are used to encode various internal functions
  80. /* Some make use of the fact that most ascii characters between
  81. /* 0 and 040 don't have any graphic or other function.
  82. /* The few that do have a purpose (e.g., \n, \b, \t, ...
  83. /* are avoided by the ad hoc choices here.
  84. /* See ifilt[] in n1.c for others -- 1, 2, 3, 5, 6, 7, 010, 011, 012
  85. */
  86. #define LEADER 001
  87. #define IMP 004 /* impossible char; glues things together */
  88. #define TAB 011
  89. #define RPT 014 /* next character is to be repeated many times */
  90. #define CHARHT 015 /* size field sets character height */
  91. #define SLANT 016 /* size field sets amount of slant */
  92. #define DRAWFCN 017 /* next several chars describe arb drawing fcns */
  93. # define DRAWLINE 'l' /* line: 'l' dx dy char */
  94. # define DRAWCIRCLE 'c' /* circle: 'c' r */
  95. # define DRAWELLIPSE 'e' /* ellipse: 'e' rx ry */
  96. # define DRAWARC 'a' /* arc: 'a' dx dy dx dy */
  97. # define DRAWSPLINE '~' /* quadratic B spline: '~' dx dy dx dy ... */
  98. /* other splines go thru too */
  99. /* NOTE: the use of ~ is a botch since it's often used in .tr commands */
  100. /* better to use a letter like s, but change it in the postprocessors too */
  101. /* for now, this is taken care of in n9.c and t10.c */
  102. # define DRAWBUILD 'b' /* built-up character (e.g., { */
  103. #define LEFT 020 /* \{ */
  104. #define RIGHT 021 /* \} */
  105. #define FILLER 022 /* \& and similar purposes */
  106. #define XON 023 /* \X'...' starts here */
  107. #define OHC 024 /* optional hyphenation character \% */
  108. #define CONT 025 /* \c character */
  109. #define PRESC 026 /* printable escape */
  110. #define UNPAD 027 /* unpaddable blank */
  111. #define XPAR 030 /* transparent mode indicator */
  112. #define FLSS 031 /* next Tchar contains vertical space */
  113. /* used when recalling diverted text */
  114. #define WORDSP 032 /* paddable word space */
  115. #define ESC 033 /* current escape character */
  116. #define XOFF 034 /* \X'...' ends here */
  117. /* matches XON, but they will probably never nest */
  118. /* so could drop this when another control is needed */
  119. #define HX 035 /* next character is value of \x'...' */
  120. #define MOTCH 036 /* this "character" is really motion; used by cbits() */
  121. #define HYPHEN c_hyphen
  122. #define EMDASH c_emdash /* \(em */
  123. #define RULE c_rule /* \(ru */
  124. #define MINUS c_minus /* minus sign on current font */
  125. #define LIG_FI c_fi /* \(ff */
  126. #define LIG_FL c_fl /* \(fl */
  127. #define LIG_FF c_ff /* \(ff */
  128. #define LIG_FFI c_ffi /* \(Fi */
  129. #define LIG_FFL c_ffl /* \(Fl */
  130. #define ACUTE c_acute /* acute accent \(aa */
  131. #define GRAVE c_grave /* grave accent \(ga */
  132. #define UNDERLINE c_under /* \(ul */
  133. #define ROOTEN c_rooten /* root en \(rn */
  134. #define BOXRULE c_boxrule /* box rule \(br */
  135. #define LEFTHAND c_lefthand /* left hand for word overflow */
  136. #define DAGGER c_dagger /* dagger for end of sentence/footnote */
  137. #define HYPHALG 1 /* hyphenation algorithm: 0=>good old troff, 1=>tex */
  138. /* array sizes, and similar limits: */
  139. #define MAXFONTS 99 /* Maximum number of fonts in fontab */
  140. #define NM 90 /* requests + macros */
  141. #define NN NNAMES /* number registers */
  142. #define NNAMES 15 /* predefined reg names */
  143. #define NIF 15 /* if-else nesting */
  144. #define NS 128 /* name buffer */
  145. #define NTM 1024 /* tm buffer */
  146. #define NEV 3 /* environments */
  147. #define EVLSZ 10 /* size of ev stack */
  148. #define STACKSIZE (12*1024) /* stack for macros and strings in progress */
  149. #define NHYP 10 /* max hyphens per word */
  150. #define NHEX 512 /* byte size of exception word list */
  151. #define NTAB 100 /* tab stops */
  152. #define NSO 5 /* "so" depth */
  153. #define NMF 5 /* number of -m flags */
  154. #define WDSIZE 500 /* word buffer click size */
  155. #define LNSIZE 4000 /* line buffer click size */
  156. #define OLNSIZE 5000 /* output line buffer click; bigger for 'w', etc. */
  157. #define NDI 5 /* number of diversions */
  158. #define ALPHABET alphabet /* number of characters in basic alphabet. */
  159. /* 128 for parochial USA 7-bit ascii, */
  160. /* 256 for "European" mode with e.g., Latin-1 */
  161. /* NCHARS must be greater than
  162. ALPHABET (ascii stuff) + total number of distinct char names
  163. from all fonts that will be run in this job (including
  164. unnamed ones and \N's)
  165. */
  166. #define NCHARS (8*1024) /* maximum size of troff character set*/
  167. /* However for nroff you want only :
  168. 1. number of special codes in charset of DESC, which ends up being the
  169. value of nchtab and which must be less than 512.
  170. 2. ALPHABET, which apparently is the size of the portion of the tables reserved
  171. for special control symbols
  172. Apparently the max N of \N is irrelevant; */
  173. /* to allow \N of up to 254 with up to 338 special characters
  174. you need NCHARS of 338 + ALPHABET = 466 */
  175. #define NROFFCHARS 1024 /* maximum size of nroff character set */
  176. #define NTRTAB NCHARS /* number of items in trtab[] */
  177. #define NWIDCACHE NCHARS /* number of items in widcache[] */
  178. #define NTRAP 20 /* number of traps */
  179. #define NPN 20 /* numbers in "-o" */
  180. #define FBUFSZ 512 /* field buf size words */
  181. #define IBUFSZ 4096 /* bytes */
  182. #define NC 1024 /* cbuf size words */
  183. #define NOV 10 /* number of overstrike chars */
  184. #define NPP 10 /* pads per field */
  185. /*
  186. Internal character representation:
  187. Internally, every character is carried around as
  188. a 32 bit cookie, called a "Tchar" (typedef long).
  189. Bits are numbered 31..0 from left to right.
  190. If bit 15 is 1, the character is motion, with
  191. if bit 16 it's vertical motion
  192. if bit 17 it's negative motion
  193. If bit 15 is 0, the character is a real character.
  194. if bit 31 zero motion
  195. bits 30..24 size
  196. bits 23..16 font
  197. */
  198. /* in the following, "L" should really be a Tchar, but ... */
  199. /* numerology leaves room for 16 bit chars */
  200. #define MOT (01uL << 16) /* motion character indicator */
  201. #define VMOT (01uL << 30) /* vertical motion bit */
  202. #define NMOT (01uL << 29) /* negative motion indicator */
  203. /* #define MOTV (MOT|VMOT|NMOT) /* motion flags */
  204. /* #define MAXMOT (~MOTV) /* maximum motion permitted */
  205. #define MAXMOT 0xFFFF
  206. #define ismot(n) ((n) & MOT)
  207. #define isvmot(n) (((n) & (MOT|VMOT)) == (MOT|VMOT)) /* must have tested MOT previously */
  208. #define isnmot(n) (((n) & (MOT|NMOT)) == (MOT|NMOT)) /* ditto */
  209. #define absmot(n) ((n) & 0xFFFF)
  210. #define ZBIT (01uL << 31) /* zero width char */
  211. #define iszbit(n) ((n) & ZBIT)
  212. #define FSHIFT 17
  213. #define SSHIFT (FSHIFT+7)
  214. #define SMASK (0177uL << SSHIFT) /* 128 distinct sizes */
  215. #define FMASK (0177uL << FSHIFT) /* 128 distinct fonts */
  216. #define SFMASK (SMASK|FMASK) /* size and font in a Tchar */
  217. #define sbits(n) (((n) >> SSHIFT) & 0177)
  218. #define fbits(n) (((n) >> FSHIFT) & 0177)
  219. #define sfbits(n) (((n) & SFMASK) >> FSHIFT)
  220. #define cbits(n) ((n) & 0x1FFFF) /* isolate character bits, */
  221. /* but don't include motions */
  222. extern int realcbits(Tchar);
  223. #define setsbits(n,s) n = (n & ~SMASK) | (Tchar)(s) << SSHIFT
  224. #define setfbits(n,f) n = (n & ~FMASK) | (Tchar)(f) << FSHIFT
  225. #define setsfbits(n,sf) n = (n & ~SFMASK) | (Tchar)(sf) << FSHIFT
  226. #define setcbits(n,c) n = (n & ~0xFFFFuL | (c)) /* set character bits */
  227. #define BYTEMASK 0377
  228. #define BYTE 8
  229. #define SHORTMASK 0XFFFF
  230. #define SHORT 16
  231. #define TABMASK ((unsigned) INT_MAX >> 1)
  232. #define RTAB ((TABMASK << 1) & ~TABMASK)
  233. #define CTAB (RTAB << 1)
  234. #define TABBIT 02 /* bits in gchtab */
  235. #define LDRBIT 04
  236. #define FCBIT 010
  237. #define PAIR(A,B) (A|(B<<SHORT))
  238. extern int Inch, Hor, Vert, Unitwidth;
  239. struct Spnames
  240. {
  241. int *n;
  242. char *v;
  243. };
  244. extern Spnames spnames[];
  245. /*
  246. String and macro definitions are stored conceptually in a giant array
  247. indexed by type Offset. In olden times, this array was real, and thus
  248. both huge and limited in size, leading to the "Out of temp file space"
  249. error. In this version, the array is represented by a list of blocks,
  250. pointed to by blist[].bp. Each block is of size BLK Tchars, and BLK
  251. MUST be a power of 2 for the macros below to work.
  252. The blocks associated with a particular string or macro are chained
  253. together in the array blist[]. Each blist[i].nextoff contains the
  254. Offset associated with the next block in the giant array, or -1 if
  255. this is the last block in the chain. If .nextoff is 0, the block is
  256. free.
  257. To find the right index in blist for an Offset, divide by BLK.
  258. */
  259. #define NBLIST 2048 /* starting number of blocks in all definitions */
  260. #define BLK 128 /* number of Tchars in a block; must be 2^N with defns below */
  261. #define rbf0(o) (blist[bindex(o)].bp[boffset(o)])
  262. #define bindex(o) ((o) / BLK)
  263. #define boffset(o) ((o) & (BLK-1))
  264. #define pastend(o) (((o) & (BLK-1)) == 0)
  265. /* #define incoff(o) ( (++o & (BLK-1)) ? o : blist[bindex(o-1)].nextoff ) */
  266. #define incoff(o) ( (((o)+1) & (BLK-1)) ? o+1 : blist[bindex(o)].nextoff )
  267. #define skipline(f) while (getc(f) != '\n')
  268. #define is(s) (strcmp(cmd, s) == 0)
  269. #define eq(s1, s2) (strcmp(s1, s2) == 0)
  270. typedef unsigned long Offset; /* an offset in macro/string storage */
  271. struct Blockp { /* info about a block: */
  272. Tchar *bp; /* the data */
  273. Offset nextoff; /* offset of next block in a chain */
  274. };
  275. extern Blockp *blist;
  276. #define RD_OFFSET (1 * BLK) /* .rd command uses block 1 */
  277. struct Diver { /* diversion */
  278. Offset op;
  279. int dnl;
  280. int dimac;
  281. int ditrap;
  282. int ditf;
  283. int alss;
  284. int blss;
  285. int nls;
  286. int mkline;
  287. int maxl;
  288. int hnl;
  289. int curd;
  290. };
  291. struct Stack { /* stack frame */
  292. int nargs;
  293. Stack *pframe;
  294. Offset pip;
  295. int pnchar;
  296. Tchar prchar;
  297. int ppendt;
  298. Tchar pch;
  299. Tchar *lastpbp;
  300. int mname;
  301. };
  302. extern Stack s;
  303. struct Divsiz {
  304. int dix;
  305. int diy;
  306. };
  307. struct Contab { /* command or macro */
  308. unsigned int rq;
  309. Contab *link;
  310. void (*f)(void);
  311. Offset mx;
  312. Offset emx;
  313. Divsiz *divsiz;
  314. };
  315. #define C(a,b) {a, 0, b, 0, 0} /* how to initialize a contab entry */
  316. extern Contab contab[NM];
  317. struct Numtab { /* number registers */
  318. unsigned int r; /* name */
  319. int val;
  320. short fmt;
  321. short inc;
  322. Numtab *link;
  323. };
  324. extern Numtab numtab[NN];
  325. #define PN 0
  326. #define NL 1
  327. #define YR 2
  328. #define HP 3
  329. #define CT 4
  330. #define DN 5
  331. #define MO 6
  332. #define DY 7
  333. #define DW 8
  334. #define LN 9
  335. #define DL 10
  336. #define ST 11
  337. #define SB 12
  338. #define CD 13
  339. #define PID 14
  340. struct Wcache { /* width cache, indexed by character */
  341. short fontpts;
  342. short width;
  343. };
  344. struct Tbuf { /* growable Tchar buffer */
  345. Tchar *_bufp;
  346. unsigned int _size;
  347. };
  348. /* the infamous environment block */
  349. #define ics envp->_ics
  350. #define sps envp->_sps
  351. #define spacesz envp->_spacesz
  352. #define lss envp->_lss
  353. #define lss1 envp->_lss1
  354. #define ll envp->_ll
  355. #define ll1 envp->_ll1
  356. #define lt envp->_lt
  357. #define lt1 envp->_lt1
  358. #define ic envp->_ic
  359. #define icf envp->_icf
  360. #define chbits envp->_chbits
  361. #define spbits envp->_spbits
  362. #define nmbits envp->_nmbits
  363. #define apts envp->_apts
  364. #define apts1 envp->_apts1
  365. #define pts envp->_pts
  366. #define pts1 envp->_pts1
  367. #define font envp->_font
  368. #define font1 envp->_font1
  369. #define ls envp->_ls
  370. #define ls1 envp->_ls1
  371. #define ad envp->_ad
  372. #define nms envp->_nms
  373. #define ndf envp->_ndf
  374. #define nmwid envp->_nmwid
  375. #define fi envp->_fi
  376. #define cc envp->_cc
  377. #define c2 envp->_c2
  378. #define ohc envp->_ohc
  379. #define tdelim envp->_tdelim
  380. #define hyf envp->_hyf
  381. #define hyoff envp->_hyoff
  382. #define hyphalg envp->_hyphalg
  383. #define un1 envp->_un1
  384. #define tabc envp->_tabc
  385. #define dotc envp->_dotc
  386. #define adsp envp->_adsp
  387. #define adrem envp->_adrem
  388. #define lastl envp->_lastl
  389. #define nel envp->_nel
  390. #define admod envp->_admod
  391. #define wordp envp->_wordp
  392. #define spflg envp->_spflg
  393. #define linep envp->_linep
  394. #define wdend envp->_wdend
  395. #define wdstart envp->_wdstart
  396. #define wne envp->_wne
  397. #define ne envp->_ne
  398. #define nc envp->_nc
  399. #define nb envp->_nb
  400. #define lnmod envp->_lnmod
  401. #define nwd envp->_nwd
  402. #define nn envp->_nn
  403. #define ni envp->_ni
  404. #define ul envp->_ul
  405. #define cu envp->_cu
  406. #define ce envp->_ce
  407. #define in envp->_in
  408. #define in1 envp->_in1
  409. #define un envp->_un
  410. #define wch envp->_wch
  411. #define pendt envp->_pendt
  412. #define pendw envp->_pendw
  413. #define pendnf envp->_pendnf
  414. #define spread envp->_spread
  415. #define it envp->_it
  416. #define itmac envp->_itmac
  417. #define hyptr envp->_hyptr
  418. #define tabtab envp->_tabtab
  419. #define line envp->_line._bufp
  420. #define lnsize envp->_line._size
  421. #define word envp->_word._bufp
  422. #define wdsize envp->_word._size
  423. #define oline _oline._bufp
  424. #define olnsize _oline._size
  425. /*
  426. * Note:
  427. * If this structure changes in ni.c, you must change
  428. * this as well, and vice versa.
  429. */
  430. struct Env {
  431. int _ics;
  432. int _sps;
  433. int _spacesz;
  434. int _lss;
  435. int _lss1;
  436. int _ll;
  437. int _ll1;
  438. int _lt;
  439. int _lt1;
  440. Tchar _ic;
  441. int _icf;
  442. Tchar _chbits;
  443. Tchar _spbits;
  444. Tchar _nmbits;
  445. int _apts;
  446. int _apts1;
  447. int _pts;
  448. int _pts1;
  449. int _font;
  450. int _font1;
  451. int _ls;
  452. int _ls1;
  453. int _ad;
  454. int _nms;
  455. int _ndf;
  456. int _nmwid;
  457. int _fi;
  458. int _cc;
  459. int _c2;
  460. int _ohc;
  461. int _tdelim;
  462. int _hyf;
  463. int _hyoff;
  464. int _hyphalg;
  465. int _un1;
  466. int _tabc;
  467. int _dotc;
  468. int _adsp;
  469. int _adrem;
  470. int _lastl;
  471. int _nel;
  472. int _admod;
  473. Tchar *_wordp;
  474. int _spflg;
  475. Tchar *_linep;
  476. Tchar *_wdend;
  477. Tchar *_wdstart;
  478. int _wne;
  479. int _ne;
  480. int _nc;
  481. int _nb;
  482. int _lnmod;
  483. int _nwd;
  484. int _nn;
  485. int _ni;
  486. int _ul;
  487. int _cu;
  488. int _ce;
  489. int _in;
  490. int _in1;
  491. int _un;
  492. int _wch;
  493. int _pendt;
  494. Tchar *_pendw;
  495. int _pendnf;
  496. int _spread;
  497. int _it;
  498. int _itmac;
  499. Tchar *_hyptr[NHYP];
  500. long _tabtab[NTAB];
  501. Tbuf _line;
  502. Tbuf _word;
  503. };
  504. extern Env env[];
  505. extern Env *envp;
  506. enum { MBchar = 'U', Troffchar = 'C', Number = 'N', Install = 'i', Lookup = 'l' };
  507. /* U => utf, for instance; C => \(xx, N => \N'...' */
  508. struct Chwid { /* data on one character */
  509. Ushort num; /* character number:
  510. 0 -> not on this font
  511. >= ALPHABET -> its number among all Cxy's */
  512. Ushort code; /* char code for actual device. used for \N */
  513. char *str; /* code string for nroff */
  514. Uchar wid; /* width */
  515. Uchar kern; /* ascender/descender */
  516. };
  517. struct Font { /* characteristics of a font */
  518. int name; /* int name, e.g., BI (2 chars) */
  519. char longname[64]; /* long name of this font (e.g., "Bembo" */
  520. char *truename; /* path name of table if not in standard place */
  521. int nchars; /* number of width entries for this font */
  522. char specfont; /* 1 == special font */
  523. int spacewidth; /* width of space on this font */
  524. int defaultwidth; /* default width of characters on this font */
  525. Chwid *wp; /* widths, etc., of the real characters */
  526. char ligfont; /* 1 == ligatures exist on this font */
  527. };
  528. /* ligatures, ORed into ligfont */
  529. #define LFF 01
  530. #define LFI 02
  531. #define LFL 04
  532. #define LFFI 010
  533. #define LFFL 020
  534. /* tracing modes */
  535. #define TRNARGS 01 /* trace legality of numeric arguments */
  536. #define TRREQ 02 /* trace requests */
  537. #define TRMAC 04 /* trace macros */
  538. #define RQERR 01 /* processing request/macro */
  539. /* typewriter driving table structure */
  540. extern Term t;
  541. struct Term {
  542. int bset; /* these bits have to be on */
  543. int breset; /* these bits have to be off */
  544. int Hor; /* #units in minimum horiz motion */
  545. int Vert; /* #units in minimum vert motion */
  546. int Newline; /* #units in single line space */
  547. int Char; /* #units in character width */
  548. int Em; /* ditto */
  549. int Halfline; /* half line units */
  550. int Adj; /* minimum units for horizontal adjustment */
  551. char *twinit; /* initialize terminal */
  552. char *twrest; /* reinitialize terminal */
  553. char *twnl; /* terminal sequence for newline */
  554. char *hlr; /* half-line reverse */
  555. char *hlf; /* half-line forward */
  556. char *flr; /* full-line reverse */
  557. char *bdon; /* turn bold mode on */
  558. char *bdoff; /* turn bold mode off */
  559. char *iton; /* turn italic mode on */
  560. char *itoff; /* turn italic mode off */
  561. char *ploton; /* turn plot mode on */
  562. char *plotoff; /* turn plot mode off */
  563. char *up; /* sequence to move up in plot mode */
  564. char *down; /* ditto */
  565. char *right; /* ditto */
  566. char *left; /* ditto */
  567. Font tfont; /* widths and other info, as in a troff font */
  568. };
  569. extern Term t;
  570. /*
  571. * for error reporting; keep track of escapes/requests with numeric arguments
  572. */
  573. struct Numerr {
  574. char type; /* request or escape? */
  575. char esc; /* was escape sequence named esc */
  576. char escarg; /* argument of esc's like \D'l' */
  577. unsigned int req; /* was request or macro named req */
  578. };