OSDN Git Service

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