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