OSDN Git Service

start extending.
[putex/putex.git] / src / texsourc / texd.h
1 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2 #define ALLOCATEINI        /* allocate iniTeX (550 k) trie_c, trie_o, trie_l, trie_r, trie_hash, trie_taken */
3 #define ALLOCATEMAIN       /* allocate main memory for TeX (2 Meg) zmem = zzzaa */
4 #define ALLOCATEFONT       /* allocate font_info (800 k) (dynamically now) */
5 #define ALLOCATETRIES      /* allocate hyphenation trie stuff (270 k) trie_trl, trie_tro, trie_trc */
6 #define ALLOCATEHYPHEN     /* allocate hyphenation exception tables */
7 #define VARIABLETRIESIZE   /* allow trie_size to be variable */
8 #define ALLOCATESTRING     /* allocate strings and string pointers (184 k)str_pool & str_start */
9 #define ALLOCATESAVESTACK  /* experiment to dynamically deal with save_stack 99/Jan/4 */
10 #define ALLOCATEINPUTSTACK /* experiment to dynamically deal with input_stack 99/Jan/21 */
11 #define ALLOCATENESTSTACK  /* experiment to dynamically deal with nest_stack 99/Jan/21 */
12 #define ALLOCATEPARAMSTACK /* experiment to dynamically deal with param_stack 99/Jan/21 */
13 #define ALLOCATEBUFFER     /* experiment to dynamically deal with input buffer 99/Jan/22 */
14 #define INCREASEFIXED
15 /* increase number of fonts - quarterword 16 bit - max_quarterword limit */
16 /* there may still be some bugs with this however ... also may slow down */
17 /* also: should split use of quarterword for (i) font from (ii) char */
18 /* for example, xeq_level ? hyphenation trie_trc ? */
19 #define INCREASEFONTS
20 /* make font_info array fmemoryword == 32 bit instead of memory_word = 64 bit */
21 #define SHORTFONTINFO
22 /* make hash table htwo_halves == 32 bit instead of two_halves == 64 bit */
23 /* increase trie_op_size from 751 to 3001 96/Oct/12 */
24 #define INCREASETRIEOP
25 #define COMPACTFORMAT
26
27
28 /* With old PharLap linker it was important to avoid large fixed allocation */
29 /* Now may be better to use fixed arrays rather than allocate them */
30 /* hence ALLOCATEZQTB, ALLOCATEDVIBUF and ALLOCATEMINOR are NOT defined */
31
32 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
33 #define STAT
34 #include "texmf.h"
35
36 // #define max_halfword 65535L  /* for 32 bit memory word */
37 // #define max_halfword 262143L /* for 36 bit memory word */
38 #define min_halfword -2147483647L /* for 64 bit memory word (signed) */
39 #define max_halfword  2147483647L /* for 64 bit memory word (signed) */
40
41 #define block_size 1000 /* block_size for variable length node alloc */
42
43 /* min_quarterword assumed 0 -- i.e. we use unsigned types for quarterword */
44 #define min_quarterword 0
45 #ifdef INCREASEFONTS
46   #define max_quarterword 65535L
47 #else
48   #define max_quarterword 255
49 #endif
50
51 /* #define default_mem_top 262140L */ /* usual big TeX allocation 2 Meg bytes */
52 /* #define default_mem_top 131070L */ /* usual big TeX allocation 1 Meg bytes */
53 #define default_mem_top 65534L        /* usual small TeX allocation 0.5 Meg   */
54
55 /* mem_bot smallest index in mem array dumped by iniTeX mem_top >= mem_min */
56 #define mem_bot 0
57 /* mem_top largest index in mem array dumped by iniTeX mem_top <= mem_max */
58 #ifdef ALLOCATEMAIN
59   EXTERN integer mem_top;
60   #define max_mem_size (max_halfword / sizeof(memory_word) - 1)
61 #else
62   #define mem_top 262140L
63 #endif
64
65 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
66 /* mem_max == mem_top in iniTeX, otherwise mem_max >= mem_top */
67 /* if ALLOCATEMAIN is true, then mem_max is a variable */
68 /* otherwise it is a pre-processor defined constant */
69 #ifdef ALLOCATEMAIN
70   EXTERN integer mem_max;
71 #else
72 /* #define mem_max 262140L */
73   #define mem_max mem_top
74 #endif
75
76 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
77 /* if ALLOCATEMAIN is true, then mem_min is a variable */
78 /* otherwise it is a pre-processor defined constant */
79 /* mem_min == mem_bot in iniTeX, otherwise mem_min <= mem_bot */
80 #ifdef ALLOCATEMAIN
81   EXTERN integer mem_min;
82 #else
83   #define mem_min 0
84 #endif
85
86 #ifdef ALLOCATEBUFFER
87   #define initial_buf_size   1000
88   #define increment_buf_size 2000
89   #define buf_size           2000000L /* arbitrary limit <= max_halfword */
90   EXTERN ASCII_code *        buffer;
91 #else
92   #define buf_size           20000
93   EXTERN ASCII_code          buffer[buf_size + 4]; /* padded out to ...  + 4 */
94 #endif
95 EXTERN integer first; 
96 EXTERN integer last; 
97 EXTERN integer max_buf_stack; 
98
99 #define error_line      79
100 #define half_error_line 50
101 #define max_print_line  79
102
103 #ifdef INCREASEFIXED
104   #define max_in_open 127
105 #else
106   #define max_in_open 15
107 #endif
108
109 /* maximum internal font number - cannot be greated than max_quarterword! */
110 #ifdef INCREASEFONTS
111   #define font_max 1023
112 #else
113   #define font_max 255
114 #endif
115
116 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
117 /* free the limit on font memory ! */
118 #ifdef ALLOCATEFONT
119   #define font_mem_size (max_halfword / sizeof(memory_word) - 1)
120 #else
121   #define font_mem_size 100000L
122 #endif
123
124 /* below is new dynamic allocation - bkph 93/Nov/28 */
125 #ifdef ALLOCATEFONT
126   #define initial_font_mem_size   20000
127   #define increment_font_mem_size 40000
128 #endif
129
130 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
131 /* max_strings max number of strings */
132 #ifdef ALLOCATESTRING
133   #define max_strings (max_halfword / sizeof(pool_pointer) - 1)
134   #define pool_size (max_halfword - 1)
135 #else
136   #define max_strings 16384
137   #define pool_size 124000L
138 #endif
139 #define string_vacancies 100000L
140
141 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
142 /* #if defined (ALLOCATEINITRIE) && defined (ALLOCATEHYPHEN) */
143 #ifdef VARIABLETRIESIZE
144   EXTERN integer trie_size;
145   #define default_trie_size 60000
146 #else
147   #define trie_size 30000     /* 3.14159 C version */
148 #endif
149
150 /* increase trie_op to accomadate more hyphenation patterns 96/OCt/12 */
151 #ifdef INCREASETRIEOP
152   #define trie_op_size      3001
153   #define neg_trie_op_size -3001
154   #define min_trie_op       0
155   #define max_trie_op       1000
156 #else
157   #define trie_op_size      751
158   #define neg_trie_op_size -751
159   #define min_trie_op       0
160   #define max_trie_op       500
161 #endif
162
163 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
164 /* dvi_buf_size must be multiple of 8 - half is written out at a time */
165 #ifdef ALLOCATEDVIBUF
166   #define default_dvi_buf_size 16384
167   EXTERN int dvi_buf_size;
168 #else
169   #define dvi_buf_size 16384
170 #endif
171
172 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
173 /* WARNING: increasing hash table for cs names is not trivial */
174 /* size of hash table for control sequence name  < (mem_max - mem_min) / 10 */
175 /* #define hash_size 9500 */
176 /* #define hash_size 25000 */   /* 96/Jan/10 */
177 #define hash_size 32768       /* 96/Jan/17 */
178 /* trick to try and get around eqtb_extra problem */
179 /* 1024 fonts = font_max + 2 */
180 /* #define hash_extra -256 */
181 #define hash_extra (255 - font_max)
182 /* hash prime about 85% of hash_size (+ hash_extra) */
183 /* #define hashprime 7919  */
184 /* #define hash_prime 21247 */    /* 96/Jan/10 */
185 #define hash_prime 27197      /* 96/Jan/17 */
186 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
187
188 /* CONSTRAINT: reconcile increase font use by stealing from hash table ... */
189
190 /* Probably require eqtb_extra to be zero, so hash_extra = 255 - font_max */
191 #if (hash_extra != 255 - font_max)
192   #error ERROR: hash_extra not equal to (255 - font_max)
193 #endif
194
195 /* sec 0113 */
196 #ifdef INCREASEFONTS
197   typedef unsigned short quarterword;
198 #else
199   typedef unsigned char quarterword;
200 #endif
201 /* possible alternative ? */
202 /* min_halfword = 0 and double max_halfword ? */
203 /* typedef unsigned long halfword; NO NO: since mem_min may be < 0 */
204 /* sec 0113 */
205 typedef integer halfword;
206 typedef char two_choices;
207 typedef char four_choices;
208 /* sec 0113 */
209 #include "texmfmem.h"
210 /* sec 0150 */
211 typedef char glue_ord; 
212 /* sec 0212 */
213 typedef struct
214 {
215   int mode_field;
216   halfword head_field, tail_field;
217   integer pg_field, ml_field;
218   memory_word aux_field;
219 } list_state_record;
220 /* sec 0269 */
221 typedef char group_code;
222 /* sec 0300 */
223 typedef struct
224 {
225   quarterword state_field, index_field; 
226   halfword start_field, loc_field, limit_field, name_field;
227 } in_state_record; 
228 /* sec 0548 */
229 typedef integer internal_font_number;
230 typedef integer font_index;
231 /* sec 0594 */
232 typedef integer dvi_index;
233 /* sec 0920 */
234 typedef integer trie_op_code;
235 /* sec 0925 */
236 typedef integer trie_pointer; 
237 /* typedef short hyph_pointer; */   /* increased 1996/Oct/20 ??? */
238 typedef integer hyph_pointer;
239
240 EXTERN integer bad;
241 EXTERN ASCII_code xord[256];
242 EXTERN ASCII_code xchr[256];
243 EXTERN unsigned char name_of_file[PATHMAX + 4];
244 EXTERN integer name_length;
245
246 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
247 #ifdef ALLOCATESTRING
248   #define initial_pool_size     40000
249   #define increment_pool_size   80000
250   EXTERN packed_ASCII_code *    str_pool;
251   #define initial_max_strings   5000
252   #define increment_max_strings 10000
253   EXTERN pool_pointer *         str_start;
254 #else
255   EXTERN packed_ASCII_code      str_pool[pool_size + 1]; 
256   EXTERN pool_pointer           str_start[max_strings + 1]; 
257 #endif
258 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
259
260 EXTERN pool_pointer pool_ptr;
261 EXTERN str_number   str_ptr;
262 EXTERN pool_pointer init_pool_ptr;
263 EXTERN str_number   init_str_ptr;
264
265 #ifdef INITEX
266 EXTERN alpha_file pool_file; 
267 #endif
268
269 EXTERN alpha_file log_file; 
270 /* EXTERN char selector; */
271 /* EXTERN integer selector; */ /* padded out */
272 EXTERN int selector;      /* padded out */ /* 95/Jan/7 */
273 /* EXTERN char dig[23]; */
274 EXTERN char dig[23 + 1];  /* padded out */
275 EXTERN integer tally;
276 EXTERN integer term_offset;
277 EXTERN integer file_offset;
278 EXTERN ASCII_code trick_buf[error_line + 1]; /* already padded 79 + 1 */
279 EXTERN integer trick_count;
280 EXTERN integer first_count;
281 /* EXTERN char interaction;  */
282 /* EXTERN integer interaction; */ /* padded out */
283 EXTERN int interaction; /* padded out */      /* 95/Jan/7 */
284 EXTERN bool deletions_allowed;
285 EXTERN bool set_box_allowed;
286 /* EXTERN char history; */
287 /* EXTERN integer history; */ /* padded out */
288 EXTERN int history; /* padded out */        /* 95/Jan/7 */
289 /* EXTERN schar error_count;  */
290 /* EXTERN integer error_count; */ /* padded out */
291 EXTERN int error_count; /* padded out */      /* 95/Jan/7 */
292 EXTERN char * help_line[6];
293 /* EXTERN char help_ptr; */
294 /* EXTERN integer help_ptr; */ /* padded out */
295 EXTERN int help_ptr; /* padded out */       /* 95/Jan/7 */
296 EXTERN bool use_err_help;
297 /* EXTERN integer interrupt;  */
298 EXTERN volatile integer interrupt;  /* bkph - do avoid compiler optimization */
299 EXTERN bool OK_to_interrupt;
300 EXTERN bool arith_error;
301 EXTERN scaled tex_remainder;
302 EXTERN halfword temp_ptr;
303
304 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
305 #ifdef ALLOCATEMAIN
306   EXTERN memory_word * main_memory;   /* remembered so can be free() later */
307   EXTERN memory_word * mem;
308 #else
309   /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
310   EXTERN memory_word 
311   /* #define zmem (zzzaa - (int)(mem_min)) */
312   /*  zzzaa[mem_max - mem_min + 1]; */
313   #define zmem (zzzaa - (int)(mem_bot))
314   zzzaa[mem_max - mem_bot + 1];
315 #endif
316
317 EXTERN halfword lo_mem_max;
318 EXTERN halfword hi_mem_min;
319 EXTERN integer var_used, dyn_used;
320 EXTERN halfword avail;
321 EXTERN halfword mem_end;
322 EXTERN halfword mem_start;
323 EXTERN halfword rover;
324
325 /* NOTE: the following really also need to be dynamically allocated */
326 #ifdef DEBUG
327 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
328 #ifdef ALLOCATEMAIN
329   EXTERN char * zzzab;
330 #else
331 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
332 /* EXTERN bool  */    /* save (4 - 1) * mem_max - mem_min */
333 EXTERN char
334 /* #define freearr (zzzab - (int)(mem_min)) */
335 /*  zzzab[mem_max - mem_min + 1];  */
336 #define freearr (zzzab - (int)(mem_bot))
337   zzzab[mem_max - mem_bot + 1]; 
338 #endif
339
340 #ifdef ALLOCATEMAIN
341   EXTERN char *zzzac;
342 #else
343 /* EXTERN bool */   /* save (4 - 1) * mem_max - mem_min */
344 EXTERN char
345 /* #define wasfree (zzzac - (int)(mem_min)) */
346 #define wasfree (zzzac - (int)(mem_bot))
347 /*  zzzac[mem_max - mem_min + 1];  */
348   zzzac[mem_max - mem_bot + 1]; 
349 #endif
350
351 EXTERN halfword was_mem_end, was_lo_max, was_hi_min;
352 EXTERN bool panicking;
353 #endif /* DEBUG */
354
355 EXTERN integer font_in_short_display;
356 EXTERN integer depth_threshold;
357 EXTERN integer breadth_max;
358 /* EXTERN list_state_record nest[nest_size + 1];  */
359 /* EXTERN short shown_mode; */
360 /* EXTERN integer shown_mode; */ /* padded out */
361 EXTERN int shown_mode; /* padded out */   /* 95/Jan/7 */
362 /* EXTERN char old_setting; */
363 /* EXTERN integer old_setting; */ /* padded out */
364 EXTERN int old_setting; /* padded out */    /* 95/Jan/7 */
365
366 /* eqtn_extra is no longer used --- it should be 0 96/Jan/10 */
367 #ifdef INCREASEFONTS
368   #define eqtb_extra (font_max - 255 + hash_extra)
369 #else
370   #define eqtb_extra 0
371 #endif
372
373 /* Probably require eqtb_extra to be zero, so hash_extra = 255 - font_max */
374 #if (eqtb_extra != 0)
375   #error ERROR: eqtb_extra is not zero (need hash_extra equal 255 - font_max)
376 #endif
377
378 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
379 #ifdef ALLOCATEZEQTB
380 EXTERN memory_word * zeqtb;
381 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
382 #else
383 #ifdef INCREASEFONTS
384 EXTERN memory_word eqtb[(hash_size + 4007) + eqtb_extra];
385 #else
386 EXTERN memory_word zeqtb[(hash_size + 4007)];
387 #endif
388 #endif
389
390 #ifdef INCREASEFONTS
391   #define xeq_level (zzzad - (int_base + eqtb_extra))
392 #else
393   #define xeq_level (zzzad - (int_base))
394 #endif
395 /* zzzad[844]; */
396 EXTERN quarterword zzzad[844]; /* ??? attempt to fix 99/Jan/5 */
397 /* region 5 & 6 int_base to eqtb_size: 13507 - 12663 */
398
399 #ifdef ALLOCATEHASH
400 #ifdef SHORTHASH
401 EXTERN htwo_halves *zzzae;
402 #else
403 EXTERN two_halves *zzzae;
404 #endif
405 #define hash (zzzae - 514)
406 #else /* not allocating hash table */
407 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
408 #ifdef SHORTHASH
409 EXTERN htwo_halves 
410 #else
411 EXTERN two_halves 
412 #endif
413 #define hash (zzzae - 514)
414
415 #ifdef INCREASEFONTS
416   zzzae[hash_size + 267 + eqtb_extra];
417 #else
418   zzzae[hash_size + 267];
419 #endif
420 #endif
421
422 EXTERN halfword hash_used;
423 EXTERN bool no_new_control_sequence;
424 EXTERN integer cs_count;
425
426 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
427 /* using allocated save stack slows it down 1% to 2%                       */
428 /* despite reallocation, we still limit it to something finite             */
429 /* to avoid soaking up all of machine memory in case of infinite loop      */
430 #ifdef ALLOCATESAVESTACK
431   #define save_size           65536 /* arbitrary - ridiculously large */
432   #define initial_save_size   1000
433   #define increment_save_size 2000
434   EXTERN memory_word *save_stack;
435 #else
436   #define save_size 8000        /* 1999/Jan/6 enough for even CRC */
437 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
438   EXTERN memory_word save_stack[save_size + 1];
439 #endif
440
441 EXTERN integer save_ptr;
442 EXTERN integer max_save_stack;
443
444 /* The following could really be char instead of quarterword ... */
445 /* EXTERN quarterword cur_level;  */
446 /* EXTERN integer cur_level; */ /* padded out */
447 EXTERN int cur_level; /* padded out */    /* 95/Jan/7 */
448
449 /* EXTERN group_code cur_group;  */
450 /* EXTERN integer cur_group;  */ /* padded out */
451 EXTERN int cur_group; /* padded out */      /* 95/Jan/7 */
452
453 EXTERN integer cur_boundary;
454 EXTERN integer mag_set;
455
456 /* EXTERN eight_bits cur_cmd;  */
457 /* EXTERN integer cur_cmd;  */ /* padded out */
458 EXTERN int cur_cmd; /* padded out */      /* 95/Jan/7 */
459
460 /* EXTERN halfword cur_chr;  */
461 EXTERN int cur_chr;
462
463 EXTERN halfword cur_cs;
464 EXTERN halfword cur_tok;
465
466 #ifdef ALLOCATENESTSTACK
467   #define nest_size           65536 /* arbitrary - ridiculously large */
468   #define initial_nest_size   100
469   #define increment_nest_size 200
470   EXTERN list_state_record * nest;
471 #else
472   #define nest_size 200       /* 1999/Jan/7 */
473   EXTERN list_state_record nest[nest_size + 1];
474 #endif
475 EXTERN integer nest_ptr;
476 EXTERN integer max_nest_stack;
477 EXTERN list_state_record cur_list;
478
479 #ifdef ALLOCATEPARAMSTACK
480   #define param_size 65536        /* arbitrary - ridiculously large */
481   #define initial_param_size 100
482   #define increment_param_size 200
483   EXTERN halfword * param_stack;
484 #else
485   #define param_size 500        /* 1997/Jan/17 */
486 EXTERN halfword param_stack[param_size + 1];
487 #endif
488 EXTERN integer param_ptr;
489 EXTERN integer max_param_stack;
490
491 #ifdef ALLOCATEINPUTSTACK
492   #define stack_size           65536          /* arbitrary - ridiculously large */
493   #define initial_stack_size   100
494   #define increment_stack_size 200
495   EXTERN in_state_record * input_stack;
496 #else
497   #define stack_size 800
498   EXTERN in_state_record input_stack[stack_size + 1];
499 #endif
500 EXTERN integer input_ptr;
501 EXTERN integer max_in_stack;
502 EXTERN integer high_in_open;      /* 1997/Jan/17 */
503 EXTERN in_state_record cur_input;
504
505 /* EXTERN integer in_open;  */
506 EXTERN int in_open;
507 EXTERN integer open_parens;
508 EXTERN integer max_open_parens;
509 EXTERN alpha_file input_file[max_in_open + 1];
510 EXTERN integer line;
511 EXTERN integer line_stack[max_in_open + 1];
512
513 /* EXTERN char scanner_status;  */
514 /* EXTERN integer scanner_status;  */ /* padded out */
515 EXTERN int scanner_status; /* padded out */ /* 95/Jan/7 */
516
517 EXTERN halfword warning_index;
518 EXTERN halfword def_ref;
519
520 EXTERN integer align_state;
521 EXTERN integer base_ptr;
522 EXTERN halfword par_loc;
523 EXTERN halfword par_token;
524 EXTERN bool force_eof;
525 /* EXTERN halfword cur_mark[5];  */
526 EXTERN halfword cur_mark[6];
527
528 /* EXTERN char long_state; */
529 /* EXTERN integer long_state; */ /* padded out */
530 EXTERN int long_state; /* padded out */ /* 95/Jan/7 */
531
532 /* EXTERN halfword pstack[9];  */
533 EXTERN halfword pstack[10];
534
535 /* EXTERN integer cur_val; */
536 EXTERN int cur_val;           /* 95/Jan/7 */
537
538 /* EXTERN char cur_val_level;  */
539 /* EXTERN integer cur_val_level; */ /* padded out */
540 EXTERN int cur_val_level; /* padded out */ /* 95/Jan/7 */
541
542 /* EXTERN small_number radix;  */
543 /* EXTERN integer radix;  */ /* padded out */
544 EXTERN int radix; /* padded out */    /* 95/Jan/7 */
545
546 /* EXTERN glue_ord cur_order;  */
547 /* EXTERN integer cur_order;  */ /* padded out */
548 EXTERN int cur_order; /* padded out */    /* 95/Jan/7 */
549
550 EXTERN alpha_file read_file[16];  /* hard wired limit in TeX */
551 /* EXTERN char read_open[17];  */
552 EXTERN char read_open[20]; /* padded out */
553
554 EXTERN halfword cond_ptr;
555
556 /* EXTERN char if_limit; */
557 /* EXTERN integer if_limit; */ /* padded out */
558 EXTERN int if_limit; /* padded out */   /* 95/Jan/7 */
559
560 /* EXTERN small_number cur_if; */
561 /* EXTERN integer cur_if; */ /* padded out */
562 EXTERN int cur_if; /* padded out */   /* 95/Jan/7 */
563
564 EXTERN integer if_line;
565 EXTERN integer skip_line;
566 EXTERN str_number cur_name;
567 EXTERN str_number cur_area;
568 EXTERN str_number cur_ext;
569 EXTERN pool_pointer area_delimiter;
570 EXTERN pool_pointer ext_delimiter;
571 EXTERN integer format_default_length;
572 EXTERN char * TEX_format_default;
573 EXTERN bool name_in_progress;
574 EXTERN bool log_opened;
575 EXTERN bool quoted_file_name;
576 EXTERN str_number job_name;
577 EXTERN str_number output_file_name;
578 EXTERN str_number texmf_log_name;
579 EXTERN byte_file dvi_file;
580 EXTERN byte_file tfm_file;
581 EXTERN byte_file pdf_file;
582 EXTERN char * dvi_file_name;
583 EXTERN char * pdf_file_name;
584 EXTERN char * log_file_name;
585
586 /* SHORTFONTINFO halves the memory word used to store font info */
587 /* if it is not defined we use ordinary TeX memory words */
588
589 #ifdef SHORTFONTINFO
590 #else
591   /* go back to original definition as TeX memory word */
592   #undef fmemoryword
593   #define fmemoryword memory_word
594   /* go back to original definition as four_quarters of a TeX word */
595   #undef ffour_quarters
596   #define ffour_quarters four_quarters
597   /* go back to original definition as quaterword */
598   #undef fquarterword
599   #define fquarterword quarterword
600 #endif
601
602 #ifdef ALLOCATEFONT
603   EXTERN fmemoryword * font_info;
604 #else
605   EXTERN fmemoryword font_info[font_mem_size + 1];
606 #endif
607
608 EXTERN font_index fmem_ptr;
609 EXTERN internal_font_number font_ptr;
610 EXTERN internal_font_number frozen_font_ptr;
611 /* There are about 24 integer size items per font, or about 100 bytes */
612 EXTERN ffour_quarters font_check[font_max + 1];
613 EXTERN scaled font_size[font_max + 1];
614 EXTERN scaled font_dsize[font_max + 1];
615 EXTERN font_index font_params[font_max + 1];
616 EXTERN str_number font_name[font_max + 1];
617 EXTERN str_number font_area[font_max + 1];
618 EXTERN eight_bits font_bc[font_max + 1];
619 EXTERN eight_bits font_ec[font_max + 1];
620 EXTERN halfword font_glue[font_max + 1];
621 /* use char instead of bool to save space, but is it worth slow down ? */
622 EXTERN bool font_used[font_max + 1];
623
624 /* might want to make some of following only one character wide also ? */
625 /* except some use -1 as special case value */
626 /* well, at least make them short instead of integer */
627 EXTERN integer hyphen_char[font_max + 1];
628 EXTERN integer skew_char[font_max + 1];
629 EXTERN font_index bchar_label[font_max + 1];
630 EXTERN short font_bchar[font_max + 1];
631 /* don't change above to int or format file will be incompatible */
632 EXTERN short font_false_bchar[font_max + 1];
633 /* don't change above to int or format file will be incompatible */
634 EXTERN integer char_base[font_max + 1];
635 EXTERN integer width_base[font_max + 1];
636 EXTERN integer height_base[font_max + 1];
637 EXTERN integer depth_base[font_max + 1];
638 EXTERN integer italic_base[font_max + 1];
639 EXTERN integer lig_kern_base[font_max + 1];
640 EXTERN integer kern_base[font_max + 1];
641 EXTERN integer exten_base[font_max + 1];
642 EXTERN integer param_base[font_max + 1];
643
644 EXTERN ffour_quarters null_character;
645
646 EXTERN integer total_pages;
647 EXTERN scaled max_v;
648 EXTERN scaled max_h;
649 EXTERN integer max_push;
650 EXTERN integer last_bop;
651 EXTERN integer dead_cycles;
652 EXTERN bool doing_leaders;
653
654 /* EXTERN quarterword c, f;  */
655 /* EXTERN integer c, f */;
656 EXTERN int c, f;
657
658 EXTERN scaled rule_ht, rule_dp, rule_wd;
659 EXTERN halfword g;
660 EXTERN integer lq, lr;
661
662 EXTERN eight_bits dvi_buf[dvi_buf_size + 4];
663 EXTERN dvi_index half_buf;
664 EXTERN dvi_index dvi_limit;
665 EXTERN dvi_index dvi_ptr;
666 EXTERN integer dvi_offset;
667 EXTERN integer pdf_offset;
668 EXTERN integer dvi_gone;
669 EXTERN halfword down_ptr, right_ptr;
670 EXTERN scaled dvi_h, dvi_v;
671 EXTERN scaled pdf_h, pdf_v;
672 EXTERN scaled pdf_x, pdf_y;
673 EXTERN scaled pdf_delta_h, pdf_delta_v;
674 EXTERN scaled cur_h, cur_v;
675 EXTERN internal_font_number dvi_f;
676 EXTERN internal_font_number pdf_f;
677 EXTERN integer cur_s; /* sec 616 */
678 EXTERN scaled total_stretch[4], total_shrink[4]; /* padded already */
679 EXTERN integer last_badness;
680 EXTERN halfword adjust_tail;
681 EXTERN integer pack_begin_line;
682 EXTERN two_halves empty_field;
683 EXTERN four_quarters null_delimiter;
684 EXTERN halfword cur_mlist;
685
686 /* EXTERN small_number cur_style; */
687 /* EXTERN integer cur_style; */  /* padded out */ /* tex5.c, tex7.c */
688 EXTERN int cur_style;  /* padded out */     /* 95/Jan/7 */
689
690 /* EXTERN small_number cur_size; */
691 /* EXTERN integer cur_size;  */ /* padded out */
692 EXTERN int cur_size;  /* padded out */        /* 95/Jan/7 */
693
694 EXTERN scaled cur_mu;
695 EXTERN bool mlist_penalties;
696 EXTERN internal_font_number cur_f;
697
698 /* EXTERN quarterword cur_c; */
699 /* EXTERN integer cur_c; */  /* padded out */
700 EXTERN int cur_c;  /* padded out */     /* 95/Jan/7 */
701
702 EXTERN ffour_quarters cur_i;
703 EXTERN integer magic_offset;
704 EXTERN halfword cur_align;
705 EXTERN halfword cur_span;
706 EXTERN halfword cur_loop;
707 EXTERN halfword align_ptr;
708 EXTERN halfword cur_head, cur_tail;
709 EXTERN halfword just_box;
710 EXTERN halfword passive;
711 EXTERN halfword printed_node;
712 EXTERN halfword pass_number;
713 EXTERN scaled active_width[8];
714 EXTERN scaled cur_active_width[8];
715 EXTERN scaled background[8];
716 EXTERN scaled break_width[8];
717 EXTERN bool no_shrink_error_yet;
718 EXTERN halfword cur_p;
719 EXTERN bool second_pass;
720 EXTERN bool final_pass;
721 EXTERN integer threshold;
722 EXTERN integer minimal_demerits[4];
723 EXTERN integer minimum_demerits;
724 EXTERN halfword best_place[4];
725 EXTERN halfword best_pl_line[4];
726 EXTERN scaled disc_width;
727 EXTERN halfword easyline;
728 EXTERN halfword last_special_line;
729 EXTERN scaled first_width;
730 EXTERN scaled second_width;
731 EXTERN scaled first_indent;
732 EXTERN scaled second_indent;
733 EXTERN halfword best_bet;
734 EXTERN integer fewest_demerits;
735 EXTERN halfword best_line;
736 EXTERN integer actual_looseness;
737 EXTERN integer line_diff;
738 /* EXTERN short hc[64+2]; */  /* padded OK 66 * 2 = 132 which is divisible by 4 */
739 EXTERN int hc[66];  /* padded OK 66 * 2 = 132 which is divisible by 4 */
740
741 /* EXTERN small_number hn; */
742 /* EXTERN integer hn; */  /* padded out */
743 EXTERN int hn;  /* padded out */      /* 95/Jan/7 */
744
745 EXTERN halfword ha, hb;
746
747 /* EXTERN internal_font_number hf;  */
748 EXTERN int hf;              /* 95/Jan/7 */
749
750 /* EXTERN short hu[64+2]; */    /* padded OK */
751 EXTERN int hu[66];    /* padded OK */ 
752
753 /* EXTERN integer hyf_char;  */
754 EXTERN int hyf_char;            /* 95/Jan/7 */
755
756 /* init_cur_lang new in 3.14159 */
757 /* EXTERN ASCII_code cur_lang, init_cur_lang; */
758 /* EXTERN integer cur_lang, init_cur_lang; */ /* padded out */
759 EXTERN int cur_lang, init_cur_lang; /* padded out */    /* 95/Jan/7 */
760
761 EXTERN integer lhyf, rhyf;
762 /* EXTERN init_l_hyf, init_r_hyf; */ /* new in 3.14159 */
763 EXTERN integer init_l_hyf, init_r_hyf;  /* new in 3.14159 */
764
765 EXTERN halfword hyfbchar;
766 /* EXTERN char hyf[65];  */
767 EXTERN char hyf[68]; /* padded out */
768 EXTERN halfword init_list;
769 EXTERN bool init_lig;
770 EXTERN bool init_lft;
771
772 /* EXTERN small_number hyphen_passed; */
773 /* EXTERN integer hyphen_passed; */  /* padded out */
774 EXTERN int hyphen_passed;  /* padded out */     /* 95/Jan/7 */
775
776 /* EXTERN halfword cur_l, cur_r; */   /* make int's ? 95/Jan/7 */
777 EXTERN int cur_l, cur_r;    /* make int's ? 95/Jan/7 */
778
779 EXTERN halfword cur_q;
780 EXTERN halfword lig_stack;
781 EXTERN bool ligature_present;
782 EXTERN bool lft_hit, rt_hit;
783
784 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
785 /* could perhaps use packed_ASCII_code for trie_trc ? */
786 #ifdef ALLOCATETRIES
787   EXTERN halfword * trie_trl;
788   EXTERN halfword * trie_tro;
789   EXTERN quarterword * trie_trc;
790 #else
791   /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
792   EXTERN halfword trie_trl[trie_size + 1];
793   EXTERN halfword trie_tro[trie_size + 1];
794   EXTERN quarterword trie_trc[trie_size + 1];
795 #endif
796 EXTERN small_number hyf_distance[trie_op_size + 1]; /* already padded 751 + 1 */
797 EXTERN small_number hyf_num[trie_op_size + 1];    /* already padded 751 + 1 */
798 EXTERN trie_op_code hyf_next[trie_op_size + 1];
799 EXTERN integer op_start[256];
800
801 /* if ALLOCATEHYPHEN is true, then hyphen_prime is a variable */
802 /* otherwise it is a pre-processor defined constant */
803 #ifdef ALLOCATEHYPHEN
804   #define default_hyphen_prime 1009
805   EXTERN str_number * hyph_word;
806   EXTERN halfword * hyph_list;
807   /* EXTERN hyphen_prime; */
808   EXTERN integer hyphen_prime;
809 #else
810   #define hyphen_prime 607
811   /* EXTERN str_number hyph_word[608];  */
812   EXTERN str_number hyph_word[hyphen_prime + 1];
813   /* EXTERN halfword hyph_list[608];  */
814   EXTERN halfword hyph_list[hyphen_prime + 1];
815 #endif
816
817 /* EXTERN hyph_pointer hyph_count;  */
818 /* EXTERN integer hyph_count; */  /* padded out */
819 EXTERN int hyph_count;  /* padded out */    /* 95/Jan/7 */
820
821 #ifdef INITEX
822 EXTERN integer trie_op_hash_C[trie_op_size - neg_trie_op_size + 1];
823 #define trie_op_hash (trie_op_hash_C - (int)(neg_trie_op_size)) 
824 EXTERN trie_op_code trie_used[256];
825 EXTERN ASCII_code trie_op_lang[trie_op_size + 1];   /* already padded 751 + 1 */
826 EXTERN trie_op_code trie_op_val[trie_op_size + 1];
827 EXTERN integer trie_op_ptr;
828 #endif /* INITEX */
829
830 EXTERN trie_op_code max_op_used;
831 EXTERN bool smallop;
832
833 #ifdef INITEX
834   #ifdef ALLOCATEINI
835     EXTERN packed_ASCII_code *trie_c; /* characters to match */
836     EXTERN trie_op_code *trie_o;      /* operations to perform */
837     EXTERN trie_pointer *trie_l;      /* left subtrie links */
838     EXTERN trie_pointer *trie_r;      /* right subtrie links */
839     EXTERN trie_pointer *trie_hash;   /* used to identify equivlent subtries */
840   #else /* end ALLOCATEINI */
841     EXTERN packed_ASCII_code trie_c[trie_size + 1];
842     EXTERN trie_op_code trie_o[trie_size + 1];
843     EXTERN trie_pointer trie_l[trie_size + 1];
844     EXTERN trie_pointer trie_r[trie_size + 1];
845     EXTERN trie_pointer trie_hash[trie_size + 1];
846   #endif /* end not ALLOCATEINI */
847   EXTERN trie_pointer trie_ptr;
848 #endif /* INITEX */
849
850 #ifdef INITEX
851   #ifdef ALLOCATEINI
852     /* EXTERN bool *trie_taken; */ /* save (4 - 1) * trie_size = 90,000 byte */
853     EXTERN char *trie_taken;
854   #else
855     EXTERN bool trie_taken[trie_size + 1];
856   #endif
857
858   EXTERN trie_pointer trie_min[256];
859   EXTERN trie_pointer trie_max;
860   EXTERN bool trie_not_ready;
861 #endif /* INITEX */
862 EXTERN scaled best_height_plus_depth;
863 EXTERN halfword page_tail;
864
865 /* EXTERN char page_contents; */
866 /* EXTERN integer page_contents; */ /* padded out */
867 EXTERN int page_contents; /* padded out */      /* 95/Jan/7 */
868
869 /* ********************************************************************* */
870
871 /* do *some* sanity checking here --- rather than in TeX later 96/Jan/18 */
872 /* (cannot catch everything here, since some is now dynamic) */
873
874 #if (half_error_line < 30) || (half_error_line > error_line - 15)
875   #error ERROR: (half_error_line < 30) || (half_error_line > error_line - 15) BAD 1
876 #endif
877
878 #if (max_print_line < 60)
879   #error ERROR: (max_print_line < 60) BAD 2
880 #endif
881
882 #if (hash_prime > hash_size)
883   #error ERROR: (hash_prime > hash_size) BAD 5
884 #endif
885
886 #if (max_in_open > 127)
887   #error ERROR: (max_in_open > 127) BAD 6
888 #endif
889
890 #if (min_quarterword > 0) || (max_quarterword < 127)
891   #error ERROR: (min_quarterword > 0) || (max_quarterword < 127) BAD 11
892 #endif
893
894 #if (min_halfword > 0) || (max_halfword < 32767)
895   #error ERROR:  (min_halfword > 0) || (max_halfword < 32767) BAD 12
896 #endif
897
898 #if (min_quarterword < min_halfword) || (max_quarterword > max_halfword)
899   #error ERROR: (min_quarterword < min_halfword) || (max_quarterword > max_halfword) BAD 13
900 #endif
901
902 #if (font_max > max_quarterword)
903   #error ERROR: (font_max > max_quarterword) BAD 15
904 #endif
905
906 #if (save_size > max_halfword)
907   #error ERROR: (save_size > max_halfword) BAD 17
908 #endif
909
910 #if (buf_size > max_halfword)
911   #error ERROR:  (buf_size > max_halfword) BAD 18
912 #endif
913
914 #if (max_quarterword - min_quarterword) < 255
915   #error (max_quarterword - min_quarterword) < 255 BAD 19
916 #endif
917
918 /* ********************************************************************* */
919
920 EXTERN scaled page_max_depth;
921 EXTERN halfword best_page_break;
922 EXTERN integer least_page_cost;
923 EXTERN scaled best_size;
924 EXTERN scaled page_so_far[8];
925 EXTERN halfword last_glue;
926 EXTERN integer last_penalty;
927 EXTERN scaled last_kern;
928 EXTERN integer insert_penalties;
929 EXTERN bool output_active;
930 EXTERN internal_font_number main_f;
931
932 EXTERN ffour_quarters main_i;
933 EXTERN ffour_quarters main_j;
934
935 EXTERN font_index main_k;
936 EXTERN halfword main_p;
937 EXTERN integer main_s;
938 EXTERN halfword bchar;
939 EXTERN halfword false_bchar;
940 EXTERN bool cancel_boundary;
941 EXTERN bool ins_disc;
942 EXTERN halfword cur_box;
943 EXTERN halfword after_token;
944 EXTERN bool long_help_seen;
945 EXTERN str_number format_ident;
946 EXTERN word_file fmt_file;
947 EXTERN gzFile gz_fmt_file;
948 EXTERN integer ready_already;
949
950 EXTERN alpha_file write_file[16]; /* hard wired limit in TeX */
951 EXTERN bool write_open[18];
952
953 EXTERN halfword write_loc;
954 EXTERN pool_pointer edit_name_start;
955 /* EXTERN integer edit_name_length, edit_line, tfm_temp;  */
956 EXTERN integer edit_name_length, edit_line;
957 EXTERN int tfm_temp;
958
959 /* new stuff defined in local.c - bkph */
960 EXTERN bool is_initex;
961 EXTERN bool verbose_flag;
962 EXTERN bool trace_flag;
963 EXTERN bool debug_flag;
964 EXTERN bool open_trace_flag;
965 EXTERN bool knuth_flag;
966 EXTERN bool no_interrupts;
967 EXTERN bool c_style_flag;
968 EXTERN bool non_ascii;
969 EXTERN bool key_replace;
970 EXTERN bool deslash;
971 EXTERN bool trimeof;
972 EXTERN bool allow_patterns;
973 EXTERN bool show_fonts_used;
974 EXTERN bool reset_exceptions;
975 EXTERN bool show_current;
976 EXTERN bool current_flag;
977 EXTERN bool current_tfm;
978 EXTERN bool return_flag;
979 EXTERN bool want_version;
980 EXTERN bool civilize_flag;
981 EXTERN bool show_numeric;
982 EXTERN bool restrict_to_ascii;
983 EXTERN bool show_missing;
984 EXTERN bool full_file_name_flag;
985 EXTERN bool save_strings_flag;
986 EXTERN int mem_initex;
987 EXTERN int mem_extra_high;
988 EXTERN int mem_extra_low;
989 EXTERN int new_hyphen_prime;
990 EXTERN int missing_characters;
991 EXTERN int show_in_hex;
992 EXTERN int show_in_dos;
993 EXTERN int show_fmt_flag;
994 EXTERN int show_tfm_flag;
995 EXTERN bool show_texinput_flag;  /* 1998/Jan/28 */
996 EXTERN bool truncate_long_lines; /* 1998/Feb/2 */
997 EXTERN bool show_cs_names;       /* 1998/Mar/31 */
998 EXTERN int tab_step;
999 EXTERN int pseudo_tilde;
1000 EXTERN int pseudo_space;
1001 EXTERN int allow_quoted_names;
1002 EXTERN int default_rule;
1003 EXTERN char * format_file;
1004 EXTERN char * source_direct;
1005 EXTERN char * format_name;
1006 EXTERN char * encoding_name;
1007 EXTERN bool format_specific;
1008 EXTERN bool encoding_specific;
1009 EXTERN bool show_line_break_stats;
1010 EXTERN int first_pass_count;
1011 EXTERN int second_pass_count;
1012 EXTERN int final_pass_count;
1013 EXTERN int underfull_hbox;
1014 EXTERN int overfull_hbox;
1015 EXTERN int underfull_vbox;
1016 EXTERN int overfull_vbox;
1017 EXTERN int paragraph_failed;
1018 EXTERN int single_line;
1019 EXTERN FILE * errout;
1020 EXTERN int font_dimen_zero;
1021 EXTERN int ignore_frozen;
1022 EXTERN bool suppress_f_ligs;
1023 EXTERN int abort_flag;
1024 EXTERN int err_level;
1025 EXTERN int jump_used;
1026 EXTERN jmp_buf jumpbuffer;
1027 extern int current_pool_size;
1028 extern int current_max_strings;
1029 extern int current_mem_size;
1030 extern int current_font_mem_size;
1031 extern int current_save_size;
1032 extern int current_stack_size;
1033 extern int current_nest_size;
1034 extern int current_param_size;
1035 extern int current_buf_size;
1036 extern char *tex_version;
1037 extern char *application;
1038 extern char *yandyversion;
1039 extern unsigned char wintodos[128];
1040 extern char log_line[MAXLINE];
1041 extern char *texpath;
1042
1043 memory_word * allocate_main_memory (int);
1044 memory_word * realloc_main (int, int);
1045 packed_ASCII_code * realloc_str_pool (int);
1046 pool_pointer * realloc_str_start (int);
1047 memory_word * realloc_save_stack (int);
1048 list_state_record * realloc_nest_stack (int);
1049 in_state_record * realloc_input_stack (int);
1050 halfword * realloc_param_stack (int);
1051 ASCII_code * realloc_buffer (int);
1052 fmemoryword * realloc_font_info (int);
1053
1054 int realloc_hyphen (int);
1055 int allocate_tries (int);
1056 void check_eqtb (char *);
1057 void probe_memory (void);
1058 void print_cs_names (FILE *, int);
1059 void perrormod(char *);
1060 char *grabenv(char *);
1061 void stamp_it (char *);
1062 void stampcopy (char *);
1063 bool prime (int);
1064 int endit (int);
1065
1066 void uexit (int unix_code);
1067 void t_open_in (void);
1068
1069
1070 void call_edit (ASCII_code *filename, pool_pointer fnstart,
1071                 integer fnlength, integer linenumber);
1072
1073 void add_variable_space(int);
1074
1075 void get_date_and_time (integer *minutes, integer *day,
1076                         integer *month, integer *year);
1077
1078 char *unixify (char *);
1079
1080 /****************************************************************************/
1081 #include "coerce.h"
1082 #include "yandy_macros.h"
1083 /****************************************************************************/
1084 /* sec 79 */
1085 extern void synch_h(void);
1086 extern void synch_v(void);
1087 extern void set_cur_lang(void);
1088 extern str_number make_string_pool (char *s);
1089 extern char * md5_file(FILE * in_file);
1090 extern INLINE void str_room_ (int val);
1091 #define str_room(a) str_room_((int) a)
1092 extern INLINE void tail_append_ (pointer val);
1093 #define tail_append(a) tail_append_((pointer) a)
1094 extern INLINE void tex_help (unsigned int n, ...);
1095 extern INLINE void append_char(ASCII_code c);
1096 extern INLINE void append_lc_hex(ASCII_code c);
1097 extern INLINE void succumb(void);
1098 extern INLINE void dvi_out_ (ASCII_code op);
1099 #define dvi_out(op) dvi_out_((ASCII_code) (op))
1100 extern INLINE void free_avail_(halfword p);
1101 #define free_avail(p) free_avail_((halfword) (p))
1102 extern INLINE void flush_string (void);
1103 extern int load_pool_strings (integer spare_size);
1104 #define help0()     tex_help(0)
1105 #define help1(...)  tex_help(1, __VA_ARGS__)
1106 #define help2(...)  tex_help(2, __VA_ARGS__)
1107 #define help3(...)  tex_help(3, __VA_ARGS__)
1108 #define help4(...)  tex_help(4, __VA_ARGS__)
1109 #define help5(...)  tex_help(5, __VA_ARGS__)
1110 #define help6(...)  tex_help(6, __VA_ARGS__)
1111
1112 /********BINDING WITH LIBHARU*********/
1113 typedef struct _mapping_table mapping_table;
1114 typedef struct _mapping_entry mapping_entry;
1115 EXTERN HPDF_Doc  yandy_pdf;
1116 EXTERN HPDF_Page yandy_page;
1117 EXTERN HPDF_Font yandy_font[1024];
1118 EXTERN bool pdf_doing_string;
1119 EXTERN bool pdf_doing_text;
1120 EXTERN integer scaled_out;
1121 EXTERN bool pdf_output_flag;
1122 EXTERN mapping_table * gentbl;
1123 EXTERN mapping_table * font_name_hash_init (void);
1124 EXTERN void font_name_hash_free (mapping_table * tbl);
1125 EXTERN void pdf_ship_out(pointer p);
1126 EXTERN void pdf_vlist_out (void);
1127 EXTERN void pdf_hlist_out (void);
1128 EXTERN void pdf_begin_text(void);
1129 EXTERN void pdf_font_def(internal_font_number f);
1130 EXTERN void pdf_error_handler (HPDF_STATUS error_no, HPDF_STATUS detail_no, void * user_data);
1131 /********BINDING WITH LIBHARU*********/