OSDN Git Service

3f1a49e3e5a686af70536e981b54cd90d7cb7277
[putex/putex.git] / src / texsourc / itex.c
1 /* Copyright 1992 Karl Berry
2    Copyright 2007 TeX Users Group
3    Copyright 2014 Clerk Ma
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18    02110-1301 USA.  */
19
20 #define EXTERN extern
21
22 #include "texd.h"
23
24 #define BEGINFMTCHECKSUM 367403084L
25 #define ENDFMTCHECKSUM   69069L
26
27 extern clock_t start_time, main_time, finish_time;
28
29 #ifdef INITEX
30   void do_initex (void);
31 #endif
32
33 /* sec 0004 */
34 void initialize (void)
35 {
36   integer i; 
37   integer k; 
38   integer flag; /* bkph */
39
40 #ifndef ALLOCATEHYPHEN
41   hyph_pointer z;
42 #endif
43
44   if (!non_ascii)
45   {
46     for (i = 0; i <= 255; i++)
47       xchr[i] = (char) i;
48
49 #ifdef JOKE
50     xchr[32] = ' ';  xchr[33] = '!';  xchr[34] = '"';  xchr[35] = '#';
51     xchr[36] = '$';  xchr[37] = '%';  xchr[38] = '&';  xchr[39] = '\'';
52     xchr[40] = '(';  xchr[41] = ')';  xchr[42] = '*';  xchr[43] = '+';
53     xchr[44] = ',';  xchr[45] = '-';  xchr[46] = '.';  xchr[47] = '/';
54     xchr[48] = '0';  xchr[49] = '1';  xchr[50] = '2';  xchr[51] = '3';
55     xchr[52] = '4';  xchr[53] = '5';  xchr[54] = '6';  xchr[55] = '7';
56     xchr[56] = '8';  xchr[57] = '9';  xchr[58] = ':';  xchr[59] = ';';
57     xchr[60] = '<';  xchr[61] = '=';  xchr[62] = '>';  xchr[63] = '?';
58     xchr[64] = '@';  xchr[65] = 'A';  xchr[66] = 'B';  xchr[67] = 'C';
59     xchr[68] = 'D';  xchr[69] = 'E';  xchr[70] = 'F';  xchr[71] = 'G';
60     xchr[72] = 'H';  xchr[73] = 'I';  xchr[74] = 'J';  xchr[75] = 'K';
61     xchr[76] = 'L';  xchr[77] = 'M';  xchr[78] = 'N';  xchr[79] = 'O';
62     xchr[80] = 'P';  xchr[81] = 'Q';  xchr[82] = 'R';  xchr[83] = 'S';
63     xchr[84] = 'T';  xchr[85] = 'U';  xchr[86] = 'V';  xchr[87] = 'W';
64     xchr[88] = 'X';  xchr[89] = 'Y';  xchr[90] = 'Z';  xchr[91] = '[';
65     xchr[92] = '\\'; xchr[93] = ']';  xchr[94] = '^';  xchr[95] = '_';
66     xchr[96] = '`';  xchr[97] = 'a';  xchr[98] = 'b';  xchr[99] = 'c';
67     xchr[100] = 'd'; xchr[101] = 'e'; xchr[102] = 'f'; xchr[103] = 'g';
68     xchr[104] = 'h'; xchr[105] = 'i'; xchr[106] = 'j'; xchr[107] = 'k';
69     xchr[108] = 'l'; xchr[109] = 'm'; xchr[110] = 'n'; xchr[111] = 'o';
70     xchr[112] = 'p'; xchr[113] = 'q'; xchr[114] = 'r'; xchr[115] = 's';
71     xchr[116] = 't'; xchr[117] = 'u'; xchr[118] = 'v'; xchr[119] = 'w';
72     xchr[120] = 'x'; xchr[121] = 'y'; xchr[122] = 'z'; xchr[123] = '{';
73     xchr[124] = '|'; xchr[125] = '}'; xchr[126] = '~';
74
75     for (i = 0; i <= 31; i++)
76       xchr[i] = chr(i);
77
78     for (i = 127; i <= 255; i++)
79       xchr[i]= chr(i);
80 #endif
81   }
82
83   for (i = 0; i <= 255; i++)
84     xord[chr(i)] = 127;
85
86 #ifdef JOKE
87   for (i = 128; i <= 255 ; i++)
88     xord[xchr[i]] = i;
89
90   for (i = 0; i <= 126; i++)
91     xord[xchr[i]] = i;
92 #endif
93
94   for (i = 0; i <= 255; i++)
95     xord[xchr[i]] = (char) i;
96
97   xord[127] = 127;
98
99   flag = 0;
100
101   if (trace_flag != 0)
102   {
103     for (k = 0; k < 256; k++)
104       if (xord[k] != k)
105       {
106         flag = 1;
107         break;
108       }
109
110     if (flag)
111     {
112       puts("Inverted mapping xord[] pairs:\n");
113
114       for (k = 0; k < 256; k++)
115       {
116         if (xord[k] != 127)
117           printf("%d => %d\n", k, xord[k]);
118       }
119     }
120   }
121
122   if (interaction < batch_mode)
123     interaction = error_stop_mode;
124
125   deletions_allowed = true;
126   set_box_allowed = true;
127   error_count = 0;
128   help_ptr = 0;
129   use_err_help = false;
130   interrupt = 0;
131   OK_to_interrupt = true;
132
133 #ifdef DEBUG
134   was_mem_end = mem_min;
135   was_lo_max = mem_bot; // mem_min
136   was_hi_min = mem_top; // mem_max
137   panicking = false;
138 #endif
139
140   nest_ptr = 0;
141   max_nest_stack = 0;
142   mode = 1;
143   head = contrib_head;
144   tail = contrib_head;
145   cur_list.aux_field.cint = ignore_depth;
146   mode_line = 0;
147   prev_graf = 0;
148   shown_mode = 0;
149   page_contents = 0;
150   page_tail = page_head;
151
152 #ifdef ALLOCATEMAIN
153   if (is_initex)
154 #endif
155     link(page_head) = 0;
156
157   last_glue = empty_flag;
158   last_penalty = 0;
159   last_kern = 0;
160   page_so_far[7] = 0;
161   page_max_depth = 0;
162
163   for (k = int_base; k <= eqtb_size; k++)
164     xeq_level[k] = level_one;
165
166   no_new_control_sequence = true;
167   next(hash_base) = 0;
168   text(hash_base) = 0;
169
170   for (k = hash_base + 1; k <= undefined_control_sequence - 1; k++)
171     hash[k] = hash[hash_base];
172
173   save_ptr = 0;
174   cur_level = 1;
175   cur_group = 0;
176   cur_boundary = 0;
177   max_save_stack = 0;
178   mag_set = 0;
179   cur_mark[0] = 0;
180   cur_mark[1] = 0;
181   cur_mark[2] = 0;
182   cur_mark[3] = 0;
183   cur_mark[4] = 0;
184   cur_val = 0;
185   cur_val_level = 0;
186   radix = 0;
187   cur_order = 0;
188
189   for (k = 0; k <= 16; k++)
190     read_open[k] = 2;
191
192   cond_ptr = 0;
193   if_limit = 0;
194   cur_if = 0;
195   if_line = 0;
196
197   for (k = 0; k <= font_max; k++)
198     font_used[k] = false;
199
200   null_character.b0 = 0;
201   null_character.b1 = 0;
202   null_character.b2 = 0;
203   null_character.b3 = 0;
204   total_pages = 0;
205   max_v = 0;
206   max_h = 0;
207   max_push = 0;
208   last_bop = -1;
209   doing_leaders = false;
210   dead_cycles = 0;
211   cur_s = -1;
212   half_buf = dvi_buf_size / 2;
213   dvi_limit = dvi_buf_size;
214   dvi_ptr = 0;
215   dvi_offset = 0;
216   dvi_gone = 0;
217   down_ptr = 0;
218   right_ptr = 0;
219   adjust_tail = 0;
220   last_badness = 0;
221   pack_begin_line = 0;
222   empty_field.rh = 0;
223   empty_field.lh = 0;
224   null_delimiter.b0 = 0;
225   null_delimiter.b1 = 0;
226   null_delimiter.b2 = 0;
227   null_delimiter.b3 = 0;
228   align_ptr = 0;
229   cur_align = 0;
230   cur_span = 0;
231   cur_loop = 0;
232   cur_head = 0;
233   cur_tail = 0;
234
235 /*  *not* OK with ALLOCATEHYPHEN, since may not be allocated yet */
236 #ifndef ALLOCATEHYPHEN
237   for (z = 0; z <= hyphen_prime; z++)
238   {
239     hyph_word[z] = 0;
240     hyph_list[z] = 0;
241   }
242 #endif
243
244   hyph_count = 0;
245   output_active = false;
246   insert_penalties = 0;
247   ligature_present = false;
248   cancel_boundary = false;
249   lft_hit = false;
250   rt_hit = false;
251   ins_disc = false;
252   after_token = 0;
253   long_help_seen = false;
254   format_ident = 0;
255
256   for (k = 0; k <= 17; k++)
257     write_open[k] = false;
258
259   edit_name_start = 0;
260
261 #ifdef INITEX
262   if (is_initex)
263   {
264     do_initex();
265   }
266 #endif
267 }
268
269 /* do the part of initialize() that requires mem_top, mem_max or mem[] */
270 /* do this part after allocating main memory */
271
272 #ifdef ALLOCATEMAIN
273 void initialize_aux (void)
274 {
275 #ifdef DEBUG
276   was_mem_end = mem_min;
277   was_lo_max = mem_bot; // mem_min
278   was_hi_min = mem_top; // mem_max
279   panicking = false;
280 #endif
281
282 /*  nest_ptr = 0; */
283 /*  max_nest_stack = 0; */
284   mode = 1;
285   head = contrib_head;
286   tail = contrib_head;
287   prev_depth = ignore_depth;
288   mode_line = 0;
289   prev_graf = 0;
290 /*  shown_mode = 0; */
291 /*  page_contents = 0; */
292   page_tail = page_head;
293   link(page_head) = 0;
294 }
295 #endif  // end of ifdef ALLOCATEMAIN
296 /* sec 0815 */
297 void line_break_ (integer final_widow_penalty)
298 {
299   boolean auto_breaking;
300   halfword prevp;
301   halfword q, r, s, prevs;
302   internal_font_number f;
303 /*  small_number j;  */
304   int j;                /* 95/Jan/7 */
305 /*  unsigned char c;  */
306   unsigned int c;           /* 95/Jan/7 */
307
308   pack_begin_line = mode_line;
309   link(temp_head) = link(head);
310
311   if (is_char_node(tail))
312     tail_append(new_penalty(inf_penalty));
313   else if (type(tail) != glue_node)
314     tail_append(new_penalty(inf_penalty));
315   else
316   {
317     type(tail) = penalty_node;
318     delete_glue_ref(glue_ptr(tail));
319     flush_node_list(leader_ptr(tail));
320     penalty(tail) = inf_penalty;
321   }
322
323   link(tail) = new_param_glue(par_fill_skip_code);
324   init_cur_lang = prev_graf % 65536L;
325   init_l_hyf = prev_graf / 4194304L; /* 2^22 */
326   init_r_hyf = (prev_graf / 65536L) % 64;
327   pop_nest();
328   no_shrink_error_yet = true;
329
330   if ((shrink_order(left_skip) != normal) && (shrink(left_skip) != 0))
331     left_skip = finite_shrink(left_skip);
332
333   if ((shrink_order(right_skip) != normal) && (shrink(right_skip) != 0))
334     right_skip = finite_shrink(right_skip);
335
336   q = left_skip;
337   r = right_skip;
338   background[1] = width(q) + width(r);
339   background[2] = 0;
340   background[3] = 0;
341   background[4] = 0;
342   background[5] = 0;
343   background[2 + stretch_order(q)] = stretch(q);
344   background[2 + stretch_order(r)] = background[2 + stretch_order(r)] + stretch(r);
345   background[6] = shrink(q) + shrink(r);
346   minimum_demerits = 1073741823L; /* 2^30 - 1 *//* 40000000 hex - 1 */
347   minimal_demerits[tight_fit] = 1073741823L;
348   minimal_demerits[decent_fit] = 1073741823L;
349   minimal_demerits[loose_fit] = 1073741823L;
350   minimal_demerits[very_loose_fit] = 1073741823L;
351
352   if (par_shape_ptr == 0)
353     if (hang_indent == 0)
354     {
355       last_special_line = 0;
356       second_width = hsize;
357       second_indent = 0;
358     }
359     else
360     {
361       last_special_line = abs(hang_after);
362
363       if (hang_after < 0)
364       {
365         first_width = hsize - abs(hang_indent);
366
367         if (hang_indent >= 0)
368           first_indent = hang_indent;
369         else
370           first_indent = 0;
371
372         second_width = hsize;
373         second_indent = 0;
374       }
375       else
376       {
377         first_width = hsize;
378         first_indent = 0;
379         second_width = hsize - abs(hang_indent);
380
381         if (hang_indent >= 0)
382           second_indent = hang_indent;
383         else
384           second_indent = 0;
385       }
386     }
387   else
388   {
389     last_special_line = info(par_shape_ptr) - 1;
390     second_width = mem[par_shape_ptr + 2 * (last_special_line + 1)].cint;
391     second_indent = mem[par_shape_ptr + 2 * last_special_line + 1].cint;
392   }
393
394   if (looseness == 0)
395     easyline = last_special_line;
396   else
397     easyline = empty_flag;
398
399   threshold = pretolerance;
400
401   if (threshold >= 0)
402   {
403 #ifdef STAT
404     if (tracing_paragraphs > 0)
405     {
406       begin_diagnostic();
407       print_nl("@firstpass");
408     }
409 #endif
410
411     second_pass = false;
412     final_pass = false;
413     first_pass_count++; /* 96 Feb 9 */
414   }
415   else
416   {
417     threshold = tolerance;
418     second_pass = true;
419     final_pass = (emergency_stretch <= 0);
420
421 #ifdef STAT
422     if (tracing_paragraphs > 0)
423       begin_diagnostic();
424 #endif
425   }
426
427   while (true)
428   {
429     if (threshold > inf_bad)
430       threshold = inf_bad;
431
432     if (second_pass)
433     {
434 #ifdef INITEX
435       if (is_initex)
436       {
437         if (trie_not_ready)
438           init_trie();
439       }
440 #endif
441
442       cur_lang = init_cur_lang;
443       lhyf = init_l_hyf;
444       rhyf = init_r_hyf;
445     }
446
447     q = get_node(3);
448     type(q) = unhyphenated;
449     fitness(q) = decent_fit;
450     link(q) = active;
451     break_node(q) = 0;
452     line_number(q) = prev_graf + 1;
453     total_demerits(q) = 0;
454     link(active) = q;
455     active_width[1] = background[1];
456     active_width[2] = background[2];
457     active_width[3] = background[3];
458     active_width[4] = background[4];
459     active_width[5] = background[5];
460     active_width[6] = background[6];
461
462     passive = 0;
463     printed_node = temp_head;
464     pass_number = 0;
465     font_in_short_display = 0;
466
467     cur_p = link(temp_head);
468     auto_breaking = true;
469     prevp = cur_p;
470
471     while ((cur_p != 0) && (link(active) != active))
472     {
473       if (is_char_node(cur_p))
474       {
475         prevp = cur_p;
476
477         do
478           {
479             f = font(cur_p);
480             active_width[1] = active_width[1] + char_width(f, char_info(f, character(cur_p)));
481             cur_p = link(cur_p);
482           }
483         while (!(!is_char_node(cur_p)));
484       }
485
486       switch(type(cur_p))
487       {
488         case hlist_node:
489         case vlist_node:
490         case rule_node:
491           active_width[1] = active_width[1] + width(cur_p);
492           break;
493
494         case whatsit_node:
495           if (subtype(cur_p) == language_node)
496           {
497             cur_lang = what_lang(cur_p);
498             lhyf = what_lhm(cur_p);
499             rhyf = what_rhm(cur_p);
500           }
501           break;
502
503         case glue_node:
504           {
505             if (auto_breaking)
506             {
507               if (is_char_node(prevp))
508                 try_break(0, unhyphenated);
509               else if ((mem[prevp].hh.b0 < 9))
510                 try_break(0, unhyphenated);
511               else if ((type(prevp) == kern_node) && (subtype(prevp) != explicit))
512                 try_break(0, unhyphenated);
513             }
514
515             if ((mem[glue_ptr(cur_p)].hh.b1 != 0) && (mem[glue_ptr(cur_p) + 3].cint != 0))
516             {
517               glue_ptr(cur_p) = finite_shrink(glue_ptr(cur_p));
518             }
519
520             q = glue_ptr(cur_p);
521             active_width[1] = active_width[1]+ width(q);
522             active_width[2 + stretch_order(q)] = active_width[2 + stretch_order(q)] + stretch(q);
523             active_width[6] = active_width[6] + shrink(q);
524
525             if (second_pass && auto_breaking)
526             {
527               prevs = cur_p;
528               s = link(prevs);
529
530               if (s != 0)
531               {
532                 while (true)
533                 {
534                   if (is_char_node(s))
535                   {
536                     c = character(s);
537                     hf = font(s);
538                   }
539                   else if (type(s) == ligature_node)
540                     if (lig_ptr(s) == 0)
541                       goto lab22;
542                     else
543                     {
544                       q = lig_ptr(s);
545                       c = character(q);
546                       hf = font(q);
547                     }
548                   else if ((type(s) == kern_node) && (subtype(s) == normal))
549                     goto lab22;
550                   else if (type(s) == whatsit_node)
551                   {
552                     if (subtype(s) == language_node)
553                     {
554                       cur_lang = what_lang(s);
555                       lhyf = what_lhm(s);
556                       rhyf = what_rhm(s);
557                     }
558                     goto lab22;
559                   }
560                   else
561                     goto lab31;
562
563                   if (lc_code(c) != 0)
564                     if ((lc_code(c) == (halfword) c) || (uc_hyph > 0)) /* fixed signed tyoe */
565                       goto lab32;
566                     else
567                       goto lab31;
568 lab22:
569                   prevs = s;
570                   s = link(prevs);
571                 }
572 lab32:
573                 hyf_char = hyphen_char[hf];
574
575                 if (hyf_char < 0)
576                   goto lab31; 
577
578                 if (hyf_char > 255)
579                   goto lab31; /* ? */
580
581                 ha = prevs;
582
583                 if (lhyf + rhyf > 63)
584                   goto lab31;
585
586                 hn = 0;
587
588                 while (true)
589                 {
590                   if (is_char_node(s))
591                   {
592                     if (font(s) != hf)
593                       goto lab33;
594
595                     hyfbchar = character(s);
596
597                     c = hyfbchar;     /*  unsigned char c;  */
598
599                     if (lc_code(c) == 0)
600                       goto lab33;
601
602                     if (hn == 63)
603                       goto lab33;
604
605                     hb = s;
606                     incr(hn);
607                     hu[hn] = c;
608                     hc[hn]= lc_code(c);
609                     hyfbchar = non_char;
610                   }
611                   else if (type(s) == ligature_node)
612                   {
613                     if (font(lig_char(s)) != hf)
614                       goto lab33;
615
616                     j = hn;
617                     q = lig_ptr(s);
618
619                     if (q != 0) /* 94/Mar/23 BUG FIX */
620                       hyfbchar = character(q);
621
622                     while (q != 0) /* 94/Mar/23 BUG FIX */
623                     {
624                       c = character(q);
625
626                       if (lc_code(c) == 0)
627                         goto lab33;
628
629                       if (j == 63)
630                         goto lab33;
631
632                       incr(j);
633                       hu[j] = c;
634                       hc[j] = lc_code(c);
635                       q = link(q);
636                     }
637
638                     hb = s;
639                     hn = j;
640
641                     if (odd(subtype(s)))
642                       hyfbchar = font_bchar[hf];
643                     else
644                       hyfbchar = non_char;
645                   }
646                   else if ((type(s) == kern_node) && (subtype(s) == normal))
647                   {
648                     hb = s;
649                     hyfbchar = font_bchar[hf];
650                   }
651                   else
652                     goto lab33;
653
654                   s = link(s);
655                 }
656 lab33:;
657                 if (hn < lhyf + rhyf)
658                   goto lab31;
659
660                 while (true)
661                 {
662                   if (!(is_char_node(s)))
663                     switch(type(s))
664                     {
665                       case ligature_node:
666                         break;
667                       case kern_node:
668                         if (subtype(s) != normal)
669                           goto lab34;
670                         break;
671                       case whatsit_node:
672                       case glue_node:
673                       case penalty_node:
674                       case ins_node:
675                       case adjust_node:
676                       case mark_node:
677                         goto lab34;
678                         break;
679                       default:
680                         goto lab31;
681                         break;
682                     }
683                   s = link(s);
684                 }
685 lab34:;
686                 hyphenate();
687               }
688 lab31:;
689             }
690           }
691           break;
692         case kern_node:
693           if (subtype(cur_p) == explicit)
694           {
695             if (!is_char_node(link(cur_p)) && auto_breaking)
696               if (type(link(cur_p)) == glue_node)
697                 try_break(0, unhyphenated);
698
699             active_width[1] = active_width[1] + width(cur_p);
700           }
701           else
702             active_width[1] = active_width[1] + width(cur_p);
703           break;
704         case ligature_node:
705           {
706             f = font(lig_char(cur_p));
707             active_width[1] = active_width[1] + char_width(f, char_info(f, character(lig_char(cur_p))));
708           }
709           break;
710         case disc_node:
711           {
712             s = pre_break(cur_p);
713             disc_width = 0;
714
715             if (s == 0)
716               try_break(ex_hyphen_penalty, hyphenated);
717             else
718             {
719               do
720               {
721                 if (is_char_node(s))
722                 {
723                   f = font(s);
724                   disc_width = disc_width + char_width(f, char_info(f, character(s)));
725                 }
726                 else switch(type(s))
727                 {
728                   case ligature_node:
729                     {
730                       f = font(lig_char(s));
731                       disc_width = disc_width + font_info[width_base[f] + font_info[char_base[f]+ mem[s + 1].hh.b1].qqqq.b0].cint;
732                     }
733                     break;
734                   case hlist_node:
735                   case vlist_node:
736                   case rule_node:
737                   case kern_node:
738                     disc_width = disc_width + width(s);
739                     break;
740                   default:
741                     {
742                       confusion("disc3");
743                       return;       // abort_flag set
744                     }
745                     break;
746                 }
747                 s = link(s);
748               }
749               while (!(s == 0));
750
751               active_width[1] = active_width[1] + disc_width;
752               try_break(hyphen_penalty, hyphenated);
753               active_width[1] = active_width[1] - disc_width;
754             }
755             r = replace_count(cur_p);
756             s = link(cur_p);
757
758             while (r > 0)
759             {
760               if (is_char_node(s))
761               {
762                 f = font(s);
763                 active_width[1] = active_width[1] + char_width(f, char_info(f, character(s)));
764               }
765               else switch(type(s))
766               {
767                 case ligature_node:
768                   {
769                     f = font(lig_char(s));
770                     active_width[1] = active_width[1] + char_width(f, char_info(f, character(lig_char(s))));
771                   }
772                   break;
773
774                 case hlist_node:
775                 case vlist_node:
776                 case rule_node:
777                 case kern_node:
778                   active_width[1] = active_width[1] + width(s);
779                   break;
780
781                 default:
782                   {
783                     confusion("disc4");
784                     return;       // abort_flag set
785                   }
786                   break;
787               }
788
789               decr(r);
790               s = link(s);
791             }
792
793             prevp = cur_p;
794             cur_p = s;
795             goto lab35;
796           }
797           break;
798
799         case math_node:
800           {
801             auto_breaking = (subtype(cur_p) == 1);
802             {
803               if (!is_char_node(link(cur_p)) && auto_breaking)
804                 if (type(link(cur_p)) == glue_node)
805                   try_break(0, unhyphenated);
806
807               active_width[1] = active_width[1] + width(cur_p);
808             }
809           }
810           break;
811
812         case penalty_node:
813           try_break(penalty(cur_p), unhyphenated);
814           break;
815
816         case mark_node:
817         case ins_node:
818         case adjust_node:
819           break;
820
821         default:
822           {
823             confusion("paragraph");
824             return;       // abort_flag set
825           }
826           break;
827       }
828
829       prevp = cur_p;
830       cur_p = link(cur_p);
831 lab35:;
832     }
833
834     if (cur_p == 0)
835     {
836       try_break(eject_penalty, hyphenated);
837
838       if (link(active) != active)
839       {
840         r = link(active);
841         fewest_demerits = 1073741823L; /* 2^30 - 1 */
842
843         do
844           {
845             if (type(r) != 2)
846               if (total_demerits(r) < fewest_demerits)
847               {
848                 fewest_demerits = total_demerits(r);
849                 best_bet = r;
850               }
851
852             r = link(r);
853           }
854         while (!(r == active));
855
856         best_line = line_number(best_bet);
857
858         if (looseness == 0)
859         {
860           goto lab30;           /* normal exit */
861         }
862
863         {
864           r = link(active);
865           actual_looseness = 0;
866
867           do
868             {
869               if (type(r) != 2)
870               {
871                 line_diff = toint(line_number(r)) - toint(best_line);
872
873                 if (((line_diff < actual_looseness) && (looseness <= line_diff)) ||
874                     ((line_diff > actual_looseness) && (looseness >= line_diff)))
875                 {
876                   best_bet = r;
877                   actual_looseness = line_diff;
878                   fewest_demerits = total_demerits(r);
879                 }
880                 else if ((line_diff == actual_looseness) && (total_demerits(r) < fewest_demerits))
881                 {
882                   best_bet = r;
883                   fewest_demerits = total_demerits(r);
884                 }
885               }
886
887               r = link(r);
888             }
889           while (!(r == active));
890
891           best_line = line_number(best_bet);
892         }
893
894         if ((actual_looseness == looseness) || final_pass)
895         {
896           goto lab30;
897         }
898       }
899     }
900
901     q = link(active);
902
903     while (q != active)
904     {
905       cur_p = link(q);
906
907       if (type(q) == 2)
908         free_node(q, 7);
909       else
910         free_node(q, 3);
911
912       q = cur_p;
913     }
914
915     q = passive;
916
917     while (q != 0)
918     {
919       cur_p = link(q);
920       free_node(q, 2);
921       q = cur_p;
922     }
923
924     if (! second_pass)
925     {
926 #ifdef STAT
927       if (tracing_paragraphs > 0)
928         print_nl("@secondpass");
929 #endif /* STAT */
930       threshold = tolerance;
931       second_pass = true;
932       second_pass_count++;          /* 96 Feb 9 */
933       final_pass = (emergency_stretch <= 0);
934     }
935     else
936     {
937 #ifdef STAT
938       if (tracing_paragraphs > 0)
939         print_nl("@emergencypass");
940 #endif
941
942       background[2] = background[2] + emergency_stretch;
943       final_pass = true;
944       ++final_pass_count;         /* 96 Feb 9 */
945     }
946   }
947
948 lab30:
949   if (best_line == 2)
950     single_line++;
951
952 #ifdef STAT
953   if (tracing_paragraphs > 0)
954   {
955     end_diagnostic(true);
956     normalize_selector();
957   }
958 #endif
959
960   post_line_break(final_widow_penalty);
961   q = link(active);
962
963   while (q != active)
964   {
965     cur_p = link(q);
966
967     if (type(q) == 2)
968       free_node(q, 7);
969     else
970       free_node(q, 3);
971
972     q = cur_p;
973   }
974
975   q = passive;
976
977   while (q != 0)
978   {
979     cur_p = link(q);
980     free_node(q, 2);
981     q = cur_p;
982   }
983
984   pack_begin_line = 0;
985 }
986 /* sec 1211 */
987 void prefixed_command (void)
988 {
989   small_number a;
990   internal_font_number f;
991   halfword j;
992   font_index k;
993   pointer p, q;
994   integer n;
995   boolean e;
996
997   a = 0;
998
999   while (cur_cmd == prefix)
1000   {
1001     if (!odd(a / cur_chr))
1002       a = a + cur_chr;
1003
1004     do
1005       {
1006         get_x_token();
1007       }
1008     while (!((cur_cmd != spacer) && (cur_cmd != relax)));
1009
1010     if (cur_cmd <= max_non_prefixed_command)
1011     {
1012       print_err("You can't use a prefix with `");
1013       print_cmd_chr(cur_cmd, cur_chr);
1014       print_char('\'');
1015       help1("I'll pretend you didn't say \\long or \\outer or \\global.");
1016       back_error();
1017       return;
1018     }
1019   }
1020
1021   if ((cur_cmd != def) && (a % 4 != 0))
1022   {
1023     print_err("You can't use `");
1024     print_esc("long");
1025     print_string("' or `");
1026     print_esc("outer");
1027     print_string("' with `");
1028     print_cmd_chr(cur_cmd, cur_chr); 
1029     print_char('\'');
1030     help1("I'll pretend you didn't say \\long or \\outer here.");
1031     error();
1032   }
1033
1034   if (global_defs != 0)
1035     if (global_defs < 0)
1036     {
1037       if ((a >= 4))
1038         a = a - 4;
1039     }
1040     else
1041     {
1042       if (!(a >= 4))
1043         a = a + 4;
1044     }
1045
1046   switch (cur_cmd)
1047   {
1048     case set_font:
1049       define(cur_font_loc, data, cur_chr);
1050       break;
1051
1052     case def:
1053       {
1054         if (odd(cur_chr) && !(a >= 4) && (global_defs >= 0))
1055           a = a + 4;
1056
1057         e = (cur_chr >= 2);
1058         get_r_token();
1059         p = cur_cs;
1060         q = scan_toks(true, e);
1061         define(p, call + (a % 4), def_ref);
1062       }
1063       break;
1064
1065     case let:
1066       {
1067         n = cur_chr;
1068         get_r_token();
1069         p = cur_cs;
1070
1071         if (n == 0)
1072         {
1073           do
1074             {
1075               get_token();
1076             }
1077           while (!(cur_cmd != spacer));
1078
1079           if (cur_tok == other_token + '=')
1080           {
1081             get_token();
1082
1083             if (cur_cmd == spacer)
1084               get_token();
1085           }
1086         }
1087         else
1088         {
1089           get_token();
1090           q = cur_tok;
1091           get_token();
1092           back_input();
1093           cur_tok = q;
1094           back_input();
1095         }
1096
1097         if (cur_cmd >= call)
1098           add_token_ref(cur_chr);
1099
1100         define(p, cur_cmd, cur_chr);
1101       }
1102       break;
1103
1104     case shorthand_def:
1105       {
1106         n = cur_chr;
1107         get_r_token();
1108         p = cur_cs;
1109         define(p, relax, 256);
1110         scan_optional_equals();
1111
1112         switch (n)
1113         {
1114           case char_def_code:
1115             {
1116               scan_char_num();
1117               define(p, char_given, cur_val);
1118             }
1119             break;
1120
1121           case math_char_def_code:
1122             {
1123               scan_fifteen_bit_int();
1124               define(p, math_given, cur_val);
1125             }
1126             break;
1127
1128           default:
1129             {
1130               scan_eight_bit_int();
1131
1132               switch (n)
1133               {
1134                 case count_def_code:
1135                   define(p, assign_int, count_base + cur_val);
1136                   break;
1137
1138                 case dimen_def_code:
1139                   define(p, assign_dimen, scaled_base + cur_val);
1140                   break;
1141
1142                 case skip_def_code:
1143                   define(p, assign_glue, skip_base + cur_val);
1144                   break;
1145
1146                 case mu_skip_def_code:
1147                   define(p, assign_mu_glue, mu_skip_base + cur_val);
1148                   break;
1149
1150                 case toks_def_code:
1151                   define(p, assign_toks, toks_base + cur_val);
1152                   break;
1153               }
1154             }
1155             break;
1156         }
1157       }
1158       break;
1159
1160     case read_to_cs:
1161       {
1162         scan_int();
1163         n = cur_val;
1164
1165         if (!scan_keyword("to"))
1166         {
1167           print_err("Missing `to' inserted");
1168           help2("You should have said `\\read<number> to \\cs'.",
1169               "I'm going to look for the \\cs now.");
1170           error();
1171         }
1172
1173         get_r_token();
1174         p = cur_cs;
1175         read_toks(n, p);
1176         define(p, call, cur_val);
1177       }
1178       break;
1179
1180     case toks_register:
1181     case assign_toks:
1182       {
1183         q = cur_cs;
1184
1185         if (cur_cmd == toks_register)
1186         {
1187           scan_eight_bit_int();
1188           p = toks_base + cur_val;
1189         }
1190         else
1191           p = cur_chr;
1192
1193         scan_optional_equals();
1194
1195         do
1196           {
1197             get_x_token();
1198           }
1199         while (!((cur_cmd != spacer) && (cur_cmd != relax)));
1200
1201         if (cur_cmd != left_brace)
1202         {
1203           if (cur_cmd == toks_register)
1204           {
1205             scan_eight_bit_int();
1206             cur_cmd = assign_toks;
1207             cur_chr = toks_base + cur_val;
1208           }
1209
1210           if (cur_cmd == assign_toks)
1211           {
1212             q = equiv(cur_chr);
1213
1214             if (q == 0)
1215               define(p, undefined_cs, 0);
1216             else
1217             {
1218               add_token_ref(q);
1219               define(p, call, q);
1220             }
1221             goto lab30;
1222           }
1223         }
1224
1225         back_input();
1226         cur_cs = q;
1227         q = scan_toks(false, false);
1228
1229         if (link(def_ref) == 0)
1230         {
1231           define(p, undefined_cs, 0);
1232           free_avail(def_ref);
1233         }
1234         else
1235         {
1236           if (p == output_routine_loc)
1237           {
1238             link(q) = get_avail();
1239             q = link(q);
1240             info(q) = right_brace_token + '}';
1241             q = get_avail();
1242             info(q) = left_brace_token + '{';
1243             link(q) = link(def_ref);
1244             link(def_ref) = q;
1245           }
1246
1247           define(p, call, def_ref);
1248         }
1249       }
1250       break;
1251
1252     case assign_int:
1253       {
1254         p = cur_chr;
1255         scan_optional_equals();
1256         scan_int();
1257         word_define(p, cur_val);
1258       }
1259       break;
1260
1261     case assign_dimen:
1262       {
1263         p = cur_chr;
1264         scan_optional_equals();
1265         scan_dimen(false, false, false);
1266         word_define(p, cur_val);
1267       }
1268       break;
1269
1270     case assign_glue:
1271     case assign_mu_glue:
1272       {
1273         p = cur_chr;
1274         n = cur_cmd;
1275         scan_optional_equals();
1276
1277         if (n == assign_mu_glue)
1278           scan_glue(mu_val);
1279         else
1280           scan_glue(glue_val);
1281
1282         trap_zero_glue();
1283         define(p, glue_ref, cur_val);
1284       }
1285       break;
1286
1287     case def_code:
1288       {
1289         if (cur_chr == cat_code_base)
1290           n = max_char_code;
1291         else if (cur_chr == math_code_base)
1292           n = 32768L; /* 2^15 */
1293         else if (cur_chr == sf_code_base)
1294           n = 32767; /* 2^15 - 1*/
1295         else if (cur_chr == del_code_base)
1296           n = 16777215L; /* 2^24 - 1 */
1297         else
1298           n = 255;
1299
1300         p = cur_chr;
1301         scan_char_num();
1302         p = p + cur_val;
1303         scan_optional_equals();
1304         scan_int();
1305
1306         if (((cur_val < 0) && (p < del_code_base)) ||(cur_val > n))
1307         {
1308           print_err("Invalid code(");
1309           print_int(cur_val);
1310
1311           if (p < del_code_base)
1312             print_string("), should be in the range 0..");
1313           else
1314             print_string("), should be at most ");
1315
1316           print_int(n);
1317           help1("I'm going to use 0 instead of that illegal code value.");
1318           error();
1319           cur_val = 0;
1320         }
1321
1322         if (p < math_code_base)
1323           define(p, data, cur_val);
1324         else if (p < del_code_base)
1325           define(p, data, cur_val);
1326         else 
1327           word_define(p, cur_val);
1328       }
1329       break;
1330
1331     case def_family:
1332       {
1333         p = cur_chr;
1334         scan_four_bit_int();
1335         p = p + cur_val;
1336         scan_optional_equals();
1337         scan_font_ident();
1338         define(p, data, cur_val);
1339       }
1340       break;
1341
1342     case tex_register:
1343     case advance:
1344     case multiply:
1345     case divide:
1346       do_register_command(a);
1347       break;
1348
1349     case set_box:
1350       {
1351         scan_eight_bit_int();
1352
1353         if ((a >= 4))
1354           n = 256 + cur_val;
1355         else
1356           n = cur_val;
1357
1358         scan_optional_equals();
1359
1360         if (set_box_allowed)
1361           scan_box(box_flag + n);
1362         else
1363         {
1364           print_err("Improper ");
1365           print_esc("setbox");
1366           help2("Sorry, \\setbox is not allowed after \\halign in a display,",
1367               "or between \\accent and an accented character.");
1368           error();
1369         }
1370       }
1371       break;
1372
1373     case set_aux:
1374       alter_aux();
1375       break;
1376
1377     case set_prev_graf:
1378       alter_prev_graf();
1379       break;
1380
1381     case set_page_dimen:
1382       alter_page_so_far();
1383       break;
1384
1385     case set_page_int:
1386       alter_integer();
1387       break;
1388
1389     case set_box_dimen:
1390       alter_box_dimen();
1391       break;
1392
1393     case set_shape:
1394       {
1395         scan_optional_equals();
1396         scan_int();
1397         n = cur_val;
1398
1399         if (n <= 0)
1400           p = 0;
1401         else
1402         {
1403           p = get_node(2 * n + 1);
1404           info(p) = n;
1405
1406           for (j = 1; j <= n; j++)
1407           {
1408             scan_dimen(false, false, false);
1409             mem[p + 2 * j - 1].cint = cur_val;
1410             scan_dimen(false, false, false);
1411             mem[p + 2 * j].cint = cur_val;
1412           }
1413         }
1414
1415         define(par_shape_loc, shape_ref, p);
1416       }
1417       break;
1418
1419     case hyph_data:
1420       if (cur_chr == 1)
1421       {
1422 #ifdef INITEX
1423         if (is_initex)
1424         {
1425           new_patterns();
1426           goto lab30;
1427         }
1428 #endif
1429         print_err("Patterns can be loaded only by INITEX");
1430         help_ptr = 0;
1431         error();
1432
1433         do
1434           {
1435             get_token();
1436           }
1437         while (!(cur_cmd == right_brace));
1438
1439         return;
1440       }
1441       else
1442       {
1443         new_hyph_exceptions();
1444         goto lab30;
1445       }
1446       break;
1447
1448     case assign_font_dimen:
1449       {
1450         find_font_dimen(true);
1451         k = cur_val;
1452         scan_optional_equals();
1453         scan_dimen(false, false, false);
1454         font_info[k].cint = cur_val;
1455       }
1456       break;
1457
1458     case assign_font_int:
1459       {
1460         n = cur_chr;
1461         scan_font_ident();
1462         f = cur_val;
1463         scan_optional_equals();
1464         scan_int();
1465
1466         if (n == 0)
1467           hyphen_char[f] = cur_val;
1468         else
1469           skew_char[f] = cur_val;
1470       }
1471       break;
1472
1473     case def_font:
1474       new_font(a);
1475       break;
1476
1477     case set_interaction:
1478       new_interaction();
1479       break;
1480
1481     default:
1482       {
1483         confusion("prefix");
1484         return;       // abort_flag set
1485       }
1486       break;
1487   }
1488
1489 lab30:
1490   if (after_token != 0)
1491   {
1492     cur_tok = after_token;
1493     back_input();
1494     after_token = 0;
1495   }
1496 }
1497 /* sec 1303 */
1498 boolean load_fmt_file (void)
1499 {
1500   integer j, k;
1501   pointer p, q;
1502   integer x;
1503
1504   undump_int(x);
1505
1506   if (x != BEGINFMTCHECKSUM)
1507     goto lab_bad_fmt;
1508
1509   undump_int(x); /* mem_bot */
1510
1511   if (x != mem_bot)
1512     goto lab_bad_fmt;
1513
1514   undump_int(x); /* mem_top */
1515
1516 #ifdef ALLOCATEMAIN
1517 /* we already read this once earlier to grab mem_top */
1518   if (trace_flag)
1519     printf("Read from fmt file mem_top = %d TeX words\n", x);
1520
1521   mem = allocate_main_memory(x); /* allocate main memory at this point */
1522
1523   if (mem == NULL)
1524     exit(1);                     /* redundant sanity test ! */
1525
1526   initialize_aux();              /* do `mem' part of initialize */
1527 #endif
1528
1529   if (x != mem_top)
1530     goto lab_bad_fmt;
1531
1532   undump_int(x); /* eqtb_size */
1533
1534   if (x != eqtb_size)
1535     goto lab_bad_fmt;
1536
1537   undump_int(x); /* hash_prime */
1538
1539   if (x != hash_prime)
1540     goto lab_bad_fmt;
1541
1542   undump_int(x); /* hyphen_prime */
1543
1544 #ifdef ALLOCATEHYPHEN
1545 /* allow format files dumped with arbitrary (prime) hyphenation exceptions */
1546   realloc_hyphen(x);
1547   hyphen_prime = x;
1548 #endif
1549
1550   if (x != hyphen_prime)
1551     goto lab_bad_fmt;
1552
1553   {
1554     undump_int(x); /* pool_size */
1555
1556     if (x < 0)
1557       goto lab_bad_fmt; 
1558
1559 #ifdef ALLOCATESTRING
1560     if (x > current_pool_size)
1561     {
1562       if (trace_flag)
1563         printf("undump string pool reallocation (%d > %d)\n", x, current_pool_size);
1564
1565       str_pool = realloc_str_pool (x - current_pool_size + increment_pool_size);
1566     }
1567
1568     if (x > current_pool_size)
1569 #else
1570     if (x > pool_size)
1571 #endif
1572     {
1573       printf("%s%s\n",  "---! Must increase the ", "string pool size");
1574       goto lab_bad_fmt;
1575     }
1576     else
1577       pool_ptr = x;
1578   }
1579
1580   {
1581     undump_int(x);  /* max_strings */
1582
1583     if (x < 0)
1584       goto lab_bad_fmt;
1585
1586 #ifdef ALLOCATESTRING
1587     if (x > current_max_strings)
1588     {
1589       if (trace_flag)
1590         printf("undump string pointer reallocation (%d > %d)\n", x, current_max_strings);
1591
1592       str_start = realloc_str_start(x - current_max_strings + increment_max_strings);
1593     }
1594
1595     if (x > current_max_strings) /* 94/Jan/24 */
1596 #else
1597     if (x > max_strings)
1598 #endif
1599     {
1600       printf("%s%s\n",  "---! Must increase the ", "max strings");
1601       goto lab_bad_fmt;
1602     }
1603     else
1604       str_ptr = x;
1605   }
1606
1607   if (undumpthings(str_start[0], str_ptr + 1)) /* undump string ptrs */
1608     return -1;
1609
1610   if (undumpthings(str_pool[0], pool_ptr)) /*  undump string pool */
1611     return -1;
1612
1613   init_str_ptr = str_ptr;
1614   init_pool_ptr = pool_ptr;
1615   undump(lo_mem_stat_max + 1000, hi_mem_stat_min - 1, lo_mem_max);
1616   undump(lo_mem_stat_max + 1, lo_mem_max, rover);
1617   p = mem_bot;
1618   q = rover;
1619
1620   do
1621     {
1622       if (undumpthings(mem[p], q + 2 - p))
1623         return -1;
1624
1625       p = q + node_size(q);
1626
1627       if ((p > lo_mem_max) || ((q >= rlink(q)) && (rlink(q) != rover)))
1628         goto lab_bad_fmt;
1629
1630       q = rlink(q);
1631     }
1632   while (!(q == rover));
1633
1634   if (undumpthings(mem[p], lo_mem_max + 1 - p))
1635     return -1;
1636
1637   if (mem_min < mem_bot - 2) /*  ? splice in block below */
1638   {
1639 /*  or call add_variable_space(mem_bot - (mem_min + 1)) */
1640     if (trace_flag)
1641       puts("Splicing in mem_min space in undump!\n");
1642
1643     p = llink(rover);
1644     q = mem_min + 1;
1645     link(mem_min) = 0;       /* null */
1646     info(mem_min) = 0;       /* null */
1647     rlink(p) = q;
1648     llink(rover) = q;
1649     rlink(q) = rover;
1650     llink(q) = p;
1651     link(q) = empty_flag;
1652     node_size(q) = mem_bot - q;
1653   }
1654
1655   undump(lo_mem_max + 1, hi_mem_stat_min, hi_mem_min);
1656   undump(mem_bot, mem_top, avail);
1657   mem_end = mem_top;
1658
1659   if (undumpthings(mem[hi_mem_min], mem_end + 1 - hi_mem_min))
1660     return -1;
1661
1662   undump_int(var_used);
1663   undump_int(dyn_used);
1664
1665   k = active_base;
1666
1667   do
1668     {
1669       undump_int(x);
1670
1671       if ((x < 1) || (k + x > (eqtb_size + 1)))
1672         goto lab_bad_fmt;
1673
1674       if (undumpthings(eqtb[k], x))
1675         return -1;
1676
1677       k = k + x;
1678       undump_int(x);
1679
1680       if ((x < 0) || (k + x > (eqtb_size + 1)))
1681         goto lab_bad_fmt;
1682
1683       for (j = k; j <= k + x - 1; j++)
1684         eqtb[j] = eqtb[k - 1];
1685
1686       k = k + x;
1687     }
1688   while (!(k > eqtb_size));
1689
1690   undump(hash_base, frozen_control_sequence, par_loc);
1691   par_token = cs_token_flag + par_loc;
1692   undump(hash_base, frozen_control_sequence, write_loc);
1693   undump(hash_base, frozen_control_sequence, hash_used);
1694
1695   p = hash_base - 1;
1696
1697   do
1698     {
1699       undump(p + 1, hash_used, p);
1700       undump_hh(hash[p]);
1701     }
1702   while (!(p == hash_used));
1703
1704   if (undumpthings(hash[hash_used + 1], undefined_control_sequence - 1 - hash_used))
1705     return -1;
1706
1707   undump_int(cs_count);
1708
1709   if (trace_flag)
1710     printf("itex undump cs_count %d ", cs_count);
1711
1712   {
1713     undump_int(x); /* font_mem_size */
1714
1715     if (x < 7)
1716       goto lab_bad_fmt;
1717
1718 #ifdef ALLOCATEFONT
1719     if (trace_flag)
1720       printf("Read from fmt fmem_ptr = %d\n", x);
1721
1722     if (x > current_font_mem_size)
1723     {
1724       if (trace_flag)
1725         printf("Undump realloc font_info (%d > %d)\n", x, current_font_mem_size);
1726
1727       font_info = realloc_font_info (x - current_font_mem_size + increment_font_mem_size);
1728     }
1729
1730     if (x > current_font_mem_size)
1731 #else
1732     if (x > font_mem_size)
1733 #endif
1734     {
1735       puts("---! Must increase the font mem size\n");
1736       goto lab_bad_fmt;
1737     }
1738     else
1739       fmem_ptr = x;
1740   }
1741
1742   {
1743     if (undumpthings(font_info[0], fmem_ptr))
1744       return -1;
1745
1746     {
1747       undump_int(x); /* font_max */
1748
1749       if (x < 0)
1750         goto lab_bad_fmt;
1751
1752       if (x > font_max)
1753       {
1754         puts("---! Must increase the font max\n"); 
1755         goto lab_bad_fmt;
1756       }
1757       else
1758         font_ptr = x;
1759     }
1760
1761     frozen_font_ptr = font_ptr;
1762
1763     if (undumpthings(font_check[0], font_ptr + 1))
1764       return -1;
1765
1766     if (undumpthings(font_size[0], font_ptr + 1))
1767       return -1;
1768
1769     if (undumpthings(font_dsize[0], font_ptr + 1))
1770       return -1;
1771
1772     if (undumpthings(font_params[0], font_ptr + 1))
1773       return -1;
1774
1775     if (undumpthings(hyphen_char[0], font_ptr + 1))
1776       return -1;
1777
1778     if (undumpthings(skew_char[0], font_ptr + 1))
1779       return -1;
1780
1781     if (undumpthings(font_name[0], font_ptr + 1))
1782       return -1;
1783
1784     if (undumpthings(font_area[0], font_ptr + 1))
1785       return -1;
1786
1787     if (undumpthings(font_bc[0], font_ptr + 1))
1788       return -1;
1789
1790     if (undumpthings(font_ec[0], font_ptr + 1))
1791       return -1;
1792
1793     if (undumpthings(char_base[0], font_ptr + 1))
1794       return -1;
1795
1796     if (undumpthings(width_base[0], font_ptr + 1))
1797       return -1;
1798
1799     if (undumpthings(height_base[0], font_ptr + 1))
1800       return -1;
1801
1802     if (undumpthings(depth_base[0], font_ptr + 1))
1803       return -1;
1804
1805     if (undumpthings(italic_base[0], font_ptr + 1))
1806       return -1;
1807
1808     if (undumpthings(lig_kern_base[0], font_ptr + 1))
1809       return -1;
1810
1811     if (undumpthings(kern_base[0], font_ptr + 1))
1812       return -1;
1813
1814     if (undumpthings(exten_base[0], font_ptr + 1))
1815       return -1;
1816
1817     if (undumpthings(param_base[0], font_ptr + 1))
1818       return -1;
1819
1820     if (undumpthings(font_glue[0], font_ptr + 1))
1821       return -1;
1822
1823     if (undumpthings(bchar_label[0], font_ptr + 1))
1824       return -1;
1825
1826     if (undumpthings(font_bchar[0], font_ptr + 1))
1827       return -1;
1828
1829     if (undumpthings(font_false_bchar[0], font_ptr + 1))
1830       return -1;
1831   }
1832
1833 /* log not opened yet, so can't show fonts frozen into format */
1834 /* May be able to avoid the following since we switched to */
1835 /* non_address from font_mem_size to 0 96/Jan/15 ??? */
1836
1837 #ifdef ALLOCATEFONT
1838   {
1839     int count = 0, oldfont_mem_size = 0;
1840     
1841     for (x = 0; x <= font_ptr; x++)
1842     {
1843       if (bchar_label[x] > oldfont_mem_size)
1844         oldfont_mem_size = bchar_label[x];
1845     }
1846
1847     if (oldfont_mem_size != non_address && oldfont_mem_size > font_max)
1848     {
1849       for (x = 0; x <= font_ptr; x++)
1850       {
1851         if (bchar_label[x] == oldfont_mem_size)
1852         {
1853           bchar_label[x] = non_address;
1854           count++;
1855         }
1856       }
1857
1858       if (trace_flag)
1859         printf("oldfont_mem_size is %d --- hit %d times. Using non_address %d\n",
1860             oldfont_mem_size, count, non_address);
1861     }
1862   }
1863 #endif
1864
1865   undump(0, hyphen_prime, hyph_count);
1866
1867   for (k = 1; k <= hyph_count; k++)
1868   {
1869     undump(0, hyphen_prime, j);
1870     undump(0, str_ptr, hyph_word[j]);
1871     undump(0, max_halfword, hyph_list[j]);
1872   }
1873
1874 #ifdef ALLOCATEHYPHEN
1875 /* if user specified new hyphen prime - flush existing exception patterns ! */
1876 /* but, we can reclaim the string storage wasted ... */
1877   if (is_initex)
1878   {
1879     if (new_hyphen_prime != 0)
1880     {
1881       realloc_hyphen(new_hyphen_prime); /* reset_hyphen(); */
1882       hyphen_prime = new_hyphen_prime;
1883     }
1884   }
1885 #endif
1886
1887   {
1888     undump_int(x);
1889
1890     if (x < 0)
1891       goto lab_bad_fmt;
1892
1893 #ifdef ALLOCATETRIES
1894     if (!is_initex)
1895     {
1896       allocate_tries(x); /* allocate only as much as is needed */
1897 /* trie_size = x; */ /* ??? */
1898     }
1899 #endif
1900
1901     if (x > trie_size)
1902     {
1903       puts("---! Must increase the trie size\n");
1904       goto lab_bad_fmt;
1905     }
1906     else
1907       j = x;
1908   }
1909
1910 #ifdef INITEX
1911   if (is_initex)
1912     trie_max = j;
1913 #endif
1914
1915   if (undumpthings(trie_trl[0], j + 1))
1916     return -1;
1917
1918   if (undumpthings(trie_tro[0], j + 1))
1919     return -1;
1920
1921   if (undumpthings(trie_trc[0], j + 1))
1922     return -1;
1923
1924   {
1925     undump_int(x);
1926
1927     if (x < 0)
1928       goto lab_bad_fmt;
1929
1930     if (x > trie_op_size)
1931     {
1932       puts("---! Must increase the trie op size\n");
1933       goto lab_bad_fmt;
1934     }
1935     else
1936       j = x;
1937   }
1938
1939 #ifdef INITEX
1940   if (is_initex)
1941     trie_op_ptr = j;
1942 #endif
1943   
1944   if (undumpthings(hyf_distance[1], j))
1945     return -1;
1946
1947   if (undumpthings(hyf_num[1], j))
1948     return -1;
1949
1950   if (undumpthings(hyf_next[1], j))
1951     return -1;
1952
1953 #ifdef INITEX
1954   if (is_initex)
1955   {
1956     for (k = 0; k <= 255; k++)
1957       trie_used[k] = min_quarterword;
1958   }
1959 #endif
1960
1961   k = 256;
1962
1963   while (j > 0)
1964   {
1965     undump(0, k - 1, k);
1966     undump(1, j, x);
1967
1968 #ifdef INITEX
1969     if (is_initex)
1970       trie_used[k] = x;
1971 #endif
1972
1973     j = j - x;
1974     op_start[k] = j;
1975   }
1976
1977 #ifdef INITEX
1978   if (is_initex)
1979     trie_not_ready = false;
1980 #endif
1981
1982   undump(batch_mode, error_stop_mode, interaction);
1983   undump(0, str_ptr, format_ident);
1984   undump_int(x);
1985   
1986   if ((x != ENDFMTCHECKSUM) || feof(fmt_file))
1987     goto lab_bad_fmt;
1988
1989   return true;
1990
1991 lab_bad_fmt:;
1992   puts("(Fatal format file error; I'm stymied)\n");
1993
1994   return false;
1995 }
1996 /* sec 1335 */
1997 void final_cleanup (void)
1998 {
1999   small_number c;
2000
2001   c = cur_chr;
2002
2003   if (job_name == 0)
2004     open_log_file();
2005
2006   while (input_ptr > 0)
2007   {
2008     if (state == 0)
2009     {
2010       end_token_list();
2011     }
2012     else
2013       end_file_reading();
2014   }
2015
2016   while (open_parens > 0)
2017   {
2018     print_string(" )");
2019     decr(open_parens);
2020   }
2021
2022   if (cur_level > level_one)
2023   {
2024     print_nl("(");
2025     print_esc("end occurred ");
2026     print_string("inside a group at level ");
2027     print_int(cur_level - 1);
2028     print_char(')');
2029   }
2030
2031   while (cond_ptr != 0)
2032   {
2033     print_nl("(");
2034     print_esc("end occurred ");
2035     print_string("when ");
2036     print_cmd_chr('i', cur_if);
2037
2038     if (if_line != 0)
2039     {
2040       print_string("on line ");
2041       print_int(if_line);
2042     }
2043
2044     print_string(" was incomplete)");
2045     if_line = mem[cond_ptr + 1].cint;
2046     cur_if = mem[cond_ptr].hh.b1;
2047     temp_ptr = cond_ptr;
2048     cond_ptr = mem[cond_ptr].hh.rh;
2049     free_node(temp_ptr, 2);
2050   }
2051
2052   if (history != spotless)
2053     if (((history == warning_issued) || (interaction < error_stop_mode)))
2054       if (selector == term_and_log)
2055       {
2056         selector = term_only;
2057         print_nl("(see the transcript file for additional information)");
2058         selector = term_and_log;
2059       }
2060
2061   if (c == 1)
2062   {
2063 #ifdef INITEX
2064     if (is_initex)
2065     {
2066       for (c = 0; c <= 4; c++)
2067       {
2068         if (cur_mark[c] != 0)
2069           delete_token_ref(cur_mark[c]);
2070       }
2071
2072       if (last_glue != max_halfword)
2073         delete_glue_ref(last_glue);
2074       store_fmt_file(); // returns a value ?
2075     }
2076 #endif
2077
2078     if (!is_initex)
2079       print_nl("(\\dump is performed only by INITEX)");
2080   }
2081 }
2082
2083 void show_frozen (void)
2084 {
2085   int i, j, n;
2086
2087   fprintf(log_file, "\n");
2088   fprintf(log_file, "(%d fonts frozen in format file:\n", font_ptr);
2089
2090   for (i = 1; i <= font_ptr; i++)
2091   {
2092     if (i > 1)
2093       fprintf(log_file, ", ");
2094
2095     if ((i % 8) == 0)
2096       fprintf(log_file, "\n");
2097
2098     n = str_start[font_name[i] + 1] - str_start[font_name[i]];
2099
2100     for (j = 0; j < n; j++)
2101     {
2102       putc(str_pool[str_start[font_name[i]] + j], log_file);
2103     }
2104   }
2105
2106   fprintf(log_file, ") ");
2107 }
2108
2109 int main_program (void)
2110 {
2111   history = fatal_error_stop;
2112
2113   if (ready_already == 314159L)
2114     goto lab1;
2115
2116   bad = 0;
2117
2118   if ((half_error_line < 30) || (half_error_line > error_line - 15))
2119     bad = 1;
2120
2121   if (max_print_line < 60)
2122     bad = 2;
2123
2124   if (dvi_buf_size % 8 != 0)
2125     bad = 3;
2126
2127   if (mem_bot + 1100 > mem_top)
2128     bad = 4;
2129
2130   if (hash_prime > (hash_size + hash_extra))
2131     bad = 5;
2132
2133   if (max_in_open >= 128)
2134     bad = 6;
2135
2136   if (mem_top < 256 + 11)
2137     bad = 7;
2138
2139 #ifdef INITEX
2140   if (is_initex)
2141   {
2142     if ((mem_min != 0) || (mem_max != mem_top))
2143       bad = 10;
2144   }
2145 #endif
2146
2147   if ((mem_min > mem_bot) || (mem_max < mem_top))
2148     bad = 10;
2149
2150   if ((min_quarterword > 0) || (max_quarterword < 255))
2151     bad = 11;
2152
2153   if ((min_halfword > 0) || (max_halfword < 32767))
2154     bad = 12;
2155
2156   if ((min_quarterword < min_halfword) || (max_quarterword > max_halfword))
2157     bad = 13;
2158
2159   if ((mem_min < min_halfword) || (mem_max >= max_halfword) || (mem_bot - mem_min >= max_halfword))
2160     bad = 14;
2161
2162   if (mem_max > mem_top + mem_extra_high)
2163     bad = 14;
2164
2165   if ((0 < min_quarterword) || (font_max > max_quarterword))
2166     bad = 15;
2167
2168 #ifdef INCREASEFONTS
2169   if (font_max > 1024)
2170 #else
2171   if (font_max > 256)
2172 #endif
2173     bad = 16;
2174
2175   if ((save_size > max_halfword) || (max_strings > max_halfword))
2176     bad = 17;
2177
2178   if (buf_size > max_halfword)
2179     bad = 18;
2180
2181   if (max_quarterword - min_quarterword < 255)
2182     bad = 19;
2183
2184   if (cs_token_flag + undefined_control_sequence > max_halfword)
2185     bad = 21;
2186
2187   if (format_default_length > file_name_size)
2188     bad = 31;
2189
2190   if (max_halfword < (mem_top - mem_min) / 2)
2191     bad = 41;
2192
2193   if (bad > 0)
2194   {
2195     printf("%s%s%ld\n", "Ouch---my internal constants have been clobbered!",
2196         "---case ", (long) bad);
2197
2198     goto lab9999;
2199   }
2200
2201   initialize();
2202
2203 #ifdef INITEX
2204   if (is_initex)
2205   {
2206     if (!get_strings_started())
2207       goto lab9999;
2208
2209     init_prim();
2210     init_str_ptr = str_ptr;
2211     init_pool_ptr = pool_ptr;
2212     fix_date_and_time();
2213   }
2214 #endif
2215
2216   ready_already = 314159L;
2217
2218 lab1:
2219   selector = term_only;
2220   tally = 0;
2221   term_offset = 0;
2222   file_offset = 0;
2223   show_line(tex_version, 0);
2224
2225 #ifdef _WIN32
2226   #ifdef _WIN64
2227     printf(log_line, " (%s %s/Windows 64bit)", application, yandyversion);
2228   #else
2229     printf(log_line, " (%s %s/Windows 32bit)", application, yandyversion);
2230   #endif
2231 #else
2232     printf(log_line, " (%s %s/Linux)", application, yandyversion);
2233 #endif
2234
2235   if (format_ident > 0)
2236     slow_print(format_ident);
2237
2238   print_ln();
2239
2240 #ifndef _WINDOWS
2241   fflush(stdout);
2242 #endif
2243
2244   job_name = 0;
2245   name_in_progress = false;
2246   log_opened = false;
2247   output_file_name = 0;
2248
2249   {
2250     {
2251       input_ptr = 0;
2252       max_in_stack = 0;
2253       in_open = 0;
2254       high_in_open = 0;
2255       open_parens = 0;
2256       max_open_parens = 0;
2257       max_buf_stack = 0;
2258       param_ptr = 0;
2259       max_param_stack = 0;
2260
2261 #ifdef ALLOCATEBUFFER
2262       memset (buffer, 0, current_buf_size);
2263 #else
2264       memset (buffer, 0, buf_size);
2265 #endif
2266
2267       first = 0;
2268       scanner_status = 0;
2269       warning_index = 0;
2270       first = 1;
2271       state = new_line;
2272       start = 1;
2273       index = 0;
2274       line = 0;
2275       cur_input.name_field = 0;
2276       force_eof = false;
2277       align_state = 1000000L;
2278
2279       if (!init_terminal())
2280         goto lab9999;
2281
2282       limit = last;
2283       first = last + 1;
2284     }
2285     
2286     if ((format_ident == 0) ||
2287         (buffer[loc] == '&') ||
2288         (buffer[loc] == '+'))
2289     {
2290       if (format_ident != 0)
2291         initialize();
2292
2293       if (!open_fmt_file ())
2294         goto lab9999;
2295
2296       if (!load_fmt_file ())
2297       {
2298 #ifdef COMPACTFORMAT
2299         gzclose(gz_fmt_file);
2300 #else
2301         w_close(fmt_file);
2302 #endif
2303         goto lab9999;
2304       }
2305
2306 #ifdef COMPACTFORMAT
2307       gzclose(gz_fmt_file);
2308 #else
2309       w_close(fmt_file);
2310 #endif
2311
2312       while ((loc < limit) &&
2313           (buffer[loc] == ' '))
2314         incr(loc);
2315     }
2316
2317     if ((end_line_char < 0) || (end_line_char > 255))
2318       decr(limit);
2319     else
2320       buffer[limit] = end_line_char;
2321
2322     fix_date_and_time();
2323     magic_offset = str_start[886] - 9 * ord_noad;
2324
2325     if (interaction == batch_mode)
2326       selector = no_print;
2327     else
2328       selector = term_only;
2329
2330     if ((loc < limit) &&
2331       (cat_code(buffer[loc]) != escape))
2332       start_input();
2333   }
2334
2335   if (show_tfm_flag && log_opened && font_ptr > 0)
2336     show_frozen();
2337
2338   main_time = clock();
2339   history = spotless;
2340
2341   if (show_cs_names)
2342     print_cs_names(stdout, 0);
2343
2344   main_control();
2345
2346   if (show_cs_names)
2347     print_cs_names(stdout, 1);
2348
2349   final_cleanup();
2350   close_files_and_terminate();
2351
2352 lab9999:
2353   {
2354     int code;
2355
2356 #ifndef _WINDOWS
2357     fflush(stdout);
2358 #endif
2359
2360     ready_already = 0;
2361
2362     if ((history != 0) && (history != 1))
2363       code = 1;
2364     else
2365       code = 0;
2366
2367     return code;
2368   }
2369 }
2370
2371 #ifdef ALLOCATEMAIN
2372 /* add a block of variable size node space below mem_bot */
2373 void add_variable_space(int size)
2374 {
2375   halfword p;
2376   halfword q;
2377   integer t;
2378
2379   if (mem_min == 0)
2380     t = mem_min;
2381   else
2382     t = mem_min + 1;
2383
2384   mem_min = t - (size + 1);     /* first word in new block - 1 */
2385
2386   if (mem_min < mem_start)      /* sanity test */
2387   {
2388     if (trace_flag)
2389       puts("WARNING: mem_min < mem_start!\n");
2390
2391     mem_min = mem_start;
2392   }
2393
2394   p = llink(rover);
2395   q = mem_min + 1;
2396   link(mem_min) = 0; /* insert blank word below ??? */
2397   info(mem_min) = 0; /* insert blank word below ??? */
2398   rlink(p) = q;
2399   llink(rover) = q;
2400   rlink(q) = rover;
2401   llink(q) = p;
2402   link(q) = empty_flag;
2403   info(q) = t - q; /* block size */
2404   rover = q;
2405 }
2406 #endif
2407
2408 /**************************************************************************/
2409
2410 #ifdef INITEX
2411 /* split out to allow sharing of code from do_initex and newpattern */
2412 void reset_trie (void)
2413 {
2414   integer k;
2415
2416   for (k = - (integer) trie_op_size; k <= trie_op_size; k++)
2417     trie_op_hash[k] = 0;
2418
2419   for (k = 0; k <= 255; k++)
2420     trie_used[k] = min_trie_op;
2421
2422   max_op_used = min_trie_op;
2423   trie_op_ptr = 0;
2424   trie_not_ready = true;
2425   trie_l[0] = 0;
2426   trie_c[0] = 0;
2427   trie_ptr = 0;
2428   trie_not_ready = true;
2429 }
2430 /* borrowed code from initialize() */
2431 void reset_hyphen (void)
2432 {
2433   hyph_pointer z;
2434
2435   for (z = 0; z <= hyphen_prime; z++)
2436   {
2437     hyph_word[z] = 0;
2438     hyph_list[z] = 0;
2439   }
2440
2441   hyph_count = 0;
2442 }
2443 /* split out to allow optimize for space, not time */
2444 void do_initex (void)
2445 {
2446 /*  integer i; */
2447   integer k;
2448 /*  hyph_pointer z; */
2449
2450   for (k = mem_bot + 1; k <= lo_mem_stat_max; k++)
2451     mem[k].cint = 0;
2452
2453   k = mem_bot;
2454
2455   while (k <= lo_mem_stat_max)
2456   {
2457     glue_ref_count(k) = 1;
2458     stretch_order(k) = normal;
2459     shrink_order(k) = normal;
2460     k = k + glue_spec_size;
2461   }
2462
2463   stretch(fil_glue) = 65535L;
2464   stretch_order(fil_glue) = fil;
2465   stretch(fill_glue) = 65535L;
2466   stretch_order(fill_glue) = fill;
2467   stretch(ss_glue) = 65535L;
2468   stretch_order(ss_glue) = fil;
2469   shrink(ss_glue) = 65535L;
2470   shrink_order(ss_glue) = fil;
2471   stretch(fil_neg_glue) = -65536L;
2472   stretch_order(fil_neg_glue) = fil;
2473   rover = lo_mem_stat_max + 1;
2474   link(rover) = empty_flag;
2475   node_size(rover) = block_size;
2476   llink(rover) = rover;
2477   rlink(rover) = rover;
2478   lo_mem_max = rover + block_size;
2479   link(lo_mem_max) = 0;
2480   info(lo_mem_max) = 0;
2481
2482   for (k = hi_mem_stat_min; k <= mem_top; k++)
2483     mem[k] = mem[lo_mem_max];
2484
2485   info(omit_template) = end_template_token;
2486   link(end_span) = max_quarterword + 1;
2487   info(end_span) = 0;
2488   type(last_active) = hyphenated;
2489   line_number(last_active) = max_halfword;
2490   subtype(last_active) = 0;
2491   subtype(page_ins_head) = 255;
2492   type(page_ins_head) = split_up;
2493   link(mem_top) = page_ins_head;
2494   type(page_head) = glue_node;
2495   subtype(page_head) = normal;
2496   avail = 0;                   /* avail <- null p.164 */
2497   mem_end = mem_top;
2498   hi_mem_min = hi_mem_stat_min;
2499   var_used = lo_mem_stat_max + 1 - mem_bot;
2500   dyn_used = hi_mem_stat_usage;
2501   eq_type(undefined_control_sequence) = undefined_cs;
2502   equiv(undefined_control_sequence) = 0;
2503   eq_level(undefined_control_sequence) = level_zero;
2504
2505   for (k = active_base; k <= undefined_control_sequence - 1; k++)
2506     eqtb[k] = eqtb[undefined_control_sequence];
2507
2508   equiv(glue_base) = zero_glue;
2509   eq_level(glue_base) = level_one;
2510   eq_type(glue_base) = glue_ref;
2511
2512   for (k = glue_base + 1; k <= local_base - 1; k++)
2513     eqtb[k] = eqtb[glue_base];
2514
2515   glue_ref_count(zero_glue) = glue_ref_count(zero_glue) + local_base - glue_base;
2516
2517   par_shape_ptr = 0;
2518   eq_type(par_shape_loc) = shape_ref;
2519   eq_level(par_shape_loc) = level_one;
2520
2521   for (k = output_routine_loc; k <= toks_base + 255; k++)
2522     eqtb[k] = eqtb[undefined_control_sequence];
2523
2524   box(0) = 0;
2525   eq_type(box_base) = box_ref;
2526   eq_level(box_base) = level_one;
2527
2528   for (k = box_base + 1; k <= box_base + 255; k++)
2529     eqtb[k] = eqtb[box_base];
2530
2531   cur_font = null_font;
2532   eq_type(cur_font_loc) = data;
2533   eq_level(cur_font_loc) = level_one;
2534
2535   for (k = math_font_base; k <= math_font_base + 47; k++)
2536     eqtb[k] = eqtb[cur_font_loc];
2537
2538   equiv(cat_code_base) = 0;
2539   eq_type(cat_code_base) = data;
2540   eq_level(cat_code_base) = level_one;
2541
2542   for (k = cat_code_base; k <= int_base - 1; k++)
2543     eqtb[k] = eqtb[cat_code_base];
2544
2545   for (k = 0; k <= 255; k++)
2546   {
2547     cat_code(k) = other_char;
2548     math_code(k) = k;
2549     sf_code(k) = 1000;
2550   }
2551
2552   cat_code(carriage_return) = car_ret;
2553   cat_code(' ') = spacer;
2554   cat_code('\\') = escape;
2555   cat_code('%') = comment;
2556   cat_code(invalid_code) = invalid_char;
2557   cat_code(null_code) = ignore;
2558
2559   for (k = '0'; k <= '9'; k++)
2560     math_code(k) = k + var_code;
2561
2562   for (k = 'A'; k <= 'Z'; k++)
2563   {
2564     cat_code(k) = letter;
2565     cat_code(k + 'a' - 'A') = letter;
2566     math_code(k) = k + var_code + 0x100;
2567     math_code(k + 'a' - 'A') = k + 'a' - 'A' + var_code + 0x100;
2568     lc_code(k) = k + 'a' - 'A';
2569     lc_code(k + 'a' - 'A') = k + 'a' - 'A';
2570     uc_code(k) = k;
2571     uc_code(k + 'a' - 'A') = k;
2572     sf_code(k) = 999;
2573   }
2574
2575   for (k = int_base; k <= del_code_base - 1; k++)
2576     eqtb[k].cint = 0;
2577
2578   mag = 1000;
2579   tolerance = 10000;
2580   hang_after = 1;
2581   max_dead_cycles = 25;
2582   escape_char = '\\';
2583   end_line_char = carriage_return;
2584
2585   for (k = 0; k <= 255; k++)
2586     del_code(k) = -1;
2587
2588   del_code('.') = 0;
2589
2590   for (k = dimen_base; k <= eqtb_size; k++)
2591     eqtb[k].cint = 0;
2592
2593   hash_used = frozen_control_sequence;
2594   cs_count = 0;
2595
2596   if (trace_flag)
2597     puts("initex cs_count = 0 ");
2598
2599   eq_type(frozen_dont_expand) = dont_expand;
2600   text(frozen_dont_expand) = 499;  /* notexpanded */
2601
2602   font_ptr                    = null_font;
2603   fmem_ptr                    = 7;
2604   font_name[null_font]        = 795; /* nullfont */
2605   font_area[null_font]        = 335; /* "" */
2606   hyphen_char[null_font]      = '-';
2607   skew_char[null_font]        = -1; 
2608   bchar_label[null_font]      = non_address;
2609   font_bchar[null_font]       = non_char;
2610   font_false_bchar[null_font] = non_char;
2611   font_bc[null_font]          = 1;
2612   font_ec[null_font]          = 0;
2613   font_size[null_font]        = 0;
2614   font_dsize[null_font]       = 0;
2615   char_base[null_font]        = 0;
2616   width_base[null_font]       = 0;
2617   height_base[null_font]      = 0;
2618   depth_base[null_font]       = 0;
2619   italic_base[null_font]      = 0;
2620   lig_kern_base[null_font]    = 0;
2621   kern_base[null_font]        = 0;
2622   exten_base[null_font]       = 0;
2623   font_glue[null_font]        = 0;
2624   font_params[null_font]      = 7;
2625   param_base[null_font]       = -1;
2626
2627   for (k = 0; k <= 6; k++)
2628     font_info[k].cint = 0;
2629
2630   reset_trie();
2631   text(frozen_protection) = 1184; /* "inaccessible" */
2632   format_ident = 1251;
2633   text(end_write) = 1290;
2634   eq_level(end_write) = level_one;
2635   eq_type(end_write) = outer_call;
2636   equiv(end_write) = 0;
2637 }
2638 #endif
2639
2640 #ifdef INITEX
2641 /* sec 0047 */
2642 boolean get_strings_started (void)
2643 {
2644   integer k;
2645   str_number g;
2646
2647   pool_ptr = 0;
2648   str_ptr = 0;
2649   str_start[0] = 0;
2650
2651   for (k = 0; k <= 255; k++)
2652   {
2653     if (((k < ' ') || (k > '~')))
2654     {
2655       append_char('^');
2656       append_char('^');
2657
2658       if (k < 64)
2659         append_char(k + 64);
2660       else
2661         if (k < 128)
2662           append_char(k - 64);
2663         else
2664         {
2665           append_lc_hex(k / 16);
2666           append_lc_hex(k % 16);
2667         }
2668     }
2669     else
2670       append_char(k);
2671
2672     g = make_string();
2673   }
2674
2675   g = load_pool_strings(pool_size - string_vacancies);
2676
2677   if (g == 0)
2678   {
2679     fprintf(stdout , "%s\n",  "! You have to increase POOLSIZE." );
2680     return false;
2681   }
2682
2683   return true;
2684 }
2685 #endif /* INITEX */
2686
2687 #ifdef INITEX
2688 /* sec 0131 */
2689 void sort_avail (void)
2690 {
2691   pointer p, q, r;
2692   pointer old_rover;
2693
2694   p = get_node(1073741824L); /* 2^30 merge adjacent free nodes */
2695   p = rlink(rover);
2696   rlink(rover) = empty_flag;
2697   old_rover = rover;
2698
2699   while (p != old_rover)
2700   {
2701     if (p < rover)
2702     {
2703       q = p;
2704       p = rlink(q);
2705       rlink(q) = rover;
2706       rover = q;
2707     }
2708     else
2709     {
2710       q = rover;
2711
2712       while (rlink(q) < p)
2713         q = rlink(q);
2714
2715       r = rlink(p);
2716       rlink(p) = rlink(q);
2717       rlink(q) = p;
2718       p = r;
2719     }
2720   }
2721
2722   p = rover;
2723
2724   while (rlink(p) != empty_flag)
2725   {
2726     llink(rlink(p)) = p;
2727     p = rlink(p);
2728   }
2729
2730   rlink(p) = rover;
2731   llink(rover) = p;
2732 }
2733 #endif
2734
2735 #ifdef INITEX
2736 /* sec 0264 */
2737 void primitive_ (str_number s, quarterword c, halfword o)
2738
2739   pool_pointer k;
2740   small_number j;
2741 /*  small_number l;  */
2742   int l; /* 95/Jan/7 */
2743
2744   if (s < 256)
2745     cur_val = s + single_base;
2746   else
2747   {
2748     k = str_start[s];
2749     l = str_start[s + 1] - k; /* small_number l */
2750
2751     for (j = 0; j <= l - 1; j++)
2752       buffer[j] = str_pool[k + j];
2753
2754     cur_val = id_lookup(0, l);
2755     flush_string();
2756
2757 #ifdef SHORTHASH
2758     if (s > 65535L)
2759       puts("ERROR: hash entry too large\n");
2760 #endif
2761
2762     text(cur_val) = s;
2763   }
2764
2765   eq_level(cur_val) = level_one;
2766   eq_type(cur_val) = c;
2767   equiv(cur_val) = o;
2768 }
2769 #endif
2770
2771 #ifdef INITEX
2772 /* sec 0944 */
2773 trie_op_code new_trie_op_ (small_number d, small_number n, trie_op_code v)
2774 {
2775   integer h;
2776   trie_op_code u;
2777   integer l;
2778
2779   h = abs(n + 313 * d + 361 * v + 1009 * cur_lang) % (trie_op_size + trie_op_size) + neg_trie_op_size;
2780
2781   while (true)
2782   {
2783     l = trie_op_hash[h];
2784
2785     if (l == 0)
2786     {
2787       if (trie_op_ptr == trie_op_size)
2788       {
2789         overflow("pattern memory ops", trie_op_size);
2790         return 0;     // abort_flag set
2791       }
2792
2793       u = trie_used[cur_lang];
2794
2795       if (u == max_trie_op)
2796       {
2797         overflow("pattern memory ops per language", max_trie_op - min_trie_op);
2798         return 0;     // abort_flag set
2799       }
2800
2801       incr(trie_op_ptr);
2802       incr(u);
2803       trie_used[cur_lang] = u;
2804
2805       if (u > max_op_used)
2806         max_op_used = u;
2807
2808       hyf_distance[trie_op_ptr] = d;
2809       hyf_num[trie_op_ptr] = n;
2810       hyf_next[trie_op_ptr] = v;
2811       trie_op_lang[trie_op_ptr] = cur_lang;
2812       trie_op_hash[h] = trie_op_ptr;
2813       trie_op_val[trie_op_ptr] = u;
2814       return u;
2815     }
2816
2817     if ((hyf_distance[l]== d) && (hyf_num[l]== n) && (hyf_next[l]== v) && (trie_op_lang[l]== cur_lang))
2818     {
2819       return trie_op_val[l];
2820     }
2821
2822     if (h > - (integer) trie_op_size)
2823       decr(h);
2824     else
2825       h = trie_op_size;
2826   }
2827 }
2828 /* sec 0948 */
2829 trie_pointer trie_node_ (trie_pointer p)
2830 {
2831   trie_pointer h;
2832   trie_pointer q;
2833
2834   /* the 1009, 2718, 3142 are hard-wired constants here (not hyphen_prime) */
2835   /* compute hash value */
2836   h = abs(trie_c[p] + 1009 * trie_o[p] + 2718 * trie_l[p] + 3142 * trie_r[p]) % trie_size;
2837
2838   while (true)
2839   {
2840     q = trie_hash[h];
2841
2842     if (q == 0)
2843     {
2844       trie_hash[h] = p;
2845       return p;
2846     }
2847
2848     if ((trie_c[q] == trie_c[p]) && (trie_o[q] == trie_o[p]) &&
2849       (trie_l[q] == trie_l[p]) && (trie_r[q] == trie_r[p]))
2850     {
2851       return q;
2852     }
2853
2854     if (h > 0)
2855       decr(h);
2856     else
2857       h = trie_size;
2858   }
2859 }
2860 /* sec 0949 */
2861 trie_pointer compress_trie_ (trie_pointer p)
2862 {
2863   if (p == 0)
2864     return 0;
2865   else
2866   {
2867     trie_l[p] = compress_trie(trie_l[p]);
2868     trie_r[p] = compress_trie(trie_r[p]);
2869     return trie_node(p);
2870   }
2871 }
2872 /* sec 0953 */
2873 void first_fit_ (trie_pointer p)
2874 {
2875   trie_pointer h;
2876   trie_pointer z;
2877   trie_pointer q;
2878   ASCII_code c;
2879   trie_pointer l, r;
2880   short ll;
2881
2882   c = trie_c[p];
2883   z = trie_min[c];
2884
2885   while (true)
2886   {
2887     h = z - c;
2888
2889     if (trie_max < h + 256)
2890     {
2891       if (trie_size <= h + 256)
2892       {
2893         overflow("pattern memory", trie_size);
2894 /*      not dynamic ---- but can be set -h=... from command line in ini-TeX */
2895         return;     // abort_flag set
2896       }
2897
2898       do
2899         {
2900           incr(trie_max);
2901           trie_taken[trie_max] = false;
2902           trie_trl[trie_max] = trie_max + 1;
2903           trie_tro[trie_max] = trie_max - 1;
2904         }
2905       while (!(trie_max == h + 256));
2906     }
2907
2908     if (trie_taken[h])
2909       goto lab45;
2910
2911     q = trie_r[p];
2912
2913     while (q > 0)
2914     {
2915       if (trie_trl[h + trie_c[q]] == 0)
2916         goto lab45;
2917
2918       q = trie_r[q];
2919     }
2920
2921     goto lab40;
2922 lab45:
2923     z = trie_trl[z];
2924   }
2925 lab40:
2926   trie_taken[h] = true; /* h may be used without ... */
2927   trie_hash[p] = h;
2928   q = p;
2929
2930   do
2931     {
2932       z = h + trie_c[q];
2933       l = trie_tro[z];
2934       r = trie_trl[z];
2935       trie_tro[r] = l;
2936       trie_trl[l] = r;
2937       trie_trl[z] = 0;
2938
2939       if (l < 256)
2940       {
2941         if (z < 256)
2942           ll = z;         /* short ll */
2943         else
2944           ll = 256;
2945
2946         do
2947           {
2948             trie_min[l] = r;
2949             incr(l);
2950           }
2951         while (!(l == ll));
2952       }
2953
2954       q = trie_r[q];
2955     }
2956   while (!(q == 0));
2957 }
2958 /* sec 0957 */
2959 void trie_pack_ (trie_pointer p)
2960 {
2961   trie_pointer q;
2962
2963   do
2964     {
2965       q = trie_l[p];
2966
2967       if ((q > 0) && (trie_hash[q]== 0))
2968       {
2969         first_fit(q);
2970         trie_pack(q);
2971       }
2972
2973       p = trie_r[p];
2974     }
2975   while (!(p == 0));
2976 }
2977 /* sec 0959 */
2978 void trie_fix_ (trie_pointer p)
2979 {
2980   trie_pointer q;
2981   ASCII_code c;
2982   trie_pointer z;
2983
2984   z = trie_hash[p];
2985
2986   do
2987     {
2988       q = trie_l[p];
2989       c = trie_c[p];
2990       trie_trl[z + c] = trie_hash[q];
2991       trie_trc[z + c] = c;
2992       trie_tro[z + c] = trie_o[p];
2993
2994       if (q > 0)
2995         trie_fix(q);
2996
2997       p = trie_r[p];
2998     }
2999   while (!(p == 0));
3000 }
3001 /* sec 0960 */
3002 void new_patterns (void)
3003 {
3004 /* ******************************************************************* */
3005 /*  was small_number k, l;  in 3.141 */
3006   char k, l;
3007 /* ******************************************************************* */
3008   boolean digitsensed;
3009   trie_op_code v;
3010   trie_pointer p, q;
3011   boolean firstchild;
3012 /*  ASCII_code c;  */
3013   int c;                /* 95/Jan/7 */
3014
3015   if (!trie_not_ready) /* new stuff */
3016   {
3017     if (allow_patterns)
3018     {
3019       if (trace_flag)
3020         puts("Resetting patterns\n");
3021
3022       reset_trie();         /* RESET PATTERNS -  93/Nov/26 */
3023
3024       if (reset_exceptions)
3025       {
3026         if (trace_flag)
3027           puts("Resetting exceptions\n");
3028
3029         reset_hyphen();     /* RESET HYPHENEXCEPTIONS -  93/Nov/26 */
3030       }
3031     }
3032   }
3033 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
3034   if (trie_not_ready)
3035   {
3036     set_cur_lang();
3037     scan_left_brace();
3038     k = 0;
3039     hyf[0] = 0;
3040     digitsensed = false;
3041
3042     while (true)
3043     {
3044       get_x_token();
3045
3046       switch (cur_cmd)
3047       {
3048         case letter:
3049         case other_char:
3050           if (digitsensed || (cur_chr < '0') || (cur_chr > '9'))
3051           {
3052             if (cur_chr == '.')
3053               cur_chr = 0;
3054             else
3055             {
3056               cur_chr = lc_code(cur_chr);
3057
3058               if (cur_chr == 0)
3059               {
3060                 print_err("Nonletter");
3061                 help1("(See Appendix H.)");
3062                 error();
3063               }
3064             }
3065
3066             if (k < 63)
3067             {
3068               incr(k);
3069               hc[k] = cur_chr;
3070               hyf[k] = 0;
3071               digitsensed = false;
3072             }
3073           }
3074           else if (k < 63)
3075           {
3076             hyf[k] = cur_chr - '0';
3077             digitsensed = true;
3078           }
3079           break;
3080         case spacer:
3081         case right_brace:
3082           {
3083             if (k > 0)
3084             {
3085               if (hc[1] == 0)
3086                 hyf[0] = 0;
3087
3088               if (hc[k] == 0)
3089                 hyf[k] = 0;
3090
3091               l = k;
3092               v = min_trie_op;
3093
3094               while (true) {
3095                 if (hyf[l]!= 0)
3096                   v = new_trie_op(k - l, hyf[l], v);
3097
3098                 if (l > 0)
3099                   decr(l);
3100                 else
3101                   goto lab31;
3102               }
3103 lab31:
3104               q = 0;
3105               hc[0] = cur_lang;
3106
3107               while (l <= k) {
3108                 c = hc[l];
3109                 incr(l);
3110                 p = trie_l[q];
3111                 firstchild = true;
3112
3113                 while ((p > 0) && (c > trie_c[p])) {
3114                   q = p;
3115                   p = trie_r[q];
3116                   firstchild = false;
3117                 }
3118
3119                 if ((p == 0) || (c < trie_c[p]))
3120                 {
3121                   if (trie_ptr == trie_size)
3122                   {
3123                     overflow("pattern memory", trie_size);  /* pattern memory - NOT DYNAMIC */
3124 /*      not dynamic ---- but can be set -h=... from command line in ini-TeX */
3125                     return;     // abort_flag set
3126                   }
3127
3128                   incr(trie_ptr);
3129                   trie_r[trie_ptr] = p;
3130                   p = trie_ptr;
3131                   trie_l[p] = 0;
3132
3133                   if (firstchild)
3134                     trie_l[q]= p;
3135                   else
3136                     trie_r[q]= p;
3137
3138                   trie_c[p] = c;
3139                   trie_o[p] = min_trie_op;
3140                 }
3141                 q = p;
3142               }
3143
3144               if (trie_o[q]!= min_trie_op)
3145               {
3146                 print_err("Duplicate pattern");
3147                 help1("(See Appendix H.)");
3148                 error();
3149               }
3150
3151               trie_o[q]= v;
3152             }
3153
3154             if (cur_cmd == right_brace)
3155               goto lab30;
3156
3157             k = 0;
3158             hyf[0] = 0;
3159             digitsensed = false;
3160           }
3161           break;
3162         default:
3163           {
3164             print_err("Bad ");
3165             print_esc("patterns");
3166             help1("(See Appendix H.)");
3167             error();
3168           }
3169           break;
3170       }
3171     }
3172 lab30:;
3173   }
3174   else
3175   {
3176     print_err("Too late for ");
3177     print_esc("patterns");
3178     help1("All patterns must be given before typesetting begins.");
3179     error();
3180     link(garbage) = scan_toks(false, false);
3181     flush_list(def_ref);
3182   }
3183 }
3184 /* sec 0966 */
3185 void init_trie (void)
3186 {
3187   trie_pointer p;
3188 /*  integer j, k, t;  */
3189   integer j, k;
3190   int t;                  /* 95/Jan/7 */
3191   trie_pointer r, s;
3192
3193   op_start[0] = - (integer) min_trie_op;
3194
3195   for (j = 1; j <= 255; j++)
3196   {
3197     op_start[j] = op_start[j - 1] + trie_used[j - 1];
3198   }
3199
3200   for (j = 1; j <= trie_op_ptr; j++)
3201   {
3202     trie_op_hash[j] = op_start[trie_op_lang[j]] + trie_op_val[j];
3203   }
3204
3205   for (j = 1; j <= trie_op_ptr; j++)
3206   {
3207     while (trie_op_hash[j] > j)
3208     {
3209       k = trie_op_hash[j];
3210       t = hyf_distance[k];
3211       hyf_distance[k] = hyf_distance[j];
3212       hyf_distance[j] = t;
3213       t = hyf_num[k];
3214       hyf_num[k] = hyf_num[j];
3215       hyf_num[j] = t;
3216       t = hyf_next[k];
3217       hyf_next[k] = hyf_next[j];
3218       hyf_next[j]= t;
3219       trie_op_hash[j] = trie_op_hash[k];
3220       trie_op_hash[k] = k;
3221     }
3222   }
3223
3224   for (p = 0; p <= trie_size; p++)
3225   {
3226     trie_hash[p] = 0;
3227   }
3228
3229   trie_l[0] = compress_trie(trie_l[0]);
3230
3231   for (p = 0; p <= trie_ptr; p++)
3232   {
3233     trie_hash[p]= 0;
3234   }
3235
3236   for (p = 0; p <= 255; p++)
3237   {
3238     trie_min[p] = p + 1;
3239   }
3240
3241   trie_trl[0] = 1;
3242   trie_max = 0;
3243
3244   if (trie_l[0] != 0)
3245   {
3246     first_fit(trie_l[0]);
3247     trie_pack(trie_l[0]);
3248   }
3249
3250   if (trie_l[0] == 0)
3251   {
3252     for (r = 0; r <= 256; r++)
3253     {
3254       trie_trl[r] = 0;
3255       trie_tro[r] = min_trie_op;
3256       trie_trc[r] = 0;
3257     }
3258     trie_max = 256;
3259   }
3260   else
3261   {
3262     trie_fix(trie_l[0]);
3263     r = 0;
3264
3265     do
3266       {
3267         s = trie_trl[r];
3268         {
3269           trie_trl[r] = 0;
3270           trie_tro[r] = min_trie_op;
3271           trie_trc[r] = 0;
3272         }
3273
3274         r = s;
3275       }
3276     while (!(r > trie_max));
3277   }
3278
3279   trie_trc[0] = 63;
3280   trie_not_ready = false;
3281 }
3282 #endif /* INITEX */
3283
3284 #ifdef INITEX
3285 /* sec 1302 */
3286 void store_fmt_file (void)
3287 {
3288   integer j, k, l;
3289   pointer p, q;
3290   integer x;
3291
3292   if (!is_initex)
3293   {
3294     puts("! \\dump is performed only by INITEX\n");
3295
3296     if (!knuth_flag)
3297       puts("  (Use -i on the command line)\n");
3298
3299     abort_flag++;
3300     return;
3301   }
3302
3303   if (save_ptr != 0)
3304   {
3305     print_err("You can't dump inside a group");
3306     help1("`{...\\dump}' is a no-no.");
3307     succumb();
3308   }
3309
3310   selector = new_string;
3311   print_string(" (format=");
3312   print(job_name);
3313   print_char(' ');
3314   print_int(year);
3315   print_char('.');
3316   print_int(month);
3317   print_char('.');
3318   print_int(day);
3319   print_char(')');
3320
3321   if (interaction == 0)
3322     selector = log_only;
3323   else
3324     selector = term_and_log;
3325
3326   str_room(1);
3327   format_ident = make_string();
3328   pack_job_name(".fmt");
3329
3330   while (!w_open_out(fmt_file))
3331   {
3332     prompt_file_name("format file name", ".fmt");
3333   }
3334
3335   print_nl("Beginning to dump on file ");
3336   slow_print(w_make_name_string(fmt_file));
3337   flush_string();
3338   print_nl("");
3339   slow_print(format_ident);
3340
3341   dump_int(BEGINFMTCHECKSUM);
3342   dump_int(mem_bot);
3343   dump_int(mem_top);
3344   dump_int(eqtb_size);
3345   dump_int(hash_prime);
3346   dump_int(hyphen_prime);
3347   dump_int(pool_ptr);
3348   dump_int(str_ptr);
3349
3350   if (dumpthings(str_start[0], str_ptr + 1))
3351     return;
3352
3353   if (dumpthings(str_pool[0], pool_ptr))
3354     return;
3355
3356   print_ln();
3357   print_int(str_ptr);
3358   print_string(" strings of total length ");
3359   print_int(pool_ptr);
3360
3361   sort_avail();
3362   var_used = 0;
3363   dump_int(lo_mem_max);
3364   dump_int(rover);
3365   p = 0;
3366   q = rover;
3367   x = 0;
3368
3369   do
3370     {
3371       if (dumpthings(mem[p], q + 2 - p))
3372         return;
3373
3374       x = x + q + 2 - p;
3375       var_used = var_used + q - p;
3376       p = q + node_size(q);
3377       q = rlink(q);
3378     }
3379   while (!(q == rover));
3380
3381   var_used = var_used + lo_mem_max - p;
3382   dyn_used = mem_end + 1 - hi_mem_min;
3383
3384   if (dumpthings(mem[p], lo_mem_max + 1 - p))
3385     return;
3386
3387   x = x + lo_mem_max + 1 - p;
3388   dump_int(hi_mem_min);
3389   dump_int(avail); 
3390
3391   if (dumpthings(mem[hi_mem_min], mem_end + 1 - hi_mem_min))
3392     return;
3393
3394   x = x + mem_end + 1 - hi_mem_min;
3395   p = avail;
3396
3397   while (p != 0)
3398   {
3399     decr(dyn_used);
3400     p = mem[p].hh.rh;
3401   }
3402
3403   dump_int(var_used);
3404   dump_int(dyn_used);
3405   print_ln();
3406   print_int(x);
3407   print_string(" memory locations dumped; current usage is ");
3408   print_int(var_used);
3409   print_char('&');
3410   print_int(dyn_used);
3411
3412   k = active_base;
3413
3414   do
3415     {
3416       j = k;
3417
3418       while (j < (int_base - 1))
3419       {
3420         if ((equiv(j) == equiv(j + 1)) &&
3421           (eq_type(j) == eq_type(j + 1)) &&
3422           (eq_level(j) == eq_level(j + 1)))
3423           goto lab41;
3424         incr(j);
3425       }
3426
3427       l = (int_base);
3428       goto lab31;
3429 lab41:
3430       incr(j);
3431       l = j;
3432       while (j < (int_base - 1))
3433       {
3434         if ((equiv(j) != equiv(j + 1)) ||
3435           (eq_type(j) != eq_type(j + 1)) ||
3436           (eq_level(j) != eq_level(j + 1)))
3437           goto lab31;
3438         incr(j);
3439       }
3440 lab31:
3441       dump_int(l - k);
3442
3443       if (dumpthings(eqtb[k], l - k))
3444         return;
3445
3446       k = j + 1;
3447       dump_int(k - l);
3448     }
3449   while (!(k == (int_base)));
3450
3451   do
3452     {
3453       j = k;
3454
3455       while (j < (eqtb_size))
3456       {
3457         if (eqtb[j].cint == eqtb[j + 1].cint)
3458           goto lab42;
3459         incr(j);
3460       }
3461
3462       l = (eqtb_size + 1);
3463       goto lab32;
3464 lab42:
3465       incr(j);
3466       l = j;
3467
3468       while (j < (eqtb_size))
3469       {
3470         if (eqtb[j].cint != eqtb[j + 1].cint)
3471           goto lab32;
3472         incr(j);
3473       }
3474 lab32:
3475       dump_int(l - k);
3476
3477       if (dumpthings(eqtb[k], l - k))
3478         return;
3479
3480       k = j + 1;
3481       dump_int(k - l);
3482     }
3483   while (!(k > (eqtb_size)));
3484
3485   dump_int(par_loc);
3486   dump_int(write_loc);
3487
3488   dump_int(hash_used);
3489   cs_count = frozen_control_sequence - 1 - hash_used;
3490
3491   if (trace_flag)
3492     printf("itex cs_count %d hash_size %d hash_extra %d hash_used %d",
3493         cs_count, hash_size, hash_extra, hash_used);
3494
3495   for (p = hash_base; p <= hash_used; p++)
3496   {
3497     if (text(p) != 0)
3498     {
3499       dump_int(p);
3500       dump_hh(hash[p]);
3501       incr(cs_count);
3502
3503       if (trace_flag)
3504         puts("itex cs_count++ ");
3505     }
3506   }
3507
3508   if (dumpthings(hash[hash_used + 1], undefined_control_sequence - 1 - hash_used))
3509     return;
3510
3511   dump_int(cs_count);
3512   print_ln();
3513   print_int(cs_count);
3514   print_string(" multiletter control sequences");
3515
3516   dump_int(fmem_ptr);
3517
3518   {
3519     if (dumpthings(font_info[0], fmem_ptr))
3520       return;
3521
3522     dump_int(font_ptr);
3523
3524     if (dumpthings(font_check[0], font_ptr + 1))
3525       return;
3526
3527     if (dumpthings(font_size[0], font_ptr + 1))
3528       return;
3529
3530     if (dumpthings(font_dsize[0], font_ptr + 1))
3531       return;
3532
3533     if (dumpthings(font_params[0], font_ptr + 1))
3534       return;
3535
3536     if (dumpthings(hyphen_char[0], font_ptr + 1))
3537       return;
3538
3539     if (dumpthings(skew_char[0], font_ptr + 1))
3540       return;
3541
3542     if (dumpthings(font_name[0], font_ptr + 1))
3543       return;
3544
3545     if (dumpthings(font_area[0], font_ptr + 1))
3546       return;
3547
3548     if (dumpthings(font_bc[0], font_ptr + 1))
3549       return;
3550
3551     if (dumpthings(font_ec[0], font_ptr + 1))
3552       return;
3553
3554     if (dumpthings(char_base[0], font_ptr + 1))
3555       return;
3556
3557     if (dumpthings(width_base[0], font_ptr + 1))
3558       return;
3559
3560     if (dumpthings(height_base[0], font_ptr + 1))
3561       return;
3562
3563     if (dumpthings(depth_base[0], font_ptr + 1))
3564       return;
3565
3566     if (dumpthings(italic_base[0], font_ptr + 1))
3567       return;
3568
3569     if (dumpthings(lig_kern_base[0], font_ptr + 1))
3570       return;
3571
3572     if (dumpthings(kern_base[0], font_ptr + 1))
3573       return;
3574
3575     if (dumpthings(exten_base[0], font_ptr + 1))
3576       return;
3577
3578     if (dumpthings(param_base[0], font_ptr + 1))
3579       return;
3580
3581     if (dumpthings(font_glue[0], font_ptr + 1))
3582       return;
3583
3584     if (dumpthings(bchar_label[0], font_ptr + 1))
3585       return;
3586
3587     if (dumpthings(font_bchar[0], font_ptr + 1))
3588       return;
3589
3590     if (dumpthings(font_false_bchar[0], font_ptr + 1))
3591       return;
3592
3593     for (k = 0; k <= font_ptr; k++)
3594     {
3595       print_nl("\\font");
3596       print_esc("");
3597       print(font_id_text(k));
3598       print_char('=');
3599       print_file_name(font_name[k], font_area[k], 335);
3600
3601       if (font_size[k] != font_dsize[k])
3602       {
3603         print_string(" at ");
3604         print_scaled(font_size[k]);
3605         print_string("pt");
3606       }
3607     }
3608   }
3609
3610   print_ln();
3611   print_int(fmem_ptr - 7);
3612   print_string(" words of font info for ");
3613   print_int(font_ptr - 0);
3614   print_string(" preloaded font");
3615
3616   if (font_ptr != 1)
3617     print_char('s');
3618
3619   dump_int(hyph_count);
3620
3621   for (k = 0; k <= hyphen_prime; k++)
3622   {
3623     if (hyph_word[k]!= 0)
3624     {
3625       dump_int(k);
3626       dump_int(hyph_word[k]);
3627       dump_int(hyph_list[k]);
3628     }
3629   }
3630
3631   print_ln();
3632   print_int(hyph_count);
3633   print_string(" hyphenation exception");
3634
3635   if (hyph_count != 1)
3636     print_char('s');
3637
3638   if (trie_not_ready)
3639     init_trie();
3640
3641   dump_int(trie_max);
3642
3643   if (dumpthings(trie_trl[0], trie_max + 1))
3644     return;
3645
3646   if (dumpthings(trie_tro[0], trie_max + 1))
3647     return;
3648
3649   if (dumpthings(trie_trc[0], trie_max + 1))
3650     return;
3651
3652   dump_int(trie_op_ptr);
3653
3654   if (dumpthings(hyf_distance[1], trie_op_ptr))
3655     return;
3656
3657   if (dumpthings(hyf_num[1], trie_op_ptr))
3658     return;
3659
3660   if (dumpthings(hyf_next[1], trie_op_ptr))
3661     return;
3662
3663   print_nl("Hyphenation trie of length ");
3664   print_int(trie_max);
3665   print_string(" has ");
3666   print_int(trie_op_ptr);
3667   print_string(" op");
3668
3669   if (trie_op_ptr != 1)
3670     print_char('s');
3671
3672   print_string(" out of ");
3673   print_int(trie_op_size);
3674
3675   for (k = 255; k >= 0; k--)
3676   {
3677     if (trie_used[k] > 0)
3678     {
3679       print_nl("  ");
3680       print_int(trie_used[k]);
3681       print_string(" for language ");
3682       print_int(k);
3683       dump_int(k);
3684       dump_int(trie_used[k]);
3685     }
3686   }
3687
3688   dump_int(interaction);
3689   dump_int(format_ident);
3690   dump_int(ENDFMTCHECKSUM);
3691   tracing_stats = 0;
3692
3693 #ifdef COMPACTFORMAT
3694   gzclose(gz_fmt_file);
3695 #else
3696   w_close(fmt_file);
3697 #endif
3698 }
3699 #endif
3700
3701 #ifdef INITEX
3702 /* sec 01336 */
3703 void init_prim (void)
3704 {
3705   no_new_control_sequence = false;
3706   primitive("lineskip", assign_glue, glue_base + line_skip_code);
3707   primitive("baselineskip", assign_glue, glue_base + baseline_skip_code);
3708   primitive("parskip", assign_glue, glue_base + par_skip_code);
3709   primitive("abovedisplayskip", assign_glue, glue_base + above_display_skip_code);
3710   primitive("belowdisplayskip", assign_glue, glue_base + below_display_skip_code);
3711   primitive("abovedisplayshortskip", assign_glue, glue_base + above_display_short_skip_code);
3712   primitive("belowdisplayshortskip", assign_glue, glue_base + below_display_short_skip_code);
3713   primitive("leftskip", assign_glue, glue_base + left_skip_code);
3714   primitive("rightskip", assign_glue, glue_base + right_skip_code);
3715   primitive("topskip", assign_glue, glue_base + top_skip_code);
3716   primitive("splittopskip", assign_glue, glue_base + split_top_skip_code);
3717   primitive("tabskip", assign_glue, glue_base + tab_skip_code);
3718   primitive("spaceskip", assign_glue, glue_base + space_skip_code);
3719   primitive("xspaceskip", assign_glue, glue_base + xspace_skip_code);
3720   primitive("parfillskip", assign_glue, glue_base + par_fill_skip_code);
3721   primitive("thinmuskip", assign_mu_glue, glue_base + thin_mu_skip_code);
3722   primitive("medmuskip", assign_mu_glue, glue_base + med_mu_skip_code);
3723   primitive("thickmuskip", assign_mu_glue, glue_base + thick_mu_skip_code);
3724   primitive("output", assign_toks, output_routine_loc);
3725   primitive("everypar", assign_toks, every_par_loc);
3726   primitive("everymath", assign_toks, every_math_loc);
3727   primitive("everydisplay", assign_toks, every_display_loc);
3728   primitive("everyhbox", assign_toks, every_hbox_loc);
3729   primitive("everyvbox", assign_toks, every_vbox_loc);
3730   primitive("everyjob", assign_toks, every_job_loc);
3731   primitive("everycr", assign_toks, every_cr_loc);
3732   primitive("errhelp", assign_toks, err_help_loc);
3733   primitive("pretolerance", assign_int, int_base + pretolerance_code);
3734   primitive("tolerance", assign_int, int_base + tolerance_code);
3735   primitive("linepenalty", assign_int, int_base + line_penalty_code);
3736   primitive("hyphenpenalty", assign_int, int_base + hyphen_penalty_code);
3737   primitive("exhyphenpenalty", assign_int, int_base + ex_hyphen_penalty_code);
3738   primitive("clubpenalty", assign_int, int_base + club_penalty_code);
3739   primitive("widowpenalty", assign_int, int_base + widow_penalty_code);
3740   primitive("displaywidowpenalty", assign_int, int_base + display_widow_penalty_code);
3741   primitive("brokenpenalty", assign_int, int_base + broken_penalty_code);
3742   primitive("binoppenalty", assign_int, int_base + bin_op_penalty_code);
3743   primitive("relpenalty", assign_int, int_base + rel_penalty_code);
3744   primitive("predisplaypenalty", assign_int, int_base + pre_display_penalty_code);
3745   primitive("postdisplaypenalty", assign_int, int_base + post_display_penalty_code);
3746   primitive("interlinepenalty", assign_int, int_base + inter_line_penalty_code);
3747   primitive("doublehyphendemerits", assign_int, int_base + double_hyphen_demerits_code);
3748   primitive("finalhyphendemerits", assign_int, int_base + final_hyphen_demerits_code);
3749   primitive("adjdemerits", assign_int, int_base + adj_demerits_code);
3750   primitive("mag", assign_int, int_base + mag_code);
3751   primitive("delimiterfactor", assign_int, int_base + delimiter_factor_code);
3752   primitive("looseness", assign_int, int_base + looseness_code);
3753   primitive("time", assign_int, int_base + time_code);
3754   primitive("day", assign_int, int_base + day_code);
3755   primitive("month", assign_int, int_base + month_code);
3756   primitive("year", assign_int, int_base + year_code);
3757   primitive("showboxbreadth", assign_int, int_base + show_box_breadth_code);
3758   primitive("showboxdepth", assign_int, int_base + show_box_depth_code);
3759   primitive("hbadness", assign_int, int_base + hbadness_code);
3760   primitive("vbadness", assign_int, int_base + vbadness_code);
3761   primitive("pausing", assign_int, int_base + pausing_code);
3762   primitive("tracingonline", assign_int, int_base + tracing_online_code);
3763   primitive("tracingmacros", assign_int, int_base + tracing_macros_code);
3764   primitive("tracingstats", assign_int, int_base + tracing_stats_code);
3765   primitive("tracingparagraphs", assign_int, int_base + tracing_paragraphs_code);
3766   primitive("tracingpages", assign_int, int_base + tracing_pages_code);
3767   primitive("tracingoutput", assign_int, int_base + tracing_output_code);
3768   primitive("tracinglostchars", assign_int, int_base + tracing_lost_chars_code);
3769   primitive("tracingcommands", assign_int, int_base + tracing_commands_code);
3770   primitive("tracingrestores", assign_int, int_base + tracing_restores_code);
3771   primitive("uchyph", assign_int, int_base + uc_hyph_code);
3772   primitive("outputpenalty", assign_int, int_base + output_penalty_code);
3773   primitive("maxdeadcycles", assign_int, int_base + max_dead_cycles_code);
3774   primitive("hangafter", assign_int, int_base + hang_after_code);
3775   primitive("floatingpenalty", assign_int, int_base + floating_penalty_code);
3776   primitive("globaldefs", assign_int, int_base + global_defs_code);
3777   primitive("fam", assign_int, int_base + cur_fam_code);
3778   primitive("escapechar", assign_int, int_base + escape_char_code);
3779   primitive("defaulthyphenchar", assign_int, int_base + default_hyphen_char_code);
3780   primitive("defaultskewchar", assign_int, int_base + default_skew_char_code);
3781   primitive("endlinechar", assign_int, int_base + end_line_char_code);
3782   primitive("newlinechar", assign_int, int_base + new_line_char_code);
3783   primitive("language", assign_int, int_base + language_code);
3784   primitive("lefthyphenmin", assign_int, int_base + left_hyphen_min_code);
3785   primitive("righthyphenmin", assign_int, int_base + right_hyphen_min_code);
3786   primitive("holdinginserts", assign_int, int_base + holding_inserts_code);
3787   primitive("errorcontextlines", assign_int, int_base + error_context_lines_code);
3788   primitive("parindent", assign_dimen, dimen_base + par_indent_code);
3789   primitive("mathsurround", assign_dimen, dimen_base + math_surround_code);
3790   primitive("lineskiplimit", assign_dimen, dimen_base + line_skip_limit_code);
3791   primitive("hsize", assign_dimen, dimen_base + hsize_code);
3792   primitive("vsize", assign_dimen, dimen_base + vsize_code);
3793   primitive("maxdepth", assign_dimen, dimen_base + max_depth_code);
3794   primitive("splitmaxdepth", assign_dimen, dimen_base + split_max_depth_code);
3795   primitive("boxmaxdepth", assign_dimen, dimen_base + box_max_depth_code);
3796   primitive("hfuzz", assign_dimen, dimen_base + hfuzz_code);
3797   primitive("vfuzz", assign_dimen, dimen_base + vfuzz_code);
3798   primitive("delimitershortfall", assign_dimen, dimen_base + delimiter_shortfall_code);
3799   primitive("nulldelimiterspace", assign_dimen, dimen_base + null_delimiter_space_code);
3800   primitive("scriptspace", assign_dimen, dimen_base + script_space_code);
3801   primitive("predisplaysize", assign_dimen, dimen_base + pre_display_size_code);
3802   primitive("displaywidth", assign_dimen, dimen_base + display_width_code);
3803   primitive("displayindent", assign_dimen, dimen_base + display_indent_code);
3804   primitive("overfullrule", assign_dimen, dimen_base + overfull_rule_code);
3805   primitive("hangindent", assign_dimen, dimen_base + hang_indent_code);
3806   primitive("hoffset", assign_dimen, dimen_base + h_offset_code);
3807   primitive("voffset", assign_dimen, dimen_base + v_offset_code);
3808   primitive("emergencystretch", assign_dimen, dimen_base + emergency_stretch_code);
3809   primitive(" ", ex_space, 0);
3810   primitive("/", ital_corr, 0);
3811   primitive("accent", accent, 0);
3812   primitive("advance", advance, 0);
3813   primitive("afterassignment", after_assignment, 0);
3814   primitive("aftergroup", after_group, 0);
3815   primitive("begingroup", begin_group, 0);
3816   primitive("char", char_num, 0);
3817   primitive("csname", cs_name, 0);
3818   primitive("delimiter", delim_num, 0);
3819   primitive("divide", divide, 0);
3820   primitive("endcsname", end_cs_name, 0);
3821   primitive("endgroup", end_group, 0);
3822   text(frozen_end_group) = make_string_pool("endgroup");
3823   eqtb[frozen_end_group] = eqtb[cur_val]; 
3824   primitive("expandafter", expand_after, 0);
3825   primitive("font", def_font, 0);
3826   primitive("fontdimen", assign_font_dimen, 0);
3827   primitive("halign", halign, 0);
3828   primitive("hrule", hrule, 0);
3829   primitive("ignorespaces", ignore_spaces, 0);
3830   primitive("insert", insert, 0);
3831   primitive("mark", mark, 0);
3832   primitive("mathaccent", math_accent, 0);
3833   primitive("mathchar", math_char_num, 0);
3834   primitive("mathchoice", math_choice, 0);
3835   primitive("multiply", multiply, 0);
3836   primitive("noalign", no_align, 0);
3837   primitive("noboundary", no_boundary, 0);
3838   primitive("noexpand", no_expand, 0);
3839   primitive("nonscript", non_script, 0);
3840   primitive("omit", omit, 0);
3841   primitive("parshape", set_shape, 0);
3842   primitive("penalty", break_penalty, 0);
3843   primitive("prevgraf", set_prev_graf, 0);
3844   primitive("radical", radical, 0);
3845   primitive("read", read_to_cs, 0);
3846   primitive("relax", relax, 256);
3847   text(frozen_relax) = make_string_pool("relax");
3848   eqtb[frozen_relax] = eqtb[cur_val];
3849   primitive("setbox", set_box, 0);
3850   primitive("the", the, 0);
3851   primitive("toks", toks_register, 0);
3852   primitive("vadjust", vadjust, 0);
3853   primitive("valign", valign, 0);
3854   primitive("vcenter", vcenter, 0);
3855   primitive("vrule", vrule, 0);
3856   primitive("par", par_end, 256);
3857   par_loc = cur_val; 
3858   par_token = cs_token_flag + par_loc;
3859   primitive("input", input, 0);
3860   primitive("endinput", input, 1);
3861   primitive("topmark", top_bot_mark, 0);
3862   primitive("firstmark", top_bot_mark, 1);
3863   primitive("botmark", top_bot_mark, 2);
3864   primitive("splitfirstmark", top_bot_mark, 3);
3865   primitive("splitbotmark", top_bot_mark, 4);
3866   primitive("count", tex_register, 0);
3867   primitive("dimen", tex_register, 1);
3868   primitive("skip", tex_register, 2);
3869   primitive("muskip", tex_register, 3);
3870   primitive("spacefactor", set_aux, 102);
3871   primitive("prevdepth", set_aux, 1);
3872   primitive("deadcycles", set_page_int, 0);
3873   primitive("insertpenalties", set_page_int, 1);
3874   primitive("wd", set_box_dimen, 1);
3875   primitive("ht", set_box_dimen, 3);
3876   primitive("dp", set_box_dimen, 2);
3877   primitive("lastpenalty", last_item, 0);
3878   primitive("lastkern", last_item, 1);
3879   primitive("lastskip", last_item, 2);
3880   primitive("inputlineno", last_item, 3);
3881   primitive("badness", last_item, 4);
3882   primitive("number", convert, 0);
3883   primitive("romannumeral", convert, 1);
3884   primitive("string", convert, 2);
3885   primitive("meaning", convert, 3);
3886   primitive("fontname", convert, 4);
3887   primitive("jobname", convert, 5);
3888   primitive("if", if_test, 0);
3889   primitive("ifcat", if_test, 1);
3890   primitive("ifnum", if_test, 2);
3891   primitive("ifdim", if_test, 3);
3892   primitive("ifodd", if_test, 4);
3893   primitive("ifvmode", if_test, 5);
3894   primitive("ifhmode", if_test, 6);
3895   primitive("ifmmode", if_test, 7);
3896   primitive("ifinner", if_test, 8);
3897   primitive("ifvoid", if_test, 9);
3898   primitive("ifhbox", if_test, 10);
3899   primitive("ifvbox", if_test, 11);
3900   primitive("ifx", if_test, 12);
3901   primitive("ifeof", if_test, 13);
3902   primitive("iftrue", if_test, 14);
3903   primitive("iffalse", if_test, 15);
3904   primitive("ifcase", if_test, 16);
3905   primitive("fi", fi_or_else, 2);
3906   text(frozen_fi) = make_string_pool("fi");
3907   eqtb[frozen_fi] = eqtb[cur_val];
3908   primitive("or", fi_or_else, 4);
3909   primitive("else", fi_or_else, 3);
3910   primitive("nullfont", set_font, 0);
3911   text(frozen_null_font) = 795;
3912   eqtb[frozen_null_font] = eqtb[cur_val];
3913   primitive("span", tab_mark, 256);
3914   primitive("cr", car_ret, 257);
3915   text(frozen_cr) = make_string_pool("cr");
3916   eqtb[frozen_cr] = eqtb[cur_val];
3917   primitive("crcr", car_ret, 258);
3918   text(frozen_end_template) = make_string_pool("endtemplate");
3919   text(frozen_endv) = make_string_pool("endtemplate");
3920   eq_type(frozen_endv) = endv;
3921   equiv(frozen_endv) = null_list; 
3922   eq_level(frozen_endv) = level_one; 
3923   eqtb[frozen_end_template] = eqtb[frozen_endv]; 
3924   eq_type(frozen_end_template) = end_template;
3925   primitive("pagegoal", set_page_dimen, 0);
3926   primitive("pagetotal", set_page_dimen, 1);
3927   primitive("pagestretch", set_page_dimen, 2);
3928   primitive("pagefilstretch", set_page_dimen, 3);
3929   primitive("pagefillstretch", set_page_dimen, 4);
3930   primitive("pagefilllstretch", set_page_dimen, 5);
3931   primitive("pageshrink", set_page_dimen, 6);
3932   primitive("pagedepth", set_page_dimen, 7);
3933   primitive("end", end_match, 0);
3934   primitive("dump", stop, 1);
3935   primitive("hskip", hskip, 4);
3936   primitive("hfil", hskip, 0);
3937   primitive("hfill", hskip, 1);
3938   primitive("hss", hskip, 2);
3939   primitive("hfilneg", hskip, 3);
3940   primitive("vskip", vskip, 4);
3941   primitive("vfil", vskip, 0);
3942   primitive("vfill", vskip, 1);
3943   primitive("vss", vskip, 2);
3944   primitive("vfilneg", vskip, 3);
3945   primitive("mskip", mskip, 5);
3946   primitive("kern", kern, 1);
3947   primitive("mkern", mkern, 99);
3948   primitive("moveleft", hmove, 1);
3949   primitive("moveright", hmove, 0);
3950   primitive("raise", vmove, 1);
3951   primitive("lower", vmove, 0);
3952   primitive("box", make_box, 0);
3953   primitive("copy", make_box, 1);
3954   primitive("lastbox", make_box, 2);
3955   primitive("vsplit", make_box, 3);
3956   primitive("vtop", make_box, 4);
3957   primitive("vbox", make_box, 5);
3958   primitive("hbox", make_box, 106);
3959   primitive("shipout", leader_ship, 99);
3960   primitive("leaders", leader_ship, 100);
3961   primitive("cleaders", leader_ship, 101);
3962   primitive("xleaders", leader_ship, 102);
3963   primitive("indent", start_par, 1);
3964   primitive("noindent", start_par, 0);
3965   primitive("unpenalty", remove_item, 12);
3966   primitive("unkern", remove_item, 11);
3967   primitive("unskip", remove_item, 10);
3968   primitive("unhbox", un_hbox, 0);
3969   primitive("unhcopy", un_hbox, 1);
3970   primitive("unvbox", un_vbox, 0);
3971   primitive("unvcopy", un_vbox, 1);
3972   primitive("-", discretionary, 1);
3973   primitive("discretionary", discretionary, 0);
3974   primitive("eqno", eq_no, 0);
3975   primitive("leqno", eq_no, 1);
3976   primitive("mathord", math_comp, 16);
3977   primitive("mathop", math_comp, 17);
3978   primitive("mathbin", math_comp, 18);
3979   primitive("mathrel", math_comp, 19);
3980   primitive("mathopen", math_comp, 20);
3981   primitive("mathclose", math_comp, 21);
3982   primitive("mathpunct", math_comp, 22);
3983   primitive("mathinner", math_comp, 23);
3984   primitive("underline", math_comp, 26);
3985   primitive("overline", math_comp, 27);
3986   primitive("displaylimits", limit_switch, 0);
3987   primitive("limits", limit_switch, 1);
3988   primitive("nolimits", limit_switch, 2);
3989   primitive("displaystyle", math_style, 0);
3990   primitive("textstyle", math_style, 2);
3991   primitive("scriptstyle", math_style, 4);
3992   primitive("scriptscriptstyle", math_style, 6);
3993   primitive("above", above, 0);
3994   primitive("over", above, 1);
3995   primitive("atop", above, 2);
3996   primitive("abovewithdelims", above, 3);
3997   primitive("overwithdelims", above, 4);
3998   primitive("atopwithdelims", above, 5);
3999   primitive("left", left_right, 30);
4000   primitive("right", left_right, 31);
4001   text(frozen_right) = make_string_pool("right");
4002   eqtb[frozen_right] = eqtb[cur_val]; 
4003   primitive("long", prefix, 1);
4004   primitive("outer", prefix, 2);
4005   primitive("global", prefix, 4);
4006   primitive("def", def, 0);
4007   primitive("gdef", def, 1);
4008   primitive("edef", def, 2);
4009   primitive("xdef", def, 3);
4010   primitive("let", let, 0);
4011   primitive("futurelet", let, 1);
4012   primitive("chardef", shorthand_def, 0);
4013   primitive("mathchardef", shorthand_def, 1);
4014   primitive("countdef", shorthand_def, 2);
4015   primitive("dimendef", shorthand_def, 3);
4016   primitive("skipdef", shorthand_def, 4);
4017   primitive("muskipdef", shorthand_def, 5);
4018   primitive("toksdef", shorthand_def, 6);
4019   primitive("catcode", def_code, cat_code_base);
4020   primitive("mathcode", def_code, math_code_base);
4021   primitive("lccode", def_code, lc_code_base);
4022   primitive("uccode", def_code, uc_code_base);
4023   primitive("sfcode", def_code, sf_code_base);
4024   primitive("delcode", def_code, (hash_size + 3474));
4025   primitive("textfont", def_family, (hash_size + 1835));
4026   primitive("scriptfont", def_family, (hash_size + 1851));
4027   primitive("scriptscriptfont", def_family, (hash_size + 1867));
4028   primitive("hyphenation", hyph_data, 0);
4029   primitive("patterns", hyph_data, 1);
4030   primitive("hyphenchar", assign_font_int, 0);
4031   primitive("skewchar", assign_font_int, 1);
4032   primitive("batchmode", set_interaction, 0);
4033   primitive("nonstopmode", set_interaction, 1);
4034   primitive("scrollmode", set_interaction, 2);
4035   primitive("errorstopmode", set_interaction, 3);
4036   primitive("openin", in_stream, 1);
4037   primitive("closein", in_stream, 0);
4038   primitive("message", message, 0);
4039   primitive("errmessage", message, 1);
4040   primitive("lowercase", case_shift, (hash_size + 2139));
4041   primitive("uppercase", case_shift, (hash_size + 2395));
4042   primitive("show", xray, 0);
4043   primitive("showbox", xray, 1);
4044   primitive("showthe", xray, 2);
4045   primitive("showlists", xray, 3);
4046   primitive("openout", extension, 0);
4047   primitive("write", extension, 1);
4048   write_loc = cur_val;
4049   primitive("closeout", extension, 2);
4050   primitive("special", extension, 3);
4051   primitive("immediate", extension, 4);
4052   primitive("setlanguage", extension, 5);
4053   no_new_control_sequence = true; 
4054 }
4055 #endif