Commit | Line | Data |
---|---|---|
e24282c2 JA |
1 | #include <signal.h> |
2 | ||
3 | #ifdef vax | |
4 | #define MAXPTR (char *)0xfffffff | |
5 | /* max value of pointer on vaxes */ | |
6 | #define INCORE | |
7 | #endif | |
8 | #ifdef pdp11 | |
9 | #define MAXPTR (char *)-1 /* max value of any pointer variable */ | |
10 | /* likely to be machine-dependent */ | |
11 | #endif | |
12 | ||
13 | /* starting values for typesetting parameters: */ | |
14 | ||
15 | #define PS 10 /* default point size */ | |
16 | #define FT 1 /* default font position */ | |
17 | #define LL (unsigned) 65*INCH/10 /* line length; 39picas=6.5in */ | |
18 | #define VS ((12*INCH)/72) /* initial vert space */ | |
19 | ||
20 | #ifdef NROFF | |
21 | # define EM t.Em | |
22 | # define HOR t.Hor | |
23 | # define VERT t.Vert | |
24 | # define INCH 240 /* increments per inch */ | |
25 | # define SPS INCH/10 /* space size */ | |
26 | # define SS INCH/10 /* " */ | |
27 | # define TRAILER 0 | |
28 | # define UNPAD 0227 | |
29 | # define PO 0 /* page offset */ | |
30 | # define ASCII 1 | |
31 | # define PTID 1 | |
32 | # define LG 0 | |
33 | # define DTAB 0 /* set at 8 Ems at init time */ | |
34 | # define ICS 2*SPS | |
35 | #endif | |
36 | #ifndef NROFF /* TROFF */ | |
37 | /* Inch is set by ptinit() when troff started. | |
38 | /* all derived values set then too | |
39 | */ | |
40 | # define INCH Inch /* troff resolution -- number of goobies/inch */ | |
41 | # define POINT (INCH/72) /* goobies per point (1/72 inch) */ | |
42 | # define HOR Hor /* horizontal resolution in goobies */ | |
43 | # define VERT Vert /* vertical resolution in goobies */ | |
44 | # define SPS (EM/3) /* space size */ | |
45 | # define SS 12 /* space size in 36ths of an em */ | |
46 | # define UNPAD 027 | |
47 | # define PO (INCH - INCH/27) /* page offset 26/27ths inch */ | |
48 | /* # define EM (POINT * pts) */ | |
49 | #define EM (((long) INCH * pts + 36) / 72) /* don't lose significance */ | |
50 | #define EMPTS(pts) (((long) INCH * (pts) + 36) / 72) | |
51 | # define ASCII 0 | |
52 | # define PTID 1 | |
53 | # define LG 1 | |
54 | # define DTAB (INCH/2) | |
55 | # define ICS 3*SPS | |
56 | #endif | |
57 | ||
58 | /* These "characters" are used to encode various internal functions | |
59 | /* Some make use of the fact that most ascii characters between | |
60 | /* 0 and 040 don't have any graphic or other function. | |
61 | /* The few that do have a purpose (e.g., \n, \b, \t, ... | |
62 | /* are avoided by the ad hoc choices here. | |
63 | /* See ifilt[] in n1.c for others -- 1, 2, 3, 5, 6, 7, 010, 011, 012 | |
64 | */ | |
65 | ||
66 | #define LEADER 001 | |
67 | #define IMP 004 /* impossible char; glues things together */ | |
68 | #define TAB 011 | |
69 | #define RPT 014 /* next character is to be repeated many times */ | |
70 | #define CHARHT 015 /* size field sets character height */ | |
71 | #define SLANT 016 /* size field sets amount of slant */ | |
72 | #define DRAWFCN 017 /* next several chars describe arb drawing fcn */ | |
73 | /* line: 'l' dx dy char */ | |
74 | /* circle: 'c' r */ | |
75 | /* ellipse: 'e' rx ry */ | |
76 | /* arc: 'a' dx dy r */ | |
77 | /* wiggly line '~' x y x y ... */ | |
78 | #define DRAWLINE 'l' | |
79 | #define DRAWCIRCLE 'c' /* circle */ | |
80 | #define DRAWELLIPSE 'e' | |
81 | #define DRAWARC 'a' /* arbitrary arc */ | |
82 | #define DRAWWIG '~' /* wiggly line with spline */ | |
83 | ||
84 | #define LEFT 020 /* \{ */ | |
85 | #define RIGHT 021 /* \} */ | |
86 | #define FILLER 022 /* \& and similar purposes */ | |
87 | #define OHC 024 /* optional hyphenation character \% */ | |
88 | #define CONT 025 /* \c character */ | |
89 | #define PRESC 026 /* printable escape */ | |
90 | #define XPAR 030 /* transparent mode indicator */ | |
91 | #define FLSS 031 | |
92 | #define WORDSP 032 /* paddable word space */ | |
93 | #define ESC 033 | |
94 | ||
95 | /* there are several tests (using iscontrol()) | |
96 | /* that rely on these having 034 true. | |
97 | */ | |
98 | #define iscontrol(n) (n>=034 && n<=037) /* used to test the next two */ | |
99 | #define HX 035 /* next character is value of \x'...' */ | |
100 | #define FONTPOS 036 /* position of font \f(XX encoded in top */ | |
101 | #define MAXFONTS 99 /* Maximum number of fonts (in fontlab) */ | |
102 | ||
103 | #define HYPHEN c_hyphen | |
104 | #define EMDASH c_emdash /* \(em */ | |
105 | #define RULE c_rule /* \(ru */ | |
106 | #define MINUS c_minus /* minus sign on current font */ | |
107 | #define NARSP c_narsp /* narrow space \|: fake character */ | |
108 | #define HNARSP c_hnarsp /* half narrow space \^: fake character */ | |
109 | #define LIG_FI c_fi /* \(ff */ | |
110 | #define LIG_FL c_fl /* \(fl */ | |
111 | #define LIG_FF c_ff /* \(ff */ | |
112 | #define LIG_FFI c_ffi /* \(Fi */ | |
113 | #define LIG_FFL c_ffl /* \(Fl */ | |
114 | #define ACUTE c_acute /* acute accent \(aa */ | |
115 | #define GRAVE c_grave /* grave accent \(ga */ | |
116 | #define UNDERLINE c_under /* \(ul */ | |
117 | #define ROOTEN c_rooten /* root en \(rn */ | |
118 | #define BOXRULE c_boxrule /* box rule \(br */ | |
119 | #define LEFTHAND c_lefthand | |
120 | ||
121 | /* array sizes, and similar limits: */ | |
122 | ||
123 | #define NFONT 10 /* maximum number of fonts (including specials) */ | |
124 | ||
125 | #define MAXCHARS 255 /* Maximum characters in one font up to now */ | |
126 | ||
127 | /* define enough space for the fontcache. EXTRAFONT is maximum space | |
128 | currently to be used by a font | |
129 | widthtab+kerntab+code dev.nchtab "asciifitab" */ | |
130 | #define EXTRAFONT (3*MAXCHARS * sizeof(char) + dev.nchtab + (128-32)\ | |
131 | * sizeof(char) + sizeof(struct font) + 255 * sizeof(short)) | |
132 | /* fonttab */ | |
133 | ||
134 | #define NN 300 /* number registers */ | |
135 | #define NNAMES 15 /* predefined reg names */ | |
136 | #define NIF 15 /* if-else nesting */ | |
137 | #define NS 64 /* name buffer */ | |
138 | #define NTM 256 /* tm buffer */ | |
139 | #define NEV 3 /* environments */ | |
140 | #define EVLSZ 10 /* size of ev stack */ | |
141 | #define DSIZE 512 /* disk sector size in chars */ | |
142 | ||
143 | /* the following defines the size of the infamous environment block. | |
144 | this macro is guaranteed to blow older C preprocessors out of the | |
145 | water. | |
146 | Furthermore, it is wrong: the proper value is more accurately | |
147 | determined by using sizeof *tchar in several places. | |
148 | no harm is done as long as it's big enough. | |
149 | */ | |
150 | ||
151 | #define EVUSED \ | |
152 | (62 * sizeof(int) /* integers in env block */ \ | |
153 | + 9 * sizeof(tchar) /* tchars in env block */ \ | |
154 | + NHYP * sizeof(tchar) /* hytab */ \ | |
155 | + NTAB * sizeof(int) /* tabtab */ \ | |
156 | + (LNSIZE+WDSIZE) * sizeof(tchar)) /* line+word */ | |
157 | ||
158 | /* added two int's to environment block for ha request jna */ | |
159 | /* added another int for changed ht request jna */ | |
160 | ||
161 | #define EVSPARE DSIZE - EVUSED % DSIZE /* number of leftover chars */ | |
162 | #define EVS (EVUSED + EVSPARE) /* should be a multiple of DSIZE */ | |
163 | #define NM 350 /* requests + macros */ | |
164 | #define DELTA 1024 /* delta core bytes */ | |
165 | #define NHYP 10 /* max hyphens per word */ | |
166 | #define NHEX 128 /* byte size of exception word list */ | |
167 | #define NTAB 35 /* tab stops */ | |
168 | #define NSO 5 /* "so" depth */ | |
169 | #define WDSIZE 270 /* word buffer size */ | |
170 | #define LNSIZE 680 /* line buffer size */ | |
171 | #define NDI 5 /* number of diversions */ | |
172 | #define NTRTAB 350 /* number of items in trtab[] */ | |
173 | #define NTRAP 20 /* number of traps */ | |
174 | #define NPN 20 /* numbers in "-o" */ | |
175 | #define FBUFSZ 256 /* field buf size words */ | |
176 | #define OBUFSZ 512 /* bytes */ | |
177 | #define IBUFSZ 512 /* bytes */ | |
178 | #define NC 256 /* cbuf size words */ | |
179 | #define NOV 10 /* number of overstrike chars */ | |
180 | #define NPP 10 /* pads per field */ | |
181 | ||
182 | /* | |
183 | Internal character representation: | |
184 | Internally, every character is carried around as | |
185 | a 32 bit cookie, called a "tchar" (typedef long). | |
186 | Bits are numbered 31..0 from left to right. | |
187 | If bit 15 is 1, the character is motion, with | |
188 | if bit 16 it's vertical motion | |
189 | if bit 17 it's negative motion | |
190 | If bit 15 is 0, the character is a real character. | |
191 | if bit 31 zero motion | |
192 | bits 30..24 size | |
193 | bits 23..16 font | |
194 | */ | |
195 | ||
196 | /* in the following, "L" should really be a tchar, but ... */ | |
197 | ||
198 | #define MOT (unsigned short)(01<<15) /* motion character indicator */ | |
199 | #define MOTV (07L<<15) /* clear for motion part */ | |
200 | #define VMOT (01L<<16) /* vert motion bit */ | |
201 | #define NMOT (01L<<17) /* negative motion indicator*/ | |
202 | #define MAXMOT 32767 /* bad way to write this!!! */ | |
203 | #define ismot(n) ((unsigned short)(n) & MOT) /* (short) is a cheap mask */ | |
204 | #define isvmot(n) ((n) & VMOT) /* must have tested MOT previously */ | |
205 | #define isnmot(n) ((n) & NMOT) /* ditto */ | |
206 | #define absmot(n) ((unsigned short)(n) & ~MOT) /* (short) is cheap mask */ | |
207 | ||
208 | #define ZBIT (01L << 31) /* zero width char */ | |
209 | #define iszbit(n) ((n) & ZBIT) | |
210 | ||
211 | #define SMASK (0177L << 24) | |
212 | #define FMASK (0377L << 16) | |
213 | #define SFMASK (SMASK|FMASK) /* size and font in a tchar */ | |
214 | #define CMASK ~MOT /* clears MOT */ | |
215 | #define CMASKL 077777L | |
216 | #define sbits(n) ((unsigned short)((n) >> 24) & 0177) | |
217 | #define fbits(n) ((unsigned short)((n) >> 16) & 0377) | |
218 | #define sfbits(n) ((unsigned short)(((n) & SFMASK) >> 16)) | |
219 | #define cbits(n) (unsigned short)(n) /* isolate bottom 16 bits */ | |
220 | #define setsbits(n,s) n = (n & ~SMASK) | (tchar)(s) << 24 | |
221 | #define setfbits(n,f) n = (n & ~FMASK) | (tchar)(f) << 16 | |
222 | #define setsfbits(n,sf) n = (n & ~SFMASK) | (tchar)(sf) << 16 | |
223 | #define setcbits(n,c) n = (n & ~CMASKL | (c)) /* set character bits */ | |
224 | ||
225 | #define MMASK 0100000 /* macro mask indicator */ | |
226 | #define BMASK 0377 | |
227 | #define BYTE 8 | |
228 | ||
229 | #define TMASK 037777 | |
230 | #define RTAB (unsigned) 0100000 | |
231 | #define CTAB 040000 | |
232 | ||
233 | #define PAIR(A,B) (A|(B<<BYTE)) | |
234 | ||
235 | typedef unsigned filep; | |
236 | #define BLK 128 /* alloc block tchars */ | |
237 | #define NBLIST 1024 /* allocation list */ | |
238 | /* previous values were BLK 256 NBLIST 512 */ | |
239 | /* it seems good to keep the product constant */ | |
240 | /* BLK*NBLIST<=65536 words, if filep=unsigned */ | |
241 | ||
242 | ||
243 | #define THRESH 160 /*digram goodness threshold*/ | |
244 | #define DUTCH_THRESH 3 /* for recursive bestesplits jna */ | |
245 | /* added the ha request, to change the hyphenation algorithm jna */ | |
246 | ||
247 | #define ORIGINAL 0 /* The original (American English) algorithm */ | |
248 | #define DUTCH 1 /* "Bestesplits" routine */ | |
249 | #define MAXDIALECTS 1 /* number of dialects minus 1 */ | |
250 | ||
251 | typedef long tchar; /* as an experiment */ | |
252 | ||
253 | extern tchar getch(), getch0(); | |
254 | extern tchar rbf(), rbf0(); | |
255 | extern tchar mot(), hmot(), vmot(); | |
256 | extern tchar makem(), sethl(); | |
257 | extern tchar popi(); | |
258 | extern tchar getlg(); | |
259 | extern tchar xlss(); | |
260 | extern tchar setfield(); | |
261 | extern tchar setz(); | |
262 | extern tchar setch(), absch(); | |
263 | extern tchar setht(), setslant(); | |
264 | ||
265 | #define atoi(i) ((int) atoi0(i)) | |
266 | extern long atoi0(); | |
267 | ||
268 | extern int Inch, Hor, Vert, Unitwidth; | |
269 | ||
270 | /* these characters are used as various signals or values | |
271 | /* in miscellaneous places. | |
272 | /* values are set in specnames in t10.c | |
273 | */ | |
274 | ||
275 | extern int c_hyphen; | |
276 | extern int c_emdash; | |
277 | extern int c_rule; | |
278 | extern int c_minus; | |
279 | extern int c_narsp; | |
280 | extern int c_hnarsp; | |
281 | extern int c_fi; | |
282 | extern int c_fl; | |
283 | extern int c_ff; | |
284 | extern int c_ffi; | |
285 | extern int c_ffl; | |
286 | extern int c_acute; | |
287 | extern int c_grave; | |
288 | extern int c_under; | |
289 | extern int c_rooten; | |
290 | extern int c_boxrule; | |
291 | extern int c_lefthand; | |
292 | ||
293 | extern int stderr; /* this is NOT the stdio value! */ |