OSDN Git Service

cur_input.name_field -> name.
[putex/putex.git] / src / texsourc / itex.c
index 32b1539..b564aba 100644 (file)
@@ -24,7 +24,7 @@
 #define BEGINFMTCHECKSUM 367403084L
 #define ENDFMTCHECKSUM   69069L
 
-extern clock_t start_time, main_time, finish_time; /* in local.c */
+extern clock_t start_time, main_time, finish_time;
 
 #ifdef INITEX
   void do_initex (void);
@@ -109,15 +109,12 @@ void initialize (void)
 
     if (flag)
     {
-      show_line("Inverted mapping xord[] pairs:\n", 0);
+      puts("Inverted mapping xord[] pairs:\n");
 
       for (k = 0; k < 256; k++)
       {
         if (xord[k] != 127)
-        {
-          sprintf(log_line, "%d => %d\n", k, xord[k]);
-          show_line(log_line, 0);
-        }
+          printf("%d => %d\n", k, xord[k]);
       }
     }
   }
@@ -135,10 +132,8 @@ void initialize (void)
 
 #ifdef DEBUG
   was_mem_end = mem_min;
-/*  was_lo_max = mem_min; */
-  was_lo_max = mem_bot;
-/*  was_hi_min = mem_max; */
-  was_hi_min = mem_top;
+  was_lo_max = mem_bot; // mem_min
+  was_hi_min = mem_top; // mem_max
   panicking = false;
 #endif
 
@@ -147,7 +142,7 @@ void initialize (void)
   mode = 1;
   head = contrib_head;
   tail = contrib_head;
-  cur_list.aux_field.cint = ignore_depth;
+  prev_depth = ignore_depth;
   mode_line = 0;
   prev_graf = 0;
   shown_mode = 0;
@@ -224,8 +219,8 @@ void initialize (void)
   adjust_tail = 0;
   last_badness = 0;
   pack_begin_line = 0;
-  empty_field.v.RH = 0;
-  empty_field.v.LH = 0;
+  empty_field.rh = 0;
+  empty_field.lh = 0;
   null_delimiter.b0 = 0;
   null_delimiter.b1 = 0;
   null_delimiter.b2 = 0;
@@ -237,7 +232,6 @@ void initialize (void)
   cur_head = 0;
   cur_tail = 0;
 
-
 /*  *not* OK with ALLOCATEHYPHEN, since may not be allocated yet */
 #ifndef ALLOCATEHYPHEN
   for (z = 0; z <= hyphen_prime; z++)
@@ -280,18 +274,17 @@ void initialize_aux (void)
 {
 #ifdef DEBUG
   was_mem_end = mem_min;
-/*  was_lo_max = mem_min; */
-  was_lo_max = mem_bot;
-/*  was_hi_min = mem_max; */
-  was_hi_min = mem_top;
+  was_lo_max = mem_bot; // mem_min
+  was_hi_min = mem_top; // mem_max
   panicking = false;
-#endif /* DEBUG */
+#endif
+
 /*  nest_ptr = 0; */
 /*  max_nest_stack = 0; */
   mode = 1;
   head = contrib_head;
   tail = contrib_head;
-  cur_list.aux_field.cint = ignore_depth;
+  prev_depth = ignore_depth;
   mode_line = 0;
   prev_graf = 0;
 /*  shown_mode = 0; */
@@ -303,27 +296,22 @@ void initialize_aux (void)
 /* sec 0815 */
 void line_break_ (integer final_widow_penalty)
 {
-  bool auto_breaking;
-  halfword prevp;
+  boolean auto_breaking;
+  halfword prev_p;
   halfword q, r, s, prevs;
   internal_font_number f;
 /*  small_number j;  */
   int j;                /* 95/Jan/7 */
 /*  unsigned char c;  */
   unsigned int c;           /* 95/Jan/7 */
-/*  savedbadness = 0; */    /* 96/Feb/9 */
 
   pack_begin_line = mode_line;
   link(temp_head) = link(head);
 
-  if ((tail >= hi_mem_min))
-  {
+  if (is_char_node(tail))
     tail_append(new_penalty(inf_penalty));
-  } 
   else if (type(tail) != glue_node)
-  {
     tail_append(new_penalty(inf_penalty));
-  }
   else
   {
     type(tail) = penalty_node;
@@ -338,17 +326,8 @@ void line_break_ (integer final_widow_penalty)
   init_r_hyf = (prev_graf / 65536L) % 64;
   pop_nest();
   no_shrink_error_yet = true;
-
-  if ((shrink_order(left_skip) != normal) && (shrink(left_skip) != 0))
-  {
-    left_skip = finite_shrink(left_skip);
-  }
-
-  if ((shrink_order(right_skip) != normal) && (shrink(right_skip) != 0))
-  {
-    right_skip = finite_shrink(right_skip);
-  }
-
+  check_shrinkage(left_skip);
+  check_shrinkage(right_skip);
   q = left_skip;
   r = right_skip;
   background[1] = width(q) + width(r);
@@ -359,12 +338,11 @@ void line_break_ (integer final_widow_penalty)
   background[2 + stretch_order(q)] = stretch(q);
   background[2 + stretch_order(r)] = background[2 + stretch_order(r)] + stretch(r);
   background[6] = shrink(q) + shrink(r);
-
-  minimum_demerits = 1073741823L; /* 2^30 - 1 *//* 40000000 hex - 1 */
-  minimal_demerits[tight_fit] = 1073741823L;
-  minimal_demerits[decent_fit] = 1073741823L;
-  minimal_demerits[loose_fit] = 1073741823L;
-  minimal_demerits[very_loose_fit] = 1073741823L;
+  minimum_demerits = awful_bad;
+  minimal_demerits[tight_fit] = awful_bad;
+  minimal_demerits[decent_fit] = awful_bad;
+  minimal_demerits[loose_fit] = awful_bad;
+  minimal_demerits[very_loose_fit] = awful_bad;
 
   if (par_shape_ptr == 0)
     if (hang_indent == 0)
@@ -423,7 +401,8 @@ void line_break_ (integer final_widow_penalty)
       begin_diagnostic();
       print_nl("@firstpass");
     }
-#endif /* STAT */
+#endif
+
     second_pass = false;
     final_pass = false;
     first_pass_count++; /* 96 Feb 9 */
@@ -433,10 +412,11 @@ void line_break_ (integer final_widow_penalty)
     threshold = tolerance;
     second_pass = true;
     final_pass = (emergency_stretch <= 0);
+
 #ifdef STAT
     if (tracing_paragraphs > 0)
       begin_diagnostic();
-#endif /* STAT */
+#endif
   }
 
   while (true)
@@ -451,8 +431,8 @@ void line_break_ (integer final_widow_penalty)
       {
         if (trie_not_ready)
           init_trie();
-      } /* bkph */
-#endif /* INITEX */
+      }
+#endif
 
       cur_lang = init_cur_lang;
       lhyf = init_l_hyf;
@@ -467,7 +447,7 @@ void line_break_ (integer final_widow_penalty)
     line_number(q) = prev_graf + 1;
     total_demerits(q) = 0;
     link(active) = q;
-    active_width[1] = background[1];
+    act_width = background[1];
     active_width[2] = background[2];
     active_width[3] = background[3];
     active_width[4] = background[4];
@@ -481,21 +461,21 @@ void line_break_ (integer final_widow_penalty)
 
     cur_p = link(temp_head);
     auto_breaking = true;
-    prevp = cur_p;
+    prev_p = cur_p;
 
-    while((cur_p != 0) && (link(active) != active))
+    while ((cur_p != 0) && (link(active) != active))
     {
-      if ((cur_p >= hi_mem_min))
+      if (is_char_node(cur_p))
       {
-        prevp = cur_p;
+        prev_p = cur_p;
 
         do
           {
             f = font(cur_p);
-            active_width[1] = active_width[1] + char_width(f, char_info(f, character(cur_p)));
+            act_width = act_width + char_width(f, char_info(f, character(cur_p)));
             cur_p = link(cur_p);
           }
-        while(!(!(cur_p >= hi_mem_min)));
+        while (!(!is_char_node(cur_p)));
       }
 
       switch(type(cur_p))
@@ -503,8 +483,9 @@ void line_break_ (integer final_widow_penalty)
         case hlist_node:
         case vlist_node:
         case rule_node:
-          active_width[1] = active_width[1] + width(cur_p);
+          act_width = act_width + width(cur_p);
           break;
+
         case whatsit_node:
           if (subtype(cur_p) == language_node)
           {
@@ -513,25 +494,22 @@ void line_break_ (integer final_widow_penalty)
             rhyf = what_rhm(cur_p);
           }
           break;
+
         case glue_node:
           {
             if (auto_breaking)
             {
-              if ((prevp >= hi_mem_min))
+              if (is_char_node(prev_p))
                 try_break(0, unhyphenated);
-              else if ((mem[prevp].hh.b0 < 9))
+              else if ((mem[prev_p].hh.b0 < 9))
                 try_break(0, unhyphenated);
-              else if ((type(prevp) == kern_node) && (subtype(prevp) != explicit))
+              else if ((type(prev_p) == kern_node) && (subtype(prev_p) != explicit))
                 try_break(0, unhyphenated);
             }
 
-            if ((mem[glue_ptr(cur_p)].hh.b1 != 0) && (mem[glue_ptr(cur_p) + 3].cint != 0))
-            {
-              glue_ptr(cur_p) = finite_shrink(glue_ptr(cur_p));
-            }
-
+            check_shrinkage(glue_ptr(cur_p));
             q = glue_ptr(cur_p);
-            active_width[1] = active_width[1]+ width(q);
+            act_width = act_width+ width(q);
             active_width[2 + stretch_order(q)] = active_width[2 + stretch_order(q)] + stretch(q);
             active_width[6] = active_width[6] + shrink(q);
 
@@ -544,14 +522,14 @@ void line_break_ (integer final_widow_penalty)
               {
                 while (true)
                 {
-                  if ((s >= hi_mem_min))
+                  if (is_char_node(s))
                   {
                     c = character(s);
                     hf = font(s);
                   }
                   else if (type(s) == ligature_node)
                     if (lig_ptr(s) == 0)
-                      goto lab22;
+                      goto continu;
                     else
                     {
                       q = lig_ptr(s);
@@ -559,7 +537,7 @@ void line_break_ (integer final_widow_penalty)
                       hf = font(q);
                     }
                   else if ((type(s) == kern_node) && (subtype(s) == normal))
-                    goto lab22;
+                    goto continu;
                   else if (type(s) == whatsit_node)
                   {
                     if (subtype(s) == language_node)
@@ -568,52 +546,52 @@ void line_break_ (integer final_widow_penalty)
                       lhyf = what_lhm(s);
                       rhyf = what_rhm(s);
                     }
-                    goto lab22;
+                    goto continu;
                   }
                   else
-                    goto lab31;
+                    goto done1;
 
                   if (lc_code(c) != 0)
                     if ((lc_code(c) == (halfword) c) || (uc_hyph > 0)) /* fixed signed tyoe */
-                      goto lab32;
+                      goto done2;
                     else
-                      goto lab31;
-lab22:
+                      goto done1;
+continu:
                   prevs = s;
                   s = link(prevs);
                 }
-lab32:
+done2:
                 hyf_char = hyphen_char[hf];
 
                 if (hyf_char < 0)
-                  goto lab31; 
+                  goto done1; 
 
                 if (hyf_char > 255)
-                  goto lab31; /* ? */
+                  goto done1; /* ? */
 
                 ha = prevs;
 
                 if (lhyf + rhyf > 63)
-                  goto lab31;
+                  goto done1;
 
                 hn = 0;
 
                 while (true)
                 {
-                  if ((s >= hi_mem_min))
+                  if (is_char_node(s))
                   {
                     if (font(s) != hf)
-                      goto lab33;
+                      goto done3;
 
                     hyfbchar = character(s);
 
                     c = hyfbchar;     /*  unsigned char c;  */
 
                     if (lc_code(c) == 0)
-                      goto lab33;
+                      goto done3;
 
                     if (hn == 63)
-                      goto lab33;
+                      goto done3;
 
                     hb = s;
                     incr(hn);
@@ -624,7 +602,7 @@ lab32:
                   else if (type(s) == ligature_node)
                   {
                     if (font(lig_char(s)) != hf)
-                      goto lab33;
+                      goto done3;
 
                     j = hn;
                     q = lig_ptr(s);
@@ -637,10 +615,10 @@ lab32:
                       c = character(q);
 
                       if (lc_code(c) == 0)
-                        goto lab33;
+                        goto done3;
 
                       if (j == 63)
-                        goto lab33;
+                        goto done3;
 
                       incr(j);
                       hu[j] = c;
@@ -662,24 +640,24 @@ lab32:
                     hyfbchar = font_bchar[hf];
                   }
                   else
-                    goto lab33;
+                    goto done3;
 
                   s = link(s);
                 }
-lab33:;
+done3:;
                 if (hn < lhyf + rhyf)
-                  goto lab31;
+                  goto done1;
 
                 while (true)
                 {
-                  if (!((s >= hi_mem_min)))
+                  if (!(is_char_node(s)))
                     switch(type(s))
                     {
                       case ligature_node:
                         break;
                       case kern_node:
                         if (subtype(s) != normal)
-                          goto lab34;
+                          goto done4;
                         break;
                       case whatsit_node:
                       case glue_node:
@@ -687,37 +665,31 @@ lab33:;
                       case ins_node:
                       case adjust_node:
                       case mark_node:
-                        goto lab34;
+                        goto done4;
                         break;
                       default:
-                        goto lab31;
+                        goto done1;
                         break;
                     }
                   s = link(s);
                 }
-lab34:;
+done4:;
                 hyphenate();
               }
-lab31:;
+done1:;
             }
           }
           break;
         case kern_node:
           if (subtype(cur_p) == explicit)
-          {
-            if (!(link(cur_p) >= hi_mem_min) && auto_breaking)
-              if (type(link(cur_p)) == glue_node)
-                try_break(0, unhyphenated);
-
-            active_width[1] = active_width[1] + width(cur_p);
-          }
+            kern_break();
           else
-            active_width[1] = active_width[1] + width(cur_p);
+            act_width = act_width + width(cur_p);
           break;
         case ligature_node:
           {
             f = font(lig_char(cur_p));
-            active_width[1] = active_width[1] + char_width(f, char_info(f, character(lig_char(cur_p))));
+            act_width = act_width + char_width(f, char_info(f, character(lig_char(cur_p))));
           }
           break;
         case disc_node:
@@ -731,7 +703,7 @@ lab31:;
             {
               do
               {
-                if ((s >= hi_mem_min))
+                if (is_char_node(s))
                 {
                   f = font(s);
                   disc_width = disc_width + char_width(f, char_info(f, character(s)));
@@ -753,86 +725,89 @@ lab31:;
                   default:
                     {
                       confusion("disc3");
-                      return;       // abort_flag set
+                      return;
                     }
                     break;
                 }
                 s = link(s);
               }
-              while(!(s == 0));
+              while (!(s == 0));
 
-              active_width[1] = active_width[1] + disc_width;
+              act_width = act_width + disc_width;
               try_break(hyphen_penalty, hyphenated);
-              active_width[1] = active_width[1] - disc_width;
+              act_width = act_width - disc_width;
             }
             r = replace_count(cur_p);
             s = link(cur_p);
 
             while (r > 0)
             {
-              if ((s >= hi_mem_min))
+              if (is_char_node(s))
               {
                 f = font(s);
-                active_width[1] = active_width[1] + char_width(f, char_info(f, character(s)));
+                act_width = act_width + char_width(f, char_info(f, character(s)));
               }
               else switch(type(s))
               {
                 case ligature_node:
                   {
                     f = font(lig_char(s));
-                    active_width[1] = active_width[1] + char_width(f, char_info(f, character(lig_char(s))));
+                    act_width = act_width + char_width(f, char_info(f, character(lig_char(s))));
                   }
                   break;
+
                 case hlist_node:
                 case vlist_node:
                 case rule_node:
                 case kern_node:
-                  active_width[1] = active_width[1] + width(s);
+                  act_width = act_width + width(s);
                   break;
+
                 default:
                   {
                     confusion("disc4");
-                    return;       // abort_flag set
+                    return;
                   }
                   break;
               }
+
               decr(r);
               s = link(s);
             }
-            prevp = cur_p;
+
+            prev_p = cur_p;
             cur_p = s;
-            goto lab35;
+            goto done5;
           }
           break;
+
         case math_node:
           {
-            auto_breaking = (subtype(cur_p) == 1);
-            {
-              if (!(link(cur_p) >= hi_mem_min) && auto_breaking)
-                if (type(link(cur_p)) == glue_node)
-                  try_break(0, unhyphenated);
-
-              active_width[1] = active_width[1] + width(cur_p);
-            }
+            auto_breaking = (subtype(cur_p) == after);
+            kern_break();
           }
           break;
+
         case penalty_node:
           try_break(penalty(cur_p), unhyphenated);
           break;
+
         case mark_node:
         case ins_node:
         case adjust_node:
           break;
+
         default:
           {
             confusion("paragraph");
-            return;       // abort_flag set
+            return;
           }
           break;
       }
-      prevp = cur_p;
+
+      prev_p = cur_p;
       cur_p = link(cur_p);
-lab35:;
+done5:;
     }
 
     if (cur_p == 0)
@@ -842,57 +817,62 @@ lab35:;
       if (link(active) != active)
       {
         r = link(active);
-        fewest_demerits = 1073741823L; /* 2^30 - 1 */
+        fewest_demerits = awful_bad;
 
         do
-        {
-          if (type(r) != 2)
-            if (total_demerits(r) < fewest_demerits)
-            {
-              fewest_demerits = total_demerits(r);
-              best_bet = r;
-            }
-          r = link(r);
-        }
+          {
+            if (type(r) != 2)
+              if (total_demerits(r) < fewest_demerits)
+              {
+                fewest_demerits = total_demerits(r);
+                best_bet = r;
+              }
+
+            r = link(r);
+          }
         while (!(r == active));
+
         best_line = line_number(best_bet);
 
         if (looseness == 0)
         {
-          goto lab30;           /* normal exit */
+          goto done;           /* normal exit */
         }
 
         {
           r = link(active);
           actual_looseness = 0;
+
           do
-          {
-            if (type(r) != 2)
             {
-              line_diff = toint(line_number(r)) - toint(best_line);
-
-              if (((line_diff < actual_looseness) && (looseness <= line_diff)) ||
-                  ((line_diff > actual_looseness) && (looseness >= line_diff)))
+              if (type(r) != 2)
               {
-                best_bet = r;
-                actual_looseness = line_diff;
-                fewest_demerits = total_demerits(r);
-              }
-              else if ((line_diff == actual_looseness) && (total_demerits(r) < fewest_demerits))
-              {
-                best_bet = r;
-                fewest_demerits = total_demerits(r);
+                line_diff = toint(line_number(r)) - toint(best_line);
+
+                if (((line_diff < actual_looseness) && (looseness <= line_diff)) ||
+                    ((line_diff > actual_looseness) && (looseness >= line_diff)))
+                {
+                  best_bet = r;
+                  actual_looseness = line_diff;
+                  fewest_demerits = total_demerits(r);
+                }
+                else if ((line_diff == actual_looseness) && (total_demerits(r) < fewest_demerits))
+                {
+                  best_bet = r;
+                  fewest_demerits = total_demerits(r);
+                }
               }
+
+              r = link(r);
             }
-            r = link(r);
-          }
           while (!(r == active));
+
           best_line = line_number(best_bet);
         }
 
         if ((actual_looseness == looseness) || final_pass)
         {
-          goto lab30;
+          goto done;
         }
       }
     }
@@ -903,10 +883,10 @@ lab35:;
     {
       cur_p = link(q);
 
-      if (type(q) == 2)
-        free_node(q, 7);
+      if (type(q) == delta_node)
+        free_node(q, delta_node_size);
       else
-        free_node(q, 3);
+        free_node(q, active_node_size);
 
       q = cur_p;
     }
@@ -916,16 +896,16 @@ lab35:;
     while (q != 0)
     {
       cur_p = link(q);
-      free_node(q, 2);
+      free_node(q, passive_node_size);
       q = cur_p;
     }
 
-    if (! second_pass)
+    if (!second_pass)
     {
 #ifdef STAT
       if (tracing_paragraphs > 0)
         print_nl("@secondpass");
-#endif /* STAT */
+#endif
       threshold = tolerance;
       second_pass = true;
       second_pass_count++;          /* 96 Feb 9 */
@@ -936,15 +916,15 @@ lab35:;
 #ifdef STAT
       if (tracing_paragraphs > 0)
         print_nl("@emergencypass");
-#endif /* STAT */
-/*     can only get here is \emergencystretch has been set positive */
+#endif
+
       background[2] = background[2] + emergency_stretch;
       final_pass = true;
       ++final_pass_count;         /* 96 Feb 9 */
-    } /* end of if second_pass */
-  } /* end of while(true)do */
-/* cannot drop through from above loop */
-lab30:                /* common exit point */
+    }
+  }
+
+done:
   if (best_line == 2)
     single_line++;
 
@@ -954,7 +934,7 @@ lab30:                /* common exit point */
     end_diagnostic(true);
     normalize_selector();
   }
-#endif /* STAT */
+#endif
 
   post_line_break(final_widow_penalty);
   q = link(active);
@@ -963,10 +943,10 @@ lab30:                /* common exit point */
   {
     cur_p = link(q);
 
-    if (type(q) == 2)
-      free_node(q, 7);
+    if (type(q) == delta_node)
+      free_node(q, delta_node_size);
     else
-      free_node(q, 3);
+      free_node(q, active_node_size);
 
     q = cur_p;
   }
@@ -976,7 +956,7 @@ lab30:                /* common exit point */
   while (q != 0)
   {
     cur_p = link(q);
-    free_node(q, 2);
+    free_node(q, passive_node_size);
     q = cur_p;
   }
 
@@ -989,9 +969,9 @@ void prefixed_command (void)
   internal_font_number f;
   halfword j;
   font_index k;
-  halfword p, q;
+  pointer p, q;
   integer n;
-  bool e;
+  boolean e;
 
   a = 0;
 
@@ -1004,7 +984,7 @@ void prefixed_command (void)
       {
         get_x_token();
       }
-    while(!((cur_cmd != spacer) && (cur_cmd != relax)));
+    while (!((cur_cmd != spacer) && (cur_cmd != relax)));
 
     if (cur_cmd <= max_non_prefixed_command)
     {
@@ -1045,10 +1025,7 @@ void prefixed_command (void)
   switch (cur_cmd)
   {
     case set_font:
-      if ((a >= 4))
-        geq_define(cur_font_loc, data, cur_chr);
-      else
-        eq_define(cur_font_loc, data, cur_chr);
+      define(cur_font_loc, data, cur_chr);
       break;
 
     case def:
@@ -1060,11 +1037,7 @@ void prefixed_command (void)
         get_r_token();
         p = cur_cs;
         q = scan_toks(true, e);
-
-        if ((a >= 4))
-          geq_define(p, call + (a % 4), def_ref);
-        else
-          eq_define(p, call + (a % 4), def_ref);
+        define(p, call + (a % 4), def_ref);
       }
       break;
 
@@ -1101,12 +1074,9 @@ void prefixed_command (void)
         }
 
         if (cur_cmd >= call)
-          incr(mem[cur_chr].hh.v.LH);
+          add_token_ref(cur_chr);
 
-        if ((a >= 4))
-          geq_define(p, cur_cmd, cur_chr);
-        else
-          eq_define(p, cur_cmd, cur_chr);
+        define(p, cur_cmd, cur_chr);
       }
       break;
 
@@ -1115,12 +1085,7 @@ void prefixed_command (void)
         n = cur_chr;
         get_r_token();
         p = cur_cs;
-
-        if ((a >= 4))
-          geq_define(p, relax, 256);
-        else
-          eq_define(p, relax, 256);
-
+        define(p, relax, 256);
         scan_optional_equals();
 
         switch (n)
@@ -1128,22 +1093,14 @@ void prefixed_command (void)
           case char_def_code:
             {
               scan_char_num();
-
-              if ((a >= 4))
-                geq_define(p, char_given, cur_val);
-              else
-                eq_define(p, char_given, cur_val);
+              define(p, char_given, cur_val);
             }
             break;
 
           case math_char_def_code:
             {
               scan_fifteen_bit_int();
-
-              if ((a >= 4))
-                geq_define(p, math_given, cur_val);
-              else
-                eq_define(p, math_given, cur_val);
+              define(p, math_given, cur_val);
             }
             break;
 
@@ -1154,38 +1111,23 @@ void prefixed_command (void)
               switch (n)
               {
                 case count_def_code:
-                  if ((a >= 4))
-                    geq_define(p, assign_int, count_base + cur_val);
-                  else
-                    eq_define(p, assign_int, count_base + cur_val);
+                  define(p, assign_int, count_base + cur_val);
                   break;
 
                 case dimen_def_code:
-                  if ((a >= 4))
-                    geq_define(p, assign_dimen, scaled_base + cur_val);
-                  else
-                    eq_define(p, assign_dimen, scaled_base + cur_val);
+                  define(p, assign_dimen, scaled_base + cur_val);
                   break;
 
                 case skip_def_code:
-                  if ((a >= 4)) 
-                    geq_define(p, assign_glue, skip_base + cur_val);
-                  else
-                    eq_define(p, assign_glue, skip_base + cur_val);
+                  define(p, assign_glue, skip_base + cur_val);
                   break;
 
                 case mu_skip_def_code:
-                  if ((a >= 4))
-                    geq_define(p, assign_mu_glue, mu_skip_base + cur_val);
-                  else
-                    eq_define(p, assign_mu_glue, mu_skip_base + cur_val);
+                  define(p, assign_mu_glue, mu_skip_base + cur_val);
                   break;
 
                 case toks_def_code:
-                  if ((a >= 4))
-                    geq_define(p, assign_toks, toks_base + cur_val);
-                  else
-                    eq_define(p, assign_toks, toks_base + cur_val);
+                  define(p, assign_toks, toks_base + cur_val);
                   break;
               }
             }
@@ -1199,7 +1141,7 @@ void prefixed_command (void)
         scan_int();
         n = cur_val;
 
-        if (! scan_keyword("to"))
+        if (!scan_keyword("to"))
         {
           print_err("Missing `to' inserted");
           help2("You should have said `\\read<number> to \\cs'.",
@@ -1210,11 +1152,7 @@ void prefixed_command (void)
         get_r_token();
         p = cur_cs;
         read_toks(n, p);
-
-        if ((a >= 4))
-          geq_define(p, call, cur_val);
-        else
-          eq_define(p, call, cur_val);
+        define(p, call, cur_val);
       }
       break;
 
@@ -1237,7 +1175,7 @@ void prefixed_command (void)
           {
             get_x_token();
           }
-        while(!((cur_cmd != spacer) && (cur_cmd != relax)));
+        while (!((cur_cmd != spacer) && (cur_cmd != relax)));
 
         if (cur_cmd != left_brace)
         {
@@ -1253,20 +1191,13 @@ void prefixed_command (void)
             q = equiv(cur_chr);
 
             if (q == 0)
-              if ((a >= 4))
-                geq_define(p, undefined_cs, 0);
-              else
-                eq_define(p, undefined_cs, 0);
+              define(p, undefined_cs, 0);
             else
             {
-              incr(mem[q].hh.v.LH);
-
-              if ((a >= 4))
-                geq_define(p, call, q);
-              else
-                eq_define(p, call, q);
+              add_token_ref(q);
+              define(p, call, q);
             }
-            goto lab30;
+            goto done;
           }
         }
 
@@ -1276,11 +1207,7 @@ void prefixed_command (void)
 
         if (link(def_ref) == 0)
         {
-          if ((a >= 4))
-            geq_define(p, undefined_cs, 0);
-          else
-            eq_define(p, undefined_cs, 0);
-
+          define(p, undefined_cs, 0);
           free_avail(def_ref);
         }
         else
@@ -1296,10 +1223,7 @@ void prefixed_command (void)
             link(def_ref) = q;
           }
 
-          if ((a >= 4))
-            geq_define(p, call, def_ref);
-          else
-            eq_define(p, call, def_ref);
+          define(p, call, def_ref);
         }
       }
       break;
@@ -1309,11 +1233,7 @@ void prefixed_command (void)
         p = cur_chr;
         scan_optional_equals();
         scan_int();
-
-        if ((a >= 4))
-          geq_word_define(p, cur_val);
-        else
-          eq_word_define(p, cur_val);
+        word_define(p, cur_val);
       }
       break;
 
@@ -1322,11 +1242,7 @@ void prefixed_command (void)
         p = cur_chr;
         scan_optional_equals();
         scan_dimen(false, false, false);
-
-        if ((a >= 4))
-          geq_word_define(p, cur_val);
-        else
-          eq_word_define(p, cur_val);
+        word_define(p, cur_val);
       }
       break;
 
@@ -1343,11 +1259,7 @@ void prefixed_command (void)
           scan_glue(glue_val);
 
         trap_zero_glue();
-
-        if ((a >= 4))
-          geq_define(p, glue_ref, cur_val);
-        else
-          eq_define(p, glue_ref, cur_val);
+        define(p, glue_ref, cur_val);
       }
       break;
 
@@ -1356,13 +1268,13 @@ void prefixed_command (void)
         if (cur_chr == cat_code_base)
           n = max_char_code;
         else if (cur_chr == math_code_base)
-          n = 32768L;                 /* 2^15 */
+          n = 32768L; /* 2^15 */
         else if (cur_chr == sf_code_base)
-          n = 32767;                /* 2^15 - 1*/
+          n = 32767; /* 2^15 - 1*/
         else if (cur_chr == del_code_base)
-          n = 16777215L;              /* 2^24 - 1 */
+          n = 16777215L; /* 2^24 - 1 */
         else
-          n = 255;             /* 2^8 - 1 */
+          n = 255;
 
         p = cur_chr;
         scan_char_num();
@@ -1387,20 +1299,11 @@ void prefixed_command (void)
         }
 
         if (p < math_code_base)
-          if ((a >= 4))
-            geq_define(p, data, cur_val);
-          else
-            eq_define(p, data, cur_val);
+          define(p, data, cur_val);
         else if (p < del_code_base)
-          if ((a >= 4))
-            geq_define(p, data, cur_val);
-          else
-            eq_define(p, data, cur_val);
+          define(p, data, cur_val);
         else 
-          if ((a >= 4))
-            geq_word_define(p, cur_val);
-          else
-            eq_word_define(p, cur_val);
+          word_define(p, cur_val);
       }
       break;
 
@@ -1411,11 +1314,7 @@ void prefixed_command (void)
         p = p + cur_val;
         scan_optional_equals();
         scan_font_ident();
-
-        if ((a >= 4))
-          geq_define(p, data, cur_val);
-        else
-          eq_define(p, data, cur_val);
+        define(p, data, cur_val);
       }
       break;
 
@@ -1438,9 +1337,7 @@ void prefixed_command (void)
         scan_optional_equals();
 
         if (set_box_allowed)
-        {
           scan_box(box_flag + n);
-        }
         else
         {
           print_err("Improper ");
@@ -1494,10 +1391,7 @@ void prefixed_command (void)
           }
         }
 
-        if ((a >= 4))
-          geq_define(par_shape_loc, shape_ref, p);
-        else
-          eq_define(par_shape_loc, shape_ref, p);
+        define(par_shape_loc, shape_ref, p);
       }
       break;
 
@@ -1508,9 +1402,9 @@ void prefixed_command (void)
         if (is_initex)
         {
           new_patterns();
-          goto lab30;
+          goto done;
         }
-#endif /* INITEX */
+#endif
         print_err("Patterns can be loaded only by INITEX");
         help_ptr = 0;
         error();
@@ -1519,14 +1413,14 @@ void prefixed_command (void)
           {
             get_token();
           }
-        while(!(cur_cmd == right_brace));
+        while (!(cur_cmd == right_brace));
 
         return;
       }
       else
       {
         new_hyph_exceptions();
-        goto lab30;
+        goto done;
       }
       break;
 
@@ -1566,12 +1460,12 @@ void prefixed_command (void)
     default:
       {
         confusion("prefix");
-        return;       // abort_flag set
+        return;
       }
       break;
   }
 
-lab30:
+done:
   if (after_token != 0)
   {
     cur_tok = after_token;
@@ -1579,66 +1473,29 @@ lab30:
     after_token = 0;
   }
 }
-
-void bad_formator_pool (char *name, char *defaultname, char *envvar)
-{
-  if (name == NULL)
-    name = defaultname;
-
-  sprintf(log_line, "(Perhaps %s is for an older version of TeX)\n", name);
-  show_line(log_line, 0);
-  name_of_file[name_length + 1] = '\0';
-  sprintf(log_line, "(Alternatively, %s may have been corrupted)\n", name_of_file + 1);
-  show_line(log_line, 0);
-  name_of_file[name_length + 1] = ' ';
-  sprintf(log_line, "(Perhaps your %s environment variable is not set correctly)\n", envvar);
-  show_line(log_line, 0);
-
-  {
-    char *s;
-
-    if ((s = grabenv(envvar)) != NULL)
-    {
-      sprintf(log_line, "(%s=%s)\n", envvar, s);
-      show_line(log_line, 0);
-    }
-    else
-    {
-      sprintf(log_line, "%s environment variable not set\n", envvar);
-      show_line(log_line, 0);
-    }
-  }
-
-#ifndef _WINDOWS
-  fflush(stdout);
-#endif
-}
 /* sec 1303 */
-bool load_fmt_file (void)
+boolean load_fmt_file (void)
 {
   integer j, k;
-  halfword p, q;
+  pointer p, q;
   integer x;
 
   undump_int(x);
 
-  if (x != BEGINFMTCHECKSUM) /* magic FMT file start 4C 20 E6 15 hex */
-    goto lab6666;
+  if (x != BEGINFMTCHECKSUM)
+    goto bad_fmt;
 
   undump_int(x); /* mem_bot */
 
   if (x != mem_bot)
-    goto lab6666;
+    goto bad_fmt;
 
   undump_int(x); /* mem_top */
 
 #ifdef ALLOCATEMAIN
 /* we already read this once earlier to grab mem_top */
   if (trace_flag)
-  {
-    sprintf(log_line, "Read from fmt file mem_top = %d TeX words\n", x);
-    show_line(log_line, 0);
-  }
+    printf("Read from fmt file mem_top = %d TeX words\n", x);
 
   mem = allocate_main_memory(x); /* allocate main memory at this point */
 
@@ -1646,84 +1503,81 @@ bool load_fmt_file (void)
     exit(1);                     /* redundant sanity test ! */
 
   initialize_aux();              /* do `mem' part of initialize */
-/*  mem = zmem; */               /* update pointer to main memory */
 #endif
 
   if (x != mem_top)
-    goto lab6666;
+    goto bad_fmt;
 
-  undump_int(x); /* eqtbsize */
+  undump_int(x); /* eqtb_size */
 
-  if (x != (eqtb_size))
-    goto lab6666;
+  if (x != eqtb_size)
+    goto bad_fmt;
 
   undump_int(x); /* hash_prime */
 
   if (x != hash_prime)
-    goto lab6666;
+    goto bad_fmt;
 
   undump_int(x); /* hyphen_prime */
 
 #ifdef ALLOCATEHYPHEN
 /* allow format files dumped with arbitrary (prime) hyphenation exceptions */
-  realloc_hyphen(x); /* reset_hyphen(); */
+  realloc_hyphen(x);
   hyphen_prime = x;
 #endif
 
   if (x != hyphen_prime)
-    goto lab6666;
+    goto bad_fmt;
 
   {
     undump_int(x); /* pool_size */
 
     if (x < 0)
-      goto lab6666
+      goto bad_fmt
 
 #ifdef ALLOCATESTRING
     if (x > current_pool_size)
     {
       if (trace_flag)
-      {
-        sprintf(log_line, "undump string pool reallocation (%d > %d)\n", x, current_pool_size);
-        show_line(log_line, 0);
-      }
+        printf("undump string pool reallocation (%d > %d)\n", x, current_pool_size);
+
       str_pool = realloc_str_pool (x - current_pool_size + increment_pool_size);
     }
-    if (x > current_pool_size)   /* 94/Jan/24 */
+
+    if (x > current_pool_size)
 #else
     if (x > pool_size)
 #endif
     {
-      sprintf(log_line, "%s%s\n",  "---! Must increase the ", "string pool size");
-      show_line(log_line, 0);
-      goto lab6666;
+      printf("%s%s\n",  "---! Must increase the ", "string pool size");
+      goto bad_fmt;
     }
     else
       pool_ptr = x;
   }
+
   {
     undump_int(x);  /* max_strings */
+
     if (x < 0)
-      goto lab6666;
+      goto bad_fmt;
 
 #ifdef ALLOCATESTRING
     if (x > current_max_strings)
     {
       if (trace_flag)
-      {
-        sprintf(log_line, "undump string pointer reallocation (%d > %d)\n", x, current_max_strings);
-        show_line(log_line, 0);
-      }
+        printf("undump string pointer reallocation (%d > %d)\n", x, current_max_strings);
+
       str_start = realloc_str_start(x - current_max_strings + increment_max_strings);
     }
+
     if (x > current_max_strings) /* 94/Jan/24 */
 #else
     if (x > max_strings)
 #endif
     {
-      sprintf(log_line,  "%s%s\n",  "---! Must increase the ", "max strings");
-      show_line(log_line, 0);
-      goto lab6666;
+      printf("%s%s\n",  "---! Must increase the ", "max strings");
+      goto bad_fmt;
     }
     else
       str_ptr = x;
@@ -1731,50 +1585,39 @@ bool load_fmt_file (void)
 
   if (undumpthings(str_start[0], str_ptr + 1)) /* undump string ptrs */
     return -1;
+
   if (undumpthings(str_pool[0], pool_ptr)) /*  undump string pool */
     return -1;
 
   init_str_ptr = str_ptr;
   init_pool_ptr = pool_ptr;
-/*  undump the dynamic memory - paragraph 1312 in the book */
-  {
-    undump_int(x);
-    if ((x < lo_mem_stat_max + 1000) || (x > hi_mem_stat_min - 1))
-      goto lab6666;
-    else
-      lo_mem_max = x;
-  }
-  {
-    undump_int(x);
-    if ((x < lo_mem_stat_max + 1) || (x > lo_mem_max))
-      goto lab6666;
-    else
-      rover = x;
-  }
-  p = 0;                  /* mem_bot */
+  undump(lo_mem_stat_max + 1000, hi_mem_stat_min - 1, lo_mem_max);
+  undump(lo_mem_stat_max + 1, lo_mem_max, rover);
+  p = mem_bot;
   q = rover;
 
   do
-  {
-    if (undumpthings(mem[p], q + 2 - p))
-      return -1;
+    {
+      if (undumpthings(mem[p], q + 2 - p))
+        return -1;
 
-    p = q + node_size(q);
+      p = q + node_size(q);
 
-    if ((p > lo_mem_max) || ((q >= rlink(q)) && (rlink(q) != rover)))
-      goto lab6666;
+      if ((p > lo_mem_max) || ((q >= rlink(q)) && (rlink(q) != rover)))
+        goto bad_fmt;
 
-    q = rlink(q);
-  } while (!(q == rover));
+      q = rlink(q);
+    }
+  while (!(q == rover));
 
   if (undumpthings(mem[p], lo_mem_max + 1 - p))
     return -1;
 
-  if (mem_min < mem_bot - 2)          /*  ? splice in block below */
+  if (mem_min < mem_bot - 2) /*  ? splice in block below */
   {
 /*  or call add_variable_space(mem_bot - (mem_min + 1)) */
     if (trace_flag)
-      show_line("Splicing in mem_min space in undump!\n", 0);
+      puts("Splicing in mem_min space in undump!");
 
     p = llink(rover);
     q = mem_min + 1;
@@ -1785,23 +1628,11 @@ bool load_fmt_file (void)
     rlink(q) = rover;
     llink(q) = p;
     link(q) = empty_flag;
-    node_size(q) = mem_bot - q;     /* ? size of block  */
-  }
-  {
-    undump_int(x);
-    if ((x < lo_mem_max + 1) || (x > hi_mem_stat_min))
-      goto lab6666;
-    else
-      hi_mem_min = x;
+    node_size(q) = mem_bot - q;
   }
-  {
-    undump_int(x);
 
-    if ((x < mem_bot) || (x > mem_top))
-      goto lab6666;
-    else
-      avail = x;
-  }
+  undump(lo_mem_max + 1, hi_mem_stat_min, hi_mem_min);
+  undump(mem_bot, mem_top, avail);
   mem_end = mem_top;
 
   if (undumpthings(mem[hi_mem_min], mem_end + 1 - hi_mem_min))
@@ -1811,162 +1642,169 @@ bool load_fmt_file (void)
   undump_int(dyn_used);
 
   k = active_base;
-  do {
-    undump_int(x);
-    if ((x < 1) || (k + x > (eqtb_size + 1)))
-      goto lab6666;
 
-    if (undumpthings(eqtb[k], x))
-      return -1;
+  do
+    {
+      undump_int(x);
 
-    k = k + x;
-    undump_int(x);
+      if ((x < 1) || (k + x > (eqtb_size + 1)))
+        goto bad_fmt;
 
-    if ((x < 0) || (k + x > (eqtb_size + 1)))
-      goto lab6666;
+      if (undumpthings(eqtb[k], x))
+        return -1;
 
-    for (j = k; j <= k + x - 1; j++)
-    {
-      eqtb[j] = eqtb[k - 1];
+      k = k + x;
+      undump_int(x);
+
+      if ((x < 0) || (k + x > (eqtb_size + 1)))
+        goto bad_fmt;
+
+      for (j = k; j <= k + x - 1; j++)
+        eqtb[j] = eqtb[k - 1];
+
+      k = k + x;
     }
-    k = k + x;
-  } while(!(k > (eqtb_size)));
-  {
-    undump_int(x);
-    if ((x < hash_base) || (x > (frozen_control_sequence)))  /*96/Jan/10*/
-      goto lab6666;
-    else
-      par_loc = x;
-  }
-  par_token = 4095 + par_loc;
-  {
-    undump_int(x);
-    if ((x < hash_base) || (x > (frozen_control_sequence))) /*96/Jan/10*/
-      goto lab6666;
-    else
-      write_loc = x;
-  }
-  {
-    undump_int(x);
-    if ((x < hash_base) || (x > (frozen_control_sequence))) /*96/Jan/10*/
-      goto lab6666;
-    else
-      hash_used = x;
-  }
+  while (!(k > eqtb_size));
+
+  undump(hash_base, frozen_control_sequence, par_loc);
+  par_token = cs_token_flag + par_loc;
+  undump(hash_base, frozen_control_sequence, write_loc);
+  undump(hash_base, frozen_control_sequence, hash_used);
+
   p = hash_base - 1;
-  do {
+
+  do
     {
-      undump_int(x);
-      if ((x < p + 1) || (x > hash_used))
-        goto lab6666;
-      else
-        p = x;
+      undump(p + 1, hash_used, p);
+      undump_hh(hash[p]);
     }
-    undump_hh(hash[p]);
-  } while (!(p == hash_used));
+  while (!(p == hash_used));
 
-  if (undumpthings(hash[hash_used + 1], (undefined_control_sequence - 1) - hash_used))
+  if (undumpthings(hash[hash_used + 1], undefined_control_sequence - 1 - hash_used))
     return -1;
 
-  undump_int(cs_count);     /* cs_count */
+  undump_int(cs_count);
+
   if (trace_flag)
+    printf("itex undump cs_count %d ", cs_count);
+
   {
-    sprintf(log_line, "itex undump cs_count %d ", cs_count); /* debugging */
-    show_line(log_line, 0);
-  }
-  {
-    undump_int(x);        /* font_mem_size */
+    undump_int(x); /* font_mem_size */
+
     if (x < 7)
-      goto lab6666;
+      goto bad_fmt;
+
 #ifdef ALLOCATEFONT
     if (trace_flag)
-    {
-      sprintf(log_line, "Read from fmt fmem_ptr = %d\n", x);
-      show_line(log_line, 0);
-    }
+      printf("Read from fmt fmem_ptr = %d\n", x);
 
-    if (x > current_font_mem_size) /* 93/Nov/28 dynamic allocate font_info */
+    if (x > current_font_mem_size)
     {
       if (trace_flag)
-      {
-        sprintf(log_line, "Undump realloc font_info (%d > %d)\n", x, current_font_mem_size);
-        show_line(log_line, 0);
-      }
+        printf("Undump realloc font_info (%d > %d)\n", x, current_font_mem_size);
+
       font_info = realloc_font_info (x - current_font_mem_size + increment_font_mem_size);
     }
-    if (x > current_font_mem_size)  /* in case allocation failed 94/Jan/24 */
+
+    if (x > current_font_mem_size)
 #else
     if (x > font_mem_size)
 #endif
     {
-      sprintf(log_line, "%s%s\n",  "---! Must increase the ", "font mem size");
-      show_line(log_line, 0);
-      goto lab6666;
+      puts("---! Must increase the font mem size");
+      goto bad_fmt;
     }
     else
       fmem_ptr = x;
   }
+
   {
     if (undumpthings(font_info[0], fmem_ptr))
       return -1;
+
     {
       undump_int(x); /* font_max */
+
       if (x < 0)
-        goto lab6666;
+        goto bad_fmt;
+
       if (x > font_max)
       {
-        sprintf(log_line, "%s%s\n",  "---! Must increase the ", "font max"); 
-        show_line(log_line, 0);
-        goto lab6666;
+        puts("---! Must increase the font max"); 
+        goto bad_fmt;
       }
       else
         font_ptr = x;
     }
-    frozen_font_ptr = font_ptr; /* remember number of fonts frozen into format */
+
+    frozen_font_ptr = font_ptr;
+
     if (undumpthings(font_check[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(font_size[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(font_dsize[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(font_params[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(hyphen_char[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(skew_char[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(font_name[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(font_area[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(font_bc[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(font_ec[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(char_base[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(width_base[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(height_base[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(depth_base[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(italic_base[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(lig_kern_base[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(kern_base[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(exten_base[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(param_base[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(font_glue[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(bchar_label[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(font_bchar[0], font_ptr + 1))
       return -1;
+
     if (undumpthings(font_false_bchar[0], font_ptr + 1))
       return -1;
   }
@@ -1976,73 +1814,41 @@ bool load_fmt_file (void)
 /* non_address from font_mem_size to 0 96/Jan/15 ??? */
 
 #ifdef ALLOCATEFONT
-/* deal with fmt files dumped with *different* font_mem_size 93/Nov/29 */
- {
-   int count = 0, oldfont_mem_size = 0;
-
-   for (x = 0; x <= font_ptr; x++)
-   {
-     if (bchar_label[x] > oldfont_mem_size)
-       oldfont_mem_size = bchar_label[x];
-   }
-
-/* somewhat arbitrary sanity check ... */
-/* if (oldfont_mem_size != font_mem_size && oldfont_mem_size > font_max) { */
-   if (oldfont_mem_size != non_address && oldfont_mem_size > font_max) /* 96/Jan/16 */
-   {
-     for (x = 0; x <= font_ptr; x++)
-     {
-       if (bchar_label[x] == oldfont_mem_size)
-       {
-         /* bchar_label[x] = font_mem_size; */
-         bchar_label[x] = non_address;  /* 96/Jan/16 */
-         count++;
-       }
-     }
-     if (trace_flag)
-     {
-       sprintf(log_line, "oldfont_mem_size is %d --- hit %d times. Using non_address %d\n",
-           oldfont_mem_size, count, non_address);
-       show_line(log_line, 0);
-     }
-   }
- }
-#endif
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-/* undump(0)(hyph_size)(hyph_count); */
   {
-    undump_int(x);
-
-    if ((x < 0) || (x > hyphen_prime))
-      goto lab6666;
-    else
-      hyph_count = x;
-  }
-/* undump hypenation exception tables p.1325 */
-  for (k = 1; k <= hyph_count; k++)
-  {
-    {
-      undump_int(x);
-      if ((x < 0) || (x > hyphen_prime))
-        goto lab6666;
-      else
-        j = x;
-    }
+    int count = 0, oldfont_mem_size = 0;
+    
+    for (x = 0; x <= font_ptr; x++)
     {
-      undump_int(x);
-      if ((x < 0) || (x > str_ptr))
-        goto lab6666;
-      else
-        hyph_word[j] = x;
+      if (bchar_label[x] > oldfont_mem_size)
+        oldfont_mem_size = bchar_label[x];
     }
+
+    if (oldfont_mem_size != non_address && oldfont_mem_size > font_max)
     {
-      undump_int(x);
-      if ((x < 0) || (x > max_halfword)) /* mem_top ? no p.1325 */
-        goto lab6666;
-      else
-        hyph_list[j] = x;
+      for (x = 0; x <= font_ptr; x++)
+      {
+        if (bchar_label[x] == oldfont_mem_size)
+        {
+          bchar_label[x] = non_address;
+          count++;
+        }
+      }
+
+      if (trace_flag)
+        printf("oldfont_mem_size is %d --- hit %d times. Using non_address %d\n",
+            oldfont_mem_size, count, non_address);
     }
   }
+#endif
+
+  undump(0, hyphen_prime, hyph_count);
+
+  for (k = 1; k <= hyph_count; k++)
+  {
+    undump(0, hyphen_prime, j);
+    undump(0, str_ptr, hyph_word[j]);
+    undump(0, max_halfword, hyph_list[j]);
+  }
 
 #ifdef ALLOCATEHYPHEN
 /* if user specified new hyphen prime - flush existing exception patterns ! */
@@ -2059,8 +1865,9 @@ bool load_fmt_file (void)
 
   {
     undump_int(x);
+
     if (x < 0)
-      goto lab6666;
+      goto bad_fmt;
 
 #ifdef ALLOCATETRIES
     if (!is_initex)
@@ -2072,114 +1879,96 @@ bool load_fmt_file (void)
 
     if (x > trie_size)
     {
-      sprintf(log_line, "%s%s\n",  "---! Must increase the ", "trie size");
-      show_line(log_line, 0);
-      goto lab6666;
+      puts("---! Must increase the trie size\n");
+      goto bad_fmt;
     }
     else
       j = x;
   }
+
 #ifdef INITEX
-  if (is_initex) /* bkph */
+  if (is_initex)
     trie_max = j;
-#endif /* INITEX */
+#endif
+
   if (undumpthings(trie_trl[0], j + 1))
     return -1;
+
   if (undumpthings(trie_tro[0], j + 1))
     return -1;
+
   if (undumpthings(trie_trc[0], j + 1))
     return -1;
+
   {
     undump_int(x);
+
     if (x < 0)
-      goto lab6666;
+      goto bad_fmt;
+
     if (x > trie_op_size)
     {
-      sprintf(log_line, "%s%s\n",  "---! Must increase the ", "trie op size");
-      show_line(log_line, 0);
-      goto lab6666;
+      puts("---! Must increase the trie op size\n");
+      goto bad_fmt;
     }
     else
       j = x;
   }
 
 #ifdef INITEX
-  if (is_initex)   /* bkph */
+  if (is_initex)
     trie_op_ptr = j;
-#endif /* INITEX */
+#endif
   
   if (undumpthings(hyf_distance[1], j))
     return -1;
+
   if (undumpthings(hyf_num[1], j))
     return -1;
+
   if (undumpthings(hyf_next[1], j))
     return -1;
 
 #ifdef INITEX
-  if (is_initex)    /* bkph */
+  if (is_initex)
   {
     for (k = 0; k <= 255; k++)
-    {
-        trie_used[k] = 0;
-    }
+      trie_used[k] = min_quarterword;
   }
-#endif /* INITEX */
+#endif
+
   k = 256;
-  while (j > 0) {
-    {
-      undump_int(x);
-      if ((x < 0) || (x > k - 1))
-        goto lab6666;
-      else
-        k = x;
-    }
-    {
-      undump_int(x);
-      if ((x < 1) || (x > j))
-        goto lab6666;
-      else
-        x = x;
-    }
+
+  while (j > 0)
+  {
+    undump(0, k - 1, k);
+    undump(1, j, x);
+
 #ifdef INITEX
-    if (is_initex)          /* bkph */
+    if (is_initex)
       trie_used[k] = x;
-#endif /* INITEX */
-/*   j:=j-x; op_start[k]:=qo(j); */
+#endif
+
     j = j - x;
     op_start[k] = j;
   }
+
 #ifdef INITEX
-  if (is_initex)          /* bkph */
+  if (is_initex)
     trie_not_ready = false;
-#endif /* INITEX */
-  {
-    undump_int(x);
-    if ((x < batch_mode) || (x > error_stop_mode))
-      goto lab6666;
-/*    else interaction = x;  */
-    if (interaction < batch_mode)    /* may now set in local.c bkph 94/Jan/8 */
-      interaction = x;
-  }
-  {
-    undump_int(x);
-    if ((x < 0) || (x > str_ptr))
-      goto lab6666;
-    else
-      format_ident = x;
-  }
+#endif
+
+  undump(batch_mode, error_stop_mode, interaction);
+  undump(0, str_ptr, format_ident);
   undump_int(x);
   
   if ((x != ENDFMTCHECKSUM) || feof(fmt_file))
-    goto lab6666;
+    goto bad_fmt;
 
   return true;
 
-lab6666:;
-  sprintf(log_line, "(Fatal format file error; I'm stymied)\n");
-  show_line(log_line, 1);
-
-  if (!knuth_flag)
-    bad_formator_pool(format_file, "the format file", "TEXFORMATS");
+bad_fmt:;
+  puts("(Fatal format file error; I'm stymied)\n");
 
   return false;
 }
@@ -2195,7 +1984,7 @@ void final_cleanup (void)
 
   while (input_ptr > 0)
   {
-    if (cur_input.state_field == 0)
+    if (state == 0)
     {
       end_token_list();
     }
@@ -2233,10 +2022,10 @@ void final_cleanup (void)
 
     print_string(" was incomplete)");
     if_line = mem[cond_ptr + 1].cint;
-    cur_if = mem[cond_ptr].hh.b1;
+    cur_if = subtype(cond_ptr);
     temp_ptr = cond_ptr;
-    cond_ptr = mem[cond_ptr].hh.v.RH;
-    free_node(temp_ptr, 2);
+    cond_ptr = link(cond_ptr);
+    free_node(temp_ptr, if_node_size);
   }
 
   if (history != spotless)
@@ -2296,7 +2085,7 @@ void show_frozen (void)
   fprintf(log_file, ") ");
 }
 
-int texbody (void)
+int main_program (void)
 {
   history = fatal_error_stop;
 
@@ -2356,7 +2145,7 @@ int texbody (void)
     bad = 15;
 
 #ifdef INCREASEFONTS
-  if (font_max > 1024)
+  if (font_max > 65535)
 #else
   if (font_max > 256)
 #endif
@@ -2374,7 +2163,7 @@ int texbody (void)
   if (cs_token_flag + undefined_control_sequence > max_halfword)
     bad = 21;
 
-  if (format_default_length > PATHMAX)
+  if (format_default_length > file_name_size)
     bad = 31;
 
   if (max_halfword < (mem_top - mem_min) / 2)
@@ -2382,14 +2171,10 @@ int texbody (void)
 
   if (bad > 0)
   {
-    sprintf(log_line, "%s%s%ld\n", "Ouch---my internal constants have been clobbered!",
+    printf("%s%s%ld\n", "Ouch---my internal constants have been clobbered!",
         "---case ", (long) bad);
-    show_line(log_line, 1);
-
-    if (!knuth_flag)
-      bad_formator_pool(format_file, "the format file", "TEXFORMATS");
 
-    goto lab9999;
+    goto final_end;
   }
 
   initialize();
@@ -2398,7 +2183,7 @@ int texbody (void)
   if (is_initex)
   {
     if (!get_strings_started())
-      goto lab9999;
+      goto final_end;
 
     init_prim();
     init_str_ptr = str_ptr;
@@ -2416,29 +2201,21 @@ lab1:
   file_offset = 0;
   show_line(tex_version, 0);
 
-  {
 #ifdef _WIN32
   #ifdef _WIN64
-    sprintf(log_line, " (%s %s/Windows 64bit)", application, yandyversion);
+    printf(" (%s %s/Win64)", application, yandyversion);
   #else
-    sprintf(log_line, " (%s %s/Windows 32bit)", application, yandyversion);
+    printf(" (%s %s/Win32)", application, yandyversion);
   #endif
 #else
-    sprintf(log_line, " (%s %s/Linux)", application, yandyversion);
+    printf(" (%s %s/Linux)", application, yandyversion);
 #endif
-  }
-
-  show_line(log_line, 0);
 
   if (format_ident > 0)
     slow_print(format_ident);
 
   print_ln();
-
-#ifndef _WINDOWS
-  fflush(stdout);
-#endif
-
+  update_terminal();
   job_name = 0;
   name_in_progress = false;
   log_opened = false;
@@ -2466,30 +2243,29 @@ lab1:
       scanner_status = 0;
       warning_index = 0;
       first = 1;
-      cur_input.state_field = 33;
-      cur_input.start_field = 1;
-      cur_input.index_field = 0;
+      state = new_line;
+      start = 1;
+      index = 0;
       line = 0;
-      cur_input.name_field = 0;
+      name = 0;
       force_eof = false;
       align_state = 1000000L;
 
       if (!init_terminal())
-        goto lab9999;
+        goto final_end;
 
-      cur_input.limit_field = last;
+      limit = last;
       first = last + 1;
     }
     
-    if ((format_ident == 0) ||
-        (buffer[cur_input.loc_field] == '&') ||
-        (buffer[cur_input.loc_field] == '+'))
+    if ((format_ident == 0) || (buffer[loc] == '&') ||
+      (buffer[loc] == '+'))
     {
       if (format_ident != 0)
         initialize();
 
       if (!open_fmt_file ())
-        goto lab9999;
+        goto final_end;
 
       if (!load_fmt_file ())
       {
@@ -2498,7 +2274,7 @@ lab1:
 #else
         w_close(fmt_file);
 #endif
-        goto lab9999;
+        goto final_end;
       }
 
 #ifdef COMPACTFORMAT
@@ -2507,15 +2283,14 @@ lab1:
       w_close(fmt_file);
 #endif
 
-      while ((cur_input.loc_field < cur_input.limit_field) &&
-          (buffer[cur_input.loc_field] == ' '))
-        incr(cur_input.loc_field);
+      while ((loc < limit) && (buffer[loc] == ' '))
+        incr(loc);
     }
 
-    if ((end_line_char < 0) || (end_line_char > 255))
-      decr(cur_input.limit_field);
+    if (end_line_char_inactive())
+      decr(limit);
     else
-      buffer[cur_input.limit_field] = end_line_char;
+      buffer[limit] = end_line_char;
 
     fix_date_and_time();
     magic_offset = str_start[886] - 9 * ord_noad;
@@ -2525,8 +2300,7 @@ lab1:
     else
       selector = term_only;
 
-    if ((cur_input.loc_field < cur_input.limit_field) &&
-      (cat_code(buffer[cur_input.loc_field]) != escape))
+    if ((loc < limit) && (cat_code(buffer[loc]) != escape))
       start_input();
   }
 
@@ -2534,7 +2308,7 @@ lab1:
     show_frozen();
 
   main_time = clock();
-  history = 0;
+  history = spotless;
 
   if (show_cs_names)
     print_cs_names(stdout, 0);
@@ -2545,10 +2319,9 @@ lab1:
     print_cs_names(stdout, 1);
 
   final_cleanup();
-
   close_files_and_terminate();
 
-lab9999:
+final_end:
   {
     int code;
 
@@ -2582,10 +2355,10 @@ void add_variable_space(int size)
 
   mem_min = t - (size + 1);     /* first word in new block - 1 */
 
-  if (mem_min < mem_start)      /* sanity test */
+  if (mem_min < mem_start)
   {
     if (trace_flag)
-      show_line("WARNING: mem_min < mem_start!\n", 0);
+      puts("WARNING: mem_min < mem_start!");
 
     mem_min = mem_start;
   }
@@ -2604,15 +2377,13 @@ void add_variable_space(int size)
 }
 #endif
 
-/**************************************************************************/
-
 #ifdef INITEX
 /* split out to allow sharing of code from do_initex and newpattern */
 void reset_trie (void)
 {
   integer k;
 
-  for (k = - (integer) trie_op_size; k <= trie_op_size; k++)
+  for (k = -(integer)trie_op_size; k <= trie_op_size; k++)
     trie_op_hash[k] = 0;
 
   for (k = 0; k <= 255; k++)
@@ -2627,7 +2398,7 @@ void reset_trie (void)
   trie_not_ready = true;
 }
 /* borrowed code from initialize() */
-void reset_hyphen (void)
+void reset_hyphen(void)
 {
   hyph_pointer z;
 
@@ -2659,15 +2430,15 @@ void do_initex (void)
     k = k + glue_spec_size;
   }
 
-  stretch(fil_glue) = 65535L;
+  stretch(fil_glue) = unity;
   stretch_order(fil_glue) = fil;
-  stretch(fill_glue) = 65535L;
+  stretch(fill_glue) = unity;
   stretch_order(fill_glue) = fill;
-  stretch(ss_glue) = 65535L;
+  stretch(ss_glue) = unity;
   stretch_order(ss_glue) = fil;
-  shrink(ss_glue) = 65535L;
+  shrink(ss_glue) = unity;
   shrink_order(ss_glue) = fil;
-  stretch(fil_neg_glue) = -65536L;
+  stretch(fil_neg_glue) = -unity;
   stretch_order(fil_neg_glue) = fil;
   rover = lo_mem_stat_max + 1;
   link(rover) = empty_flag;
@@ -2692,7 +2463,7 @@ void do_initex (void)
   link(mem_top) = page_ins_head;
   type(page_head) = glue_node;
   subtype(page_head) = normal;
-  avail = 0;                   /* avail <- null p.164 */
+  avail = 0;
   mem_end = mem_top;
   hi_mem_min = hi_mem_stat_min;
   var_used = lo_mem_stat_max + 1 - mem_bot;
@@ -2793,7 +2564,7 @@ void do_initex (void)
   cs_count = 0;
 
   if (trace_flag)
-    show_line("initex cs_count = 0 ", 0);
+    puts("initex cs_count = 0 ");
 
   eq_type(frozen_dont_expand) = dont_expand;
   text(frozen_dont_expand) = 499;  /* notexpanded */
@@ -2822,6 +2593,10 @@ void do_initex (void)
   font_glue[null_font]        = 0;
   font_params[null_font]      = 7;
   param_base[null_font]       = -1;
+
+  for (k = 0; k <= 6; k++)
+    font_info[k].cint = 0;
+
   reset_trie();
   text(frozen_protection) = 1184; /* "inaccessible" */
   format_ident = 1251;
@@ -2834,7 +2609,7 @@ void do_initex (void)
 
 #ifdef INITEX
 /* sec 0047 */
-bool get_strings_started (void)
+boolean get_strings_started (void)
 {
   integer k;
   str_number g;
@@ -2883,8 +2658,8 @@ bool get_strings_started (void)
 /* sec 0131 */
 void sort_avail (void)
 {
-  halfword p, q, r;
-  halfword old_rover;
+  pointer p, q, r;
+  pointer old_rover;
 
   p = get_node(1073741824L); /* 2^30 merge adjacent free nodes */
   p = rlink(rover);
@@ -2925,24 +2700,9 @@ void sort_avail (void)
   rlink(p) = rover;
   llink(rover) = p;
 }
-#endif /* INITEX */
+#endif
 
 #ifdef INITEX
-str_number make_string_pool (char *s)
-{
-  int slen = strlen(s);
-
-  if (slen == 1)
-  {
-    return ((str_number)s[0]);
-  }
-  else
-  {
-    memcpy(str_pool + pool_ptr, s, slen);
-    pool_ptr += slen;
-    return (make_string());
-  }
-}
 /* sec 0264 */
 void primitive_ (str_number s, quarterword c, halfword o)
 { 
@@ -2966,7 +2726,7 @@ void primitive_ (str_number s, quarterword c, halfword o)
 
 #ifdef SHORTHASH
     if (s > 65535L)
-      show_line("ERROR: hash entry too large\n", 1);
+      puts("ERROR: hash entry too large\n");
 #endif
 
     text(cur_val) = s;
@@ -2997,7 +2757,7 @@ trie_op_code new_trie_op_ (small_number d, small_number n, trie_op_code v)
       if (trie_op_ptr == trie_op_size)
       {
         overflow("pattern memory ops", trie_op_size);
-        return 0;     // abort_flag set
+        return 0;
       }
 
       u = trie_used[cur_lang];
@@ -3005,7 +2765,7 @@ trie_op_code new_trie_op_ (small_number d, small_number n, trie_op_code v)
       if (u == max_trie_op)
       {
         overflow("pattern memory ops per language", max_trie_op - min_trie_op);
-        return 0;     // abort_flag set
+        return 0;
       }
 
       incr(trie_op_ptr);
@@ -3102,7 +2862,7 @@ void first_fit_ (trie_pointer p)
       {
         overflow("pattern memory", trie_size);
 /*      not dynamic ---- but can be set -h=... from command line in ini-TeX */
-        return;     // abort_flag set
+        return;
       }
 
       do
@@ -3116,49 +2876,54 @@ void first_fit_ (trie_pointer p)
     }
 
     if (trie_taken[h])
-      goto lab45;
+      goto not_found;
 
     q = trie_r[p];
 
     while (q > 0)
     {
       if (trie_trl[h + trie_c[q]] == 0)
-        goto lab45;
+        goto not_found;
 
       q = trie_r[q];
     }
 
-    goto lab40;
-lab45:
+    goto found;
+not_found:
     z = trie_trl[z];
   }
-lab40:
+found:
   trie_taken[h] = true; /* h may be used without ... */
   trie_hash[p] = h;
   q = p;
 
-  do {
-    z = h + trie_c[q];
-    l = trie_tro[z];
-    r = trie_trl[z];
-    trie_tro[r] = l;
-    trie_trl[l] = r;
-    trie_trl[z] = 0;
-
-    if (l < 256)
+  do
     {
-      if (z < 256)
-        ll = z;         /* short ll */
-      else
-        ll = 256;
+      z = h + trie_c[q];
+      l = trie_tro[z];
+      r = trie_trl[z];
+      trie_tro[r] = l;
+      trie_trl[l] = r;
+      trie_trl[z] = 0;
 
-      do {
-        trie_min[l] = r;
-        incr(l);
-      } while (!(l == ll));
+      if (l < 256)
+      {
+        if (z < 256)
+          ll = z;         /* short ll */
+        else
+          ll = 256;
+
+        do
+          {
+            trie_min[l] = r;
+            incr(l);
+          }
+        while (!(l == ll));
+      }
+
+      q = trie_r[q];
     }
-    q = trie_r[q];
-  } while (!(q == 0));
+  while (!(q == 0));
 }
 /* sec 0957 */
 void trie_pack_ (trie_pointer p)
@@ -3177,7 +2942,7 @@ void trie_pack_ (trie_pointer p)
 
       p = trie_r[p];
     }
-  while(!(p == 0));
+  while (!(p == 0));
 }
 /* sec 0959 */
 void trie_fix_ (trie_pointer p)
@@ -3201,7 +2966,7 @@ void trie_fix_ (trie_pointer p)
 
       p = trie_r[p];
     }
-  while(!(p == 0));
+  while (!(p == 0));
 }
 /* sec 0960 */
 void new_patterns (void)
@@ -3210,10 +2975,10 @@ void new_patterns (void)
 /*  was small_number k, l;  in 3.141 */
   char k, l;
 /* ******************************************************************* */
-  bool digitsensed;
+  boolean digitsensed;
   trie_op_code v;
   trie_pointer p, q;
-  bool firstchild;
+  boolean firstchild;
 /*  ASCII_code c;  */
   int c;                /* 95/Jan/7 */
 
@@ -3222,14 +2987,14 @@ void new_patterns (void)
     if (allow_patterns)
     {
       if (trace_flag)
-        show_line("Resetting patterns\n", 0);
+        puts("Resetting patterns\n");
 
       reset_trie();         /* RESET PATTERNS -  93/Nov/26 */
 
       if (reset_exceptions)
       {
         if (trace_flag)
-          show_line("Resetting exceptions\n", 0);
+          puts("Resetting exceptions\n");
 
         reset_hyphen();     /* RESET HYPHENEXCEPTIONS -  93/Nov/26 */
       }
@@ -3303,9 +3068,9 @@ void new_patterns (void)
                 if (l > 0)
                   decr(l);
                 else
-                  goto lab31;
+                  goto done1;
               }
-lab31:
+done1:
               q = 0;
               hc[0] = cur_lang;
 
@@ -3327,7 +3092,7 @@ lab31:
                   {
                     overflow("pattern memory", trie_size);  /* pattern memory - NOT DYNAMIC */
 /*      not dynamic ---- but can be set -h=... from command line in ini-TeX */
-                    return;     // abort_flag set
+                    return;
                   }
 
                   incr(trie_ptr);
@@ -3357,7 +3122,7 @@ lab31:
             }
 
             if (cur_cmd == right_brace)
-              goto lab30;
+              goto done;
 
             k = 0;
             hyf[0] = 0;
@@ -3374,7 +3139,7 @@ lab31:
           break;
       }
     }
-lab30:;
+done:;
   }
   else
   {
@@ -3478,29 +3243,29 @@ void init_trie (void)
 
         r = s;
       }
-    while(!(r > trie_max));
+    while (!(r > trie_max));
   }
+
   trie_trc[0] = 63;
   trie_not_ready = false;
 }
-#endif /* INITEX */
+#endif
 
 #ifdef INITEX
 /* sec 1302 */
 void store_fmt_file (void)
 {
   integer j, k, l;
-  halfword p, q;
+  pointer p, q;
   integer x;
 
-  if (!is_initex)   /* redundant check 94/Feb/14 */
+  if (!is_initex)
   {
-    show_line("! \\dump is performed only by INITEX\n", 1);
+    puts("! \\dump is performed only by INITEX\n");
 
-    if (! knuth_flag)
-      show_line("  (Use -i on the command line)\n", 0);
+    if (!knuth_flag)
+      puts("  (Use -i on the command line)\n");
 
-    abort_flag++;
     return;
   }
 
@@ -3531,7 +3296,7 @@ void store_fmt_file (void)
   format_ident = make_string();
   pack_job_name(".fmt");
 
-  while(!w_open_out(fmt_file))
+  while (!w_open_out(fmt_file))
   {
     prompt_file_name("format file name", ".fmt");
   }
@@ -3542,14 +3307,12 @@ void store_fmt_file (void)
   print_nl("");
   slow_print(format_ident);
 
-  dump_int(BEGINFMTCHECKSUM); /* magic FMT file start 4C 20 E6 15 hex */
-
+  dump_int(BEGINFMTCHECKSUM);
   dump_int(mem_bot);
   dump_int(mem_top);
   dump_int(eqtb_size);
   dump_int(hash_prime);
-  dump_int(hyphen_prime);   /* bkph */
-
+  dump_int(hyphen_prime);
   dump_int(pool_ptr);
   dump_int(str_ptr);
 
@@ -3579,8 +3342,8 @@ void store_fmt_file (void)
 
       x = x + q + 2 - p;
       var_used = var_used + q - p;
-      p = q + mem[q].hh.v.LH;
-      q = mem[q + 1].hh.v.RH;
+      p = q + node_size(q);
+      q = rlink(q);
     }
   while (!(q == rover));
 
@@ -3592,7 +3355,7 @@ void store_fmt_file (void)
 
   x = x + lo_mem_max + 1 - p;
   dump_int(hi_mem_min);
-  dump_int(avail);
+  dump_int(avail); 
 
   if (dumpthings(mem[hi_mem_min], mem_end + 1 - hi_mem_min))
     return;
@@ -3603,7 +3366,7 @@ void store_fmt_file (void)
   while (p != 0)
   {
     decr(dyn_used);
-    p = mem[p].hh.v.RH;
+    p = mem[p].hh.rh;
   }
 
   dump_int(var_used);
@@ -3626,13 +3389,13 @@ void store_fmt_file (void)
         if ((equiv(j) == equiv(j + 1)) &&
           (eq_type(j) == eq_type(j + 1)) &&
           (eq_level(j) == eq_level(j + 1)))
-          goto lab41;
+          goto found1;
         incr(j);
       }
 
       l = (int_base);
-      goto lab31;
-lab41:
+      goto done1;
+found1:
       incr(j);
       l = j;
       while (j < (int_base - 1))
@@ -3640,10 +3403,10 @@ lab41:
         if ((equiv(j) != equiv(j + 1)) ||
           (eq_type(j) != eq_type(j + 1)) ||
           (eq_level(j) != eq_level(j + 1)))
-          goto lab31;
+          goto done1;
         incr(j);
       }
-lab31:
+done1:
       dump_int(l - k);
 
       if (dumpthings(eqtb[k], l - k))
@@ -3654,30 +3417,39 @@ lab31:
     }
   while (!(k == (int_base)));
 
-  do {
-    j = k;
-    while (j < (eqtb_size)) {
-      if (eqtb[j].cint == eqtb[j + 1].cint)
-        goto lab42;
-      incr(j);
-    }
-    l = (eqtb_size + 1);
-    goto lab32;
-lab42:
-    incr(j);
-    l = j;
-    while (j < (eqtb_size)) {
-      if (eqtb[j].cint != eqtb[j + 1].cint)
-        goto lab32;
+  do
+    {
+      j = k;
+
+      while (j < (eqtb_size))
+      {
+        if (eqtb[j].cint == eqtb[j + 1].cint)
+          goto found2;
+        incr(j);
+      }
+
+      l = (eqtb_size + 1);
+      goto done2;
+found2:
       incr(j);
+      l = j;
+
+      while (j < (eqtb_size))
+      {
+        if (eqtb[j].cint != eqtb[j + 1].cint)
+          goto done2;
+        incr(j);
+      }
+done2:
+      dump_int(l - k);
+
+      if (dumpthings(eqtb[k], l - k))
+        return;
+
+      k = j + 1;
+      dump_int(k - l);
     }
-lab32:
-    dump_int(l - k);
-    if (dumpthings(eqtb[k], l - k))
-      return;
-    k = j + 1;
-    dump_int(k - l);
-  } while (!(k > (eqtb_size)));
+  while (!(k > (eqtb_size)));
 
   dump_int(par_loc);
   dump_int(write_loc);
@@ -3686,31 +3458,23 @@ lab32:
   cs_count = frozen_control_sequence - 1 - hash_used;
 
   if (trace_flag)
-  {
-    sprintf(log_line, "itex cs_count %d hash_size %d hash_extra %d hash_used %d",
+    printf("itex cs_count %d hash_size %d hash_extra %d hash_used %d",
         cs_count, hash_size, hash_extra, hash_used);
-    show_line(log_line, 0);
-  }
 
   for (p = hash_base; p <= hash_used; p++)
   {
-    if (hash[p].v.RH != 0)
+    if (text(p) != 0)
     {
       dump_int(p);
       dump_hh(hash[p]);
       incr(cs_count);
 
       if (trace_flag)
-      {
-        sprintf(log_line, "itex cs_count++ ");
-        show_line(log_line, 0); /* debugging */
-      }
-
+        puts("itex cs_count++ ");
     }
   }
-/*  ??? */
-/* for p <- hash_used+1 to undefined_control_sequence-1 do dump_hh(hash[p]) */
-  if (dumpthings(hash[hash_used + 1], (hash_size + 780) - hash_used))
+
+  if (dumpthings(hash[hash_used + 1], undefined_control_sequence - 1 - hash_used))
     return;
 
   dump_int(cs_count);
@@ -3719,6 +3483,7 @@ lab32:
   print_string(" multiletter control sequences");
 
   dump_int(fmem_ptr);
+
   {
     if (dumpthings(font_info[0], fmem_ptr))
       return;
@@ -3797,9 +3562,8 @@ lab32:
     for (k = 0; k <= font_ptr; k++)
     {
       print_nl("\\font");
-/*  print_esc(hash[(hash_size + 524) + k].v.RH);  */
-/*  print_esc(hash[(hash_size + hash_extra + 524) + k].v.RH); */
-      print_esc("");print(hash[(hash_size + hash_extra + 524) + k].v.RH);
+      print_esc("");
+      print(font_id_text(k));
       print_char('=');
       print_file_name(font_name[k], font_area[k], 335);
 
@@ -3892,7 +3656,7 @@ lab32:
 
   dump_int(interaction);
   dump_int(format_ident);
-  dump_int(ENDFMTCHECKSUM); /* magic checksum end of FMT file --- change ??? */ 
+  dump_int(ENDFMTCHECKSUM);
   tracing_stats = 0;
 
 #ifdef COMPACTFORMAT
@@ -3901,13 +3665,14 @@ lab32:
   w_close(fmt_file);
 #endif
 }
-#endif /* INITEX */
+#endif
 
 #ifdef INITEX
 /* sec 01336 */
 void init_prim (void)
 {
   no_new_control_sequence = false;
+  /* sec 0266 */
   primitive("lineskip", assign_glue, glue_base + line_skip_code);
   primitive("baselineskip", assign_glue, glue_base + baseline_skip_code);
   primitive("parskip", assign_glue, glue_base + par_skip_code);
@@ -3926,6 +3691,7 @@ void init_prim (void)
   primitive("thinmuskip", assign_mu_glue, glue_base + thin_mu_skip_code);
   primitive("medmuskip", assign_mu_glue, glue_base + med_mu_skip_code);
   primitive("thickmuskip", assign_mu_glue, glue_base + thick_mu_skip_code);
+  /* sec 0230 */
   primitive("output", assign_toks, output_routine_loc);
   primitive("everypar", assign_toks, every_par_loc);
   primitive("everymath", assign_toks, every_math_loc);
@@ -3935,6 +3701,7 @@ void init_prim (void)
   primitive("everyjob", assign_toks, every_job_loc);
   primitive("everycr", assign_toks, every_cr_loc);
   primitive("errhelp", assign_toks, err_help_loc);
+  /* sec 0238 */
   primitive("pretolerance", assign_int, int_base + pretolerance_code);
   primitive("tolerance", assign_int, int_base + tolerance_code);
   primitive("linepenalty", assign_int, int_base + line_penalty_code);
@@ -3990,6 +3757,7 @@ void init_prim (void)
   primitive("righthyphenmin", assign_int, int_base + right_hyphen_min_code);
   primitive("holdinginserts", assign_int, int_base + holding_inserts_code);
   primitive("errorcontextlines", assign_int, int_base + error_context_lines_code);
+  /* sec 0248 */
   primitive("parindent", assign_dimen, dimen_base + par_indent_code);
   primitive("mathsurround", assign_dimen, dimen_base + math_surround_code);
   primitive("lineskiplimit", assign_dimen, dimen_base + line_skip_limit_code);
@@ -4226,10 +3994,10 @@ void init_prim (void)
   primitive("lccode", def_code, lc_code_base);
   primitive("uccode", def_code, uc_code_base);
   primitive("sfcode", def_code, sf_code_base);
-  primitive("delcode", def_code, (hash_size + 3474));
-  primitive("textfont", def_family, (hash_size + 1835));
-  primitive("scriptfont", def_family, (hash_size + 1851));
-  primitive("scriptscriptfont", def_family, (hash_size + 1867));
+  primitive("delcode", def_code, del_code_base);
+  primitive("textfont", def_family, math_font_base);
+  primitive("scriptfont", def_family, math_font_base + script_size);
+  primitive("scriptscriptfont", def_family, math_font_base + script_script_size);
   primitive("hyphenation", hyph_data, 0);
   primitive("patterns", hyph_data, 1);
   primitive("hyphenchar", assign_font_int, 0);
@@ -4242,8 +4010,8 @@ void init_prim (void)
   primitive("closein", in_stream, 0);
   primitive("message", message, 0);
   primitive("errmessage", message, 1);
-  primitive("lowercase", case_shift, (hash_size + 2139));
-  primitive("uppercase", case_shift, (hash_size + 2395));
+  primitive("lowercase", case_shift, lc_code_base);
+  primitive("uppercase", case_shift, uc_code_base);
   primitive("show", xray, 0);
   primitive("showbox", xray, 1);
   primitive("showthe", xray, 2);