OSDN Git Service

redesigning header.
[putex/putex.git] / src / texsourc / tex8.c
index 3f90335..29975b4 100644 (file)
-#ifdef _WINDOWS
-  #define NOCOMM
-  #define NOSOUND
-  #define NODRIVERS
-  #define STRICT
-  #pragma warning(disable:4115) // kill rpcasync.h complaint
-  #include <windows.h>
-  #define MYLIBAPI __declspec(dllexport)
-#endif
-
-#include "texwin.h"
 
 #pragma warning(disable:4996)
 #pragma warning(disable:4131) // old style declarator
 #pragma warning(disable:4135) // conversion between different integral types 
 #pragma warning(disable:4127) // conditional expression is constant
 
-#include <setjmp.h>
-
 #define EXTERN extern
 
 #include "texd.h"
 
 #pragma warning(disable:4244)       /* 96/Jan/10 */
 
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-
-/* math_fraction etc used to be in tex7.c */
 /* sec 1181 */
-void math_fraction (void) 
+void math_fraction (void)
 {
-  small_number c; 
-  c = cur_chr; 
-  if (cur_list.aux_field.cint != 0)
+  small_number c;
+
+  c = cur_chr;
+
+  if (incompleat_noad != 0)
   {
-    if (c >= 3)
+    if (c >= delimited_code)
     {
-      scan_delimiter(lig_trick, false); 
-      scan_delimiter(lig_trick, false); 
-    } 
-    if (c % 3 == 0)
+      scan_delimiter(garbage, false);
+      scan_delimiter(garbage, false);
+    }
+
+    if (c % delimited_code == 0)
       scan_dimen(false, false, false);
+
     print_err("Ambiguous; you need another { and }");
     help3("I'm ignoring this fraction specification, since I don't",
       "know whether a construction like `x \\over y \\over z'",
       "means `{x \\over y} \\over z' or `x \\over {y \\over z}'.");
     error();
-  } else {
-    cur_list.aux_field.cint = get_node(6);
-    mem[cur_list.aux_field.cint].hh.b0 = 25;
-    mem[cur_list.aux_field.cint].hh.b1 = 0;
-    mem[cur_list.aux_field.cint + 2].hh.v.RH = 3;
-    mem[cur_list.aux_field.cint + 2].hh.v.LH = mem[head].hh.v.RH;
-    mem[cur_list.aux_field.cint + 3].hh = empty_field;
-    mem[cur_list.aux_field.cint + 4].qqqq = null_delimiter;
-    mem[cur_list.aux_field.cint + 5].qqqq = null_delimiter;
-    mem[head].hh.v.RH = 0;
+  }
+  else
+  {
+    incompleat_noad = get_node(fraction_noad_size);
+    type(incompleat_noad) = fraction_noad;
+    subtype(incompleat_noad) = normal;
+    math_type(numerator(incompleat_noad)) = sub_mlist;
+    info(numerator(incompleat_noad)) = link(head);
+    mem[denominator(incompleat_noad)].hh = empty_field;
+    mem[left_delimiter(incompleat_noad)].qqqq = null_delimiter;
+    mem[right_delimiter(incompleat_noad)].qqqq = null_delimiter;
+    link(head) = 0;
     tail = head;
-    if (c >= 3) {
-      scan_delimiter(cur_list.aux_field.cint + 4, false);
-      scan_delimiter(cur_list.aux_field.cint + 5, false);
+
+    if (c >= delimited_code)
+    {
+      scan_delimiter(left_delimiter(incompleat_noad), false);
+      scan_delimiter(right_delimiter(incompleat_noad), false);
     }
-    switch(c % 3)
+
+    switch(c % delimited_code)
     {
-    case 0:
-      {
+      case above_code:
         scan_dimen(false, false, false);
-        mem[cur_list.aux_field.cint + 1].cint = cur_val;
-      }
-      break;
-    case 1:
-      mem[cur_list.aux_field.cint + 1].cint = 1073741824L;  /* 2^30 */
-      break;
-    case 2:
-      mem[cur_list.aux_field.cint + 1].cint = 0;
-      break;
+        thickness(incompleat_noad) = cur_val;
+        break;
+
+      case over_code:
+        thickness(incompleat_noad) = default_code;
+        break;
+
+      case atop_code:
+        thickness(incompleat_noad) = 0;
+        break;
     }
   }
 }
 /* sec 1191 */
-void math_left_right (void) 
-{ 
-  small_number t; 
-  halfword p; 
-  t = cur_chr; 
-  if ((t == 31) && (cur_group != 16)) {
-    if (cur_group == 15) {
-      scan_delimiter(lig_trick, false);
+void math_left_right (void)
+{
+  small_number t;
+  halfword p;
+
+  t = cur_chr;
+
+  if ((t == right_noad) && (cur_group != math_left_group))
+  {
+    if (cur_group == math_shift_group)
+    {
+      scan_delimiter(garbage, false);
       print_err("Extra ");
       print_esc("right");
       help1("I'm ignoring a \\right that had no matching \\left.");
       error();
-    } else {
+    }
+    else
+    {
       off_save();
     }
-  } else {
+  }
+  else
+  {
     p = new_noad();
-    mem[p].hh.b0 = t;
-    scan_delimiter(p + 1, false);
-    if (t == 30) {
-      push_math(16);
-      mem[head].hh.v.RH = p;
+    type(p) = t;
+    scan_delimiter(delimiter(p), false);
+
+    if (t == left_noad)
+    {
+      push_math(math_left_group);
+      link(tail) = p;
       tail = p;
-    } else {
+    }
+    else
+    {
       p = fin_mlist(p);
       unsave();
-      {
-        mem[tail].hh.v.RH = new_noad();
-        tail = mem[tail].hh.v.RH;
-      }
-      mem[tail].hh.b0 = 23;
-      mem[tail + 1].hh.v.RH = 3;
-      mem[tail + 1].hh.v.LH = p;
+      tail_append(new_noad());
+      type(tail) = inner_noad;
+      math_type(nucleus(tail)) = sub_mlist;
+      info(nucleus(tail)) = p;
     }
   }
 }
 /* sec 1194 */
-void after_math (void) 
-{ 
-  bool l; 
-  bool danger; 
-  integer m; 
-  halfword p; 
-  halfword a; 
-  halfword b; 
-  scaled w; 
-  scaled z; 
-  scaled e; 
-  scaled q; 
-  scaled d; 
-  scaled s; 
-  small_number g1, g2; 
-  halfword r; 
-  halfword t; 
-  danger = false; 
-  if ((font_params[eqtb[(hash_size + 1837)].hh.v.RH]< 22)||
-    (font_params[eqtb[(hash_size + 1853)].hh.v.RH]< 22)||
-    (font_params[eqtb[(hash_size + 1869)].hh.v.RH]< 22)) 
+void after_math (void)
+{
+  bool l;
+  bool danger;
+  integer m;
+  halfword p;
+  halfword a;
+  halfword b;
+  scaled w;
+  scaled z;
+  scaled e;
+  scaled q;
+  scaled d;
+  scaled s;
+  small_number g1, g2;
+  halfword r;
+  halfword t;
+
+  danger = false;
+  
+  if ((font_params[fam_fnt(2 + text_size)] < total_mathsy_params) ||
+    (font_params[fam_fnt(2 + script_size)] < total_mathsy_params) ||
+    (font_params[fam_fnt(2 + script_script_size)] < total_mathsy_params))
   {
-         print_err("Math formula deleted: Insufficient symbol fonts");
-         help3("Sorry, but I can't typeset math unless \\textfont Sorry, but I can't typeset math unless \\textfont 2",
-                 "and \\scriptfont 2 and \\scriptscriptfont 2 have and \\scriptfont 2 and \\scriptscriptfont 2 have all",
-                 "the \\fontdimen values needed in math symbol the \\fontdimen values needed in math symbol fonts.."); 
-    error(); 
-    flush_math(); 
-    danger = true; 
-  } 
-  else if ((font_params[eqtb[(hash_size + 1838)].hh.v.RH]< 13)||
-      (font_params[eqtb[(hash_size + 1854)].hh.v.RH]< 13)||
-      (font_params[eqtb[(hash_size + 1870)].hh.v.RH]< 13)) 
+    print_err("Math formula deleted: Insufficient symbol fonts");
+    help3("Sorry, but I can't typeset math unless \\textfont 2",
+        "and \\scriptfont 2 and \\scriptscriptfont 2 have all",
+        "the \\fontdimen values needed in math symbol fonts.");
+    error();
+    flush_math();
+    danger = true;
+  }
+  else if ((font_params[fam_fnt(3 + text_size)] < total_mathex_params) ||
+    (font_params[fam_fnt(3 + script_size)] < total_mathex_params) ||
+    (font_params[fam_fnt(3 + script_script_size)] < total_mathex_params))
   {
-         print_err("Math formula deleted: Insufficient extension fonts");
-         help3("Sorry, but I can't typeset math unless \\textfont 3",
-                 "and \\scriptfont 3 and \\scriptscriptfont 3 have all",
-                 "the \\fontdimen values needed in math extension fonts.");
-    error(); 
-    flush_math(); 
-    danger = true; 
-  } 
-  m = mode; 
-  l = false; 
-  p = fin_mlist(0); 
+    print_err("Math formula deleted: Insufficient extension fonts");
+    help3("Sorry, but I can't typeset math unless \\textfont 3",
+        "and \\scriptfont 3 and \\scriptscriptfont 3 have all",
+        "the \\fontdimen values needed in math extension fonts.");
+    error();
+    flush_math();
+    danger = true;
+  }
+
+  m = mode;
+  l = false;
+  p = fin_mlist(0);
+
   if (mode == - (integer) m)
   {
     {
-      get_x_token(); 
-      if (cur_cmd != 3)
+      get_x_token();
+
+      if (cur_cmd != math_shift)
       {
-                 print_err("Display math should end with $$");
-                 help2("The `$' that I just saw supposedly matches a previous `$$'.",
-                         "So I shall assume that you typed `$$' both times.");
-  back_error(); 
-      } 
-    } 
-    cur_mlist = p; 
-    cur_style = 2; 
-    mlist_penalties = false; 
-    mlist_to_hlist(); 
-    a = hpack(mem[temp_head].hh.v.RH, 0, 1); 
-    unsave(); 
-    decr(save_ptr); 
-    if (save_stack[save_ptr + 0].cint == 1)
-    l = true; 
-    danger = false; 
-    if ((font_params[eqtb[(hash_size + 1837)].hh.v.RH]< 22)||
-    (font_params[eqtb[(hash_size + 1853)].hh.v.RH]< 22)||
-    (font_params[eqtb[(hash_size + 1869)].hh.v.RH]< 22)) 
-    {
-               print_err("Math formula deleted: Insufficient symbol fonts");
-               help3("Sorry, but I can't typeset math unless \\textfont 2",
-                       "and \\scriptfont 2 and \\scriptscriptfont 2 have all",
-                       "the \\fontdimen values needed in math symbol fonts.");
-      error(); 
-      flush_math(); 
-      danger = true; 
-    } 
-    else if ((font_params[eqtb[(hash_size + 1838)].hh.v.RH]< 13)||
-       (font_params[eqtb[(hash_size + 1854)].hh.v.RH]< 13)|| 
-       (font_params[eqtb[(hash_size + 1870)].hh.v.RH]< 13)) 
-    {
-               print_err("Math formula deleted: Insufficient extension fonts");
-               help3("Sorry, but I can't typeset math unless \\textfont 3",
-                       "and \\scriptfont 3 and \\scriptscriptfont 3 have all",
-                       "the \\fontdimen values needed in math extension fonts.");
-      error(); 
-      flush_math(); 
-      danger = true; 
-    } 
-    m = mode; 
-    p = fin_mlist(0); 
-  } 
-  else a = 0; 
+        print_err("Display math should end with $$");
+        help2("The `$' that I just saw supposedly matches a previous `$$'.",
+            "So I shall assume that you typed `$$' both times.");
+        back_error();
+      }
+    }
+
+    cur_mlist = p;
+    cur_style = text_style;
+    mlist_penalties = false;
+    mlist_to_hlist();
+    a = hpack(link(temp_head), 0, 1);
+    unsave();
+    decr(save_ptr);
+
+    if (saved(0) == 1)
+      l = true;
+
+    danger = false;
+
+    if ((font_params[fam_fnt(2 + text_size)] < total_mathsy_params) ||
+      (font_params[fam_fnt(2 + script_size)] < total_mathsy_params) ||
+      (font_params[fam_fnt(2 + script_script_size)] < total_mathsy_params))
+    {
+      print_err("Math formula deleted: Insufficient symbol fonts");
+      help3("Sorry, but I can't typeset math unless \\textfont 2",
+          "and \\scriptfont 2 and \\scriptscriptfont 2 have all",
+          "the \\fontdimen values needed in math symbol fonts.");
+      error();
+      flush_math();
+      danger = true;
+    }
+    else if ((font_params[fam_fnt(3 + text_size)] < total_mathex_params) ||
+      (font_params[fam_fnt(3 + script_size)] < total_mathex_params) ||
+      (font_params[fam_fnt(3 + script_script_size)] < total_mathex_params))
+    {
+      print_err("Math formula deleted: Insufficient extension fonts");
+      help3("Sorry, but I can't typeset math unless \\textfont 3",
+        "and \\scriptfont 3 and \\scriptscriptfont 3 have all",
+        "the \\fontdimen values needed in math extension fonts.");
+      error();
+      flush_math();
+      danger = true;
+    }
+
+    m = mode;
+    p = fin_mlist(0);
+  }
+  else
+    a = 0;
+
   if (m < 0)
   {
-    {
-      mem[tail].hh.v.RH = new_math(math_surround, 0); 
-      tail = mem[tail].hh.v.RH; 
-    } 
-    cur_mlist = p; 
-    cur_style = 2; 
-    mlist_penalties =(mode > 0); 
-    mlist_to_hlist(); 
-    mem[tail].hh.v.RH = mem[temp_head].hh.v.RH; 
-    while(mem[tail].hh.v.RH != 0)tail = 
-    mem[tail].hh.v.RH; 
-    {
-      mem[tail].hh.v.RH = new_math(math_surround, 1); 
-      tail = mem[tail].hh.v.RH; 
-    } 
-    space_factor = 1000; 
-    unsave(); 
-  } 
-  else {
-      
+    tail_append(new_math(math_surround, 0));
+    cur_mlist = p;
+    cur_style = text_style;
+    mlist_penalties = (mode > 0);
+    mlist_to_hlist();
+    link(tail) = link(temp_head);
+
+    while(link(tail) != 0)
+      tail = link(tail);
+
+    tail_append(new_math(math_surround, 1));
+    space_factor = 1000;
+    unsave();
+  }
+  else
+  {
     if (a == 0)
     {
-      get_x_token(); 
-      if (cur_cmd != 3) {
-                 print_err("Display math should end with $$");
-                 help2("The `$' that I just saw supposedly matches a previous `$$'.",
-                         "So I shall assume that you typed `$$' both times.");
-  back_error(); 
-      } 
-    } 
-    cur_mlist = p; 
-    cur_style = 0; 
-    mlist_penalties = false; 
-    mlist_to_hlist(); 
-    p = mem[temp_head].hh.v.RH; 
-    adjust_tail = adjust_head; 
-    b = hpack(p, 0, 1); 
-    p = mem[b + 5].hh.v.RH; 
-    t = adjust_tail; 
-    adjust_tail = 0; 
-    w = mem[b + 1].cint; 
-    z = display_width; 
-    s = display_indent; 
-    if ((a == 0)|| danger)
+      get_x_token();
+
+      if (cur_cmd != math_shift)
+      {
+        print_err("Display math should end with $$");
+        help2("The `$' that I just saw supposedly matches a previous `$$'.",
+            "So I shall assume that you typed `$$' both times.");
+        back_error();
+      }
+    }
+
+    cur_mlist = p;
+    cur_style = display_style;
+    mlist_penalties = false;
+    mlist_to_hlist();
+    p = link(temp_head);
+    adjust_tail = adjust_head;
+    b = hpack(p, 0, 1);
+    p = list_ptr(b);
+    t = adjust_tail;
+    adjust_tail = 0;
+    w = width(b);
+    z = display_width;
+    s = display_indent;
+
+    if ((a == 0) || danger)
+    {
+      e = 0;
+      q = 0;
+    }
+    else
     {
-      e = 0; 
-      q = 0; 
-    } 
-    else {
-  
-      e = mem[a + 1].cint; 
-      q = e + font_info[6 + param_base[eqtb[(hash_size + 1837)].hh.v.RH]].cint; 
-    } 
+      e = width(a);
+      q = e + math_quad(text_size);
+    }
+
     if (w + q > z)
     {
-      if ((e != 0)&&((w - totalshrink[0]+ q <= z)||(totalshrink 
-     [1]!= 0)||(totalshrink[2]!= 0)||(totalshrink[3]!= 0)
-    )) 
+      if ((e != 0) && ((w - total_shrink[normal] + q <= z) || (total_shrink[fil] != 0) || (total_shrink[fill] != 0) || (total_shrink[filll] != 0)))
       {
-  free_node(b, 7); 
-  b = hpack(p, z - q, 0); 
-      } 
-      else {
-    
-  e = 0; 
-  if (w > z)
-  {
-    free_node(b, 7); 
-    b = hpack(p, z, 0); 
-  } 
-      } 
-      w = mem[b + 1].cint; 
-    } 
-    d = half(z - w); 
-    if ((e > 0)&&(d < 2 * e)) 
+        free_node(b, box_node_size);
+        b = hpack(p, z - q, 0);
+      }
+      else
+      {
+        e = 0;
+
+        if (w > z)
+        {
+          free_node(b, box_node_size);
+          b = hpack(p, z, 0);
+        }
+      }
+      w = width(b);
+    }
+
+    d = half(z - w);
+
+    if ((e > 0) && (d < 2 * e))
     {
-      d = half(z - w - e); 
+      d = half(z - w - e);
+
       if (p != 0)
-      if (!(p >= hi_mem_min)) 
-      if (mem[p].hh.b0 == 10)
-      d = 0; 
-    } 
+        if (!(p >= hi_mem_min))
+          if (type(p) == glue_node)
+            d = 0;
+    }
+
+    tail_append(new_penalty(pre_display_penalty));
+
+    if ((d + s <= pre_display_size) || l)
     {
-      mem[tail].hh.v.RH = new_penalty(pre_display_penalty); 
-      tail = mem[tail].hh.v.RH; 
-    } 
-    if ((d + s <= pre_display_size)|| l)
+      g1 = above_display_skip_code;
+      g2 = below_display_skip_code;
+    }
+    else
     {
-      g1 = 3; 
-      g2 = 4; 
-    } 
-    else {
-  
-      g1 = 5; 
-      g2 = 6; 
-    } 
-    if (l &&(e == 0)) 
+      g1 = above_display_short_skip_code;
+      g2 = below_display_short_skip_code;
+    }
+    if (l && (e == 0))
     {
-      mem[a + 4].cint = s; 
-      append_to_vlist(a); 
-      {
-  mem[tail].hh.v.RH = new_penalty(10000); 
-  tail = mem[tail].hh.v.RH; 
-      } 
-    } 
-    else {
-  
-      mem[tail].hh.v.RH = new_param_glue(g1); 
-      tail = mem[tail].hh.v.RH; 
-    } 
+      shift_amount(a) = s;
+      append_to_vlist(a);
+      tail_append(new_penalty(10000));
+    }
+    else
+    {
+      tail_append(new_param_glue(g1));
+    }
+
     if (e != 0)
     {
-      r = new_kern(z - w - e - d); 
+      r = new_kern(z - w - e - d);
+
       if (l)
       {
-  mem[a].hh.v.RH = r; 
-  mem[r].hh.v.RH = b; 
-  b = a; 
-  d = 0; 
-      } 
-      else {
-    
-  mem[b].hh.v.RH = r; 
-  mem[r].hh.v.RH = a; 
-      } 
-      b = hpack(b, 0, 1); 
-    } 
-    mem[b + 4].cint = s + d; 
-    append_to_vlist(b); 
-    if ((a != 0)&&(e == 0)&& ! l)
-    {
+        link(a) = r;
+        link(r) = b;
+        b = a;
+        d = 0;
+      }
+      else
       {
-  mem[tail].hh.v.RH = new_penalty(10000); 
-  tail = mem[tail].hh.v.RH; 
-      } 
-      mem[a + 4].cint = s + z - mem[a + 1].cint; 
-      append_to_vlist(a); 
-      g2 = 0; 
-    } 
-    if (t != adjust_head)
+        link(b) = r;
+        link(r) = a;
+      }
+      b = hpack(b, 0, 1);
+    }
+
+    shift_amount(b) = s + d;
+    append_to_vlist(b);
+
+    if ((a != 0) && (e == 0) && !l)
     {
-      mem[tail].hh.v.RH = mem[adjust_head].hh.v.RH; 
-      tail = t; 
-    } 
+      tail_append(new_penalty(10000));
+      shift_amount(a) = s + z - width(a);
+      append_to_vlist(a);
+      g2 = 0;
+    }
+
+    if (t != adjust_head)
     {
-      mem[tail].hh.v.RH = new_penalty(post_display_penalty); 
-      tail = mem[tail].hh.v.RH; 
-    } 
+      link(tail) = link(adjust_head);
+      tail = t;
+    }
+
+    tail_append(new_penalty(post_display_penalty));
+
     if (g2 > 0)
     {
-      mem[tail].hh.v.RH = new_param_glue(g2); 
-      tail = mem[tail].hh.v.RH; 
-    } 
-    resume_after_display(); 
-  } 
+      tail_append(new_param_glue(g2));
+    }
+
+    resume_after_display();
+  }
 }
 /* sec 1200 */
-void resume_after_display (void) 
+void resume_after_display (void)
 {
-  if (cur_group != 15) {
+  if (cur_group != math_shift_group)
+  {
     confusion("display");
     return;       // abort_flag set
   }
+
   unsave();
   prev_graf = prev_graf + 3;
   push_nest();
-  mode = 102;
+  mode = hmode;
   space_factor = 1000;
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-/* was   clang = 0; etc in 3.141 new stuff follows */
-  if (language <= 0)
-    cur_lang = 0; 
-  else if (language > 255)
-    cur_lang = 0;
-  else cur_lang = language;
+  set_cur_lang();
   clang = cur_lang;
-  prev_graf =(norm_min(left_hyphen_min) * 64 +
-     norm_min(right_hyphen_min)) * 65536L + cur_lang; 
-/* eqtb ??? hash_size ? hash_size + hash_extra ? norm_min etc */
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+  prev_graf =(norm_min(left_hyphen_min) * 64 + norm_min(right_hyphen_min)) * 65536L + cur_lang;
+
+  {
+    get_x_token();
+
+    if (cur_cmd != spacer)
+      back_input();
+  }
+
+  if (nest_ptr == 1)
   {
-    get_x_token(); 
-    if (cur_cmd != 10) back_input(); 
-  } 
-  if (nest_ptr == 1) {
     build_page();
   }
 }
 /* sec 1215 */
-void get_r_token (void) 
+void get_r_token (void)
 {
 lab20:
-  do {
-    get_token(); 
-  } while (!(cur_tok != 2592));
-/*  if ((cur_cs == 0)||(cur_cs > (hash_size + 514))) */  /* 95/Jan/10 */
-  if ((cur_cs == 0) || (cur_cs > (hash_size + hash_extra + 514))) {
+  do
+    {
+      get_token();
+    }
+    while (!(cur_tok != space_token));
+
+  if ((cur_cs == 0) || (cur_cs > frozen_control_sequence))
+  {
     print_err("Missing control sequence inserted");
     help5("Please don't say `\\def cs{...}', say `\\def\\cs{...}'.",
       "I've inserted an inaccessible control sequence so that your",
       "definition will be completed without mixing me up too badly.",
       "You can recover graciously from this error, if you're",
       "careful; see exercise 27.2 in The TeXbook.");
+
     if (cur_cs == 0)
-      back_input(); 
-/*    cur_tok = (hash_size + 4609);  */
-/*    cur_tok = (hash_size + 4095 + 514);  */
-    cur_tok = (hash_size + hash_extra + 4095 + 514); /* 96/Jan/10 */
+      back_input();
+
+    cur_tok = cs_token_flag + frozen_protection;
     ins_error();
     goto lab20;
   }
 }
 /* sec 1229 */
-void trap_zero_glue (void) 
+void trap_zero_glue (void)
 {
-  if ((mem[cur_val + 1].cint == 0) && (mem[cur_val + 2].cint == 0) &&
-    (mem[cur_val + 3].cint == 0)) {
-    incr(mem[0].hh.v.RH); /* mem[mem_bot]? */ /* mem[null]? */
+  if ((width(cur_val) == 0) && (stretch(cur_val) == 0) && (shrink(cur_val) == 0))
+  {
+    add_glue_ref(zero_glue);
     delete_glue_ref(cur_val);
     cur_val = 0;
   }
 }
 /* sec 1236 */
-void do_register_command_ (small_number a) 
-{/* 40 10 */ 
-  halfword l, q, r, s; 
-  char p; 
-  q = cur_cmd; 
+void do_register_command_ (small_number a)
+{
+  halfword l, q, r, s;
+  char p;
+
+  q = cur_cmd;
+
   {
-    if (q != 89)
+    if (q != tex_register)
     {
-      get_x_token(); 
-      if ((cur_cmd >= 73)&&(cur_cmd <= 76)) 
+      get_x_token();
+
+      if ((cur_cmd >= assign_int) && (cur_cmd <= assign_mu_glue))
       {
-  l = cur_chr; 
-  p = cur_cmd - 73; 
-  goto lab40; 
-      } 
-      if (cur_cmd != 89)
+        l = cur_chr;
+        p = cur_cmd - assign_int;
+        goto lab40;
+      }
+
+      if (cur_cmd != tex_register)
       {
-                 print_err("You can't use `");
-  print_cmd_chr(cur_cmd, cur_chr); 
-  print_string("' after ");
-  print_cmd_chr(q, 0); 
-  help1("I'm forgetting what you said and not changing anything.");
-  error(); 
-  return; 
-      } 
-    } 
-    p = cur_chr; 
-    scan_eight_bit_int(); 
+        print_err("You can't use `");
+        print_cmd_chr(cur_cmd, cur_chr);
+        print_string("' after ");
+        print_cmd_chr(q, 0);
+        help1("I'm forgetting what you said and not changing anything.");
+        error();
+        return;
+      }
+    }
+
+    p = cur_chr;
+    scan_eight_bit_int();
+
     switch(p)
-    {case 0 : 
-      l = cur_val + (hash_size + 3218); 
-      break; 
-    case 1 : 
-      l = cur_val + (hash_size + 3751); 
-      break; 
-    case 2 : 
-      l = cur_val + (hash_size + 800); 
-      break; 
-    case 3 : 
-      l = cur_val + (hash_size + 1056); 
-      break; 
-    } 
-  } 
-  lab40:; 
-  if (q == 89)
-  scan_optional_equals(); 
-  else if (scan_keyword("by")); 
-  arith_error = false; 
-  if (q < 91)
-  if (p < 2)
-  {
-    if (p == 0){
-    scan_int();
-  }
-    else {
-    scan_dimen(false, false, false);
+    {
+      case int_val:
+        l = cur_val + count_base;
+        break;
+
+      case dimen_val:
+        l = cur_val + scaled_base;
+        break;
+
+      case glue_val:
+        l = cur_val + skip_base;
+        break;
+
+      case mu_val:
+        l = cur_val + mu_skip_base;
+        break;
+    }
   }
-    if (q == 90)
-    cur_val = cur_val + eqtb[l].cint; 
-  } 
-  else {
-      
-    scan_glue(p); 
-    if (q == 90){
-      q = new_spec(cur_val); 
-      r = eqtb[l].hh.v.RH; 
-      delete_glue_ref(cur_val); 
-      mem[q + 1].cint = mem[q + 1].cint + mem[r + 1].cint; 
-      if (mem[q + 2].cint == 0)
-      mem[q].hh.b0 = 0; 
-      if (mem[q].hh.b0 == mem[r].hh.b0)
-      mem[q + 2].cint = mem[q + 2].cint + mem[r + 2].cint; 
-      else if ((mem[q].hh.b0 < mem[r].hh.b0)&&(mem[r + 2]
-     .cint != 0)) 
+lab40:;
+
+  if (q == tex_register)
+    scan_optional_equals();
+  else
+    if (scan_keyword("by"));
+
+  arith_error = false;
+
+  if (q < multiply)
+    if (p < glue_val)
+    {
+      if (p == int_val)
+        scan_int();
+      else
+        scan_dimen(false, false, false);
+
+      if (q == advance)
+        cur_val = cur_val + eqtb[l].cint;
+    }
+    else
+    {
+      scan_glue(p);
+
+      if (q == advance)
       {
-  mem[q + 2].cint = mem[r + 2].cint; 
-  mem[q].hh.b0 = mem[r].hh.b0; 
-      } 
-      if (mem[q + 3].cint == 0)
-      mem[q].hh.b1 = 0; 
-      if (mem[q].hh.b1 == mem[r].hh.b1)
-      mem[q + 3].cint = mem[q + 3].cint + mem[r + 3].cint; 
-      else if ((mem[q].hh.b1 < mem[r].hh.b1)&&(mem[r + 3]
-     .cint != 0)) 
+        q = new_spec(cur_val);
+        r = equiv(l);
+        delete_glue_ref(cur_val);
+        width(q) = width(q) + width(r);
+
+        if (stretch(q) == 0)
+          stretch_order(q) = normal;
+
+        if (stretch_order(q) == stretch_order(r))
+          stretch(q) = stretch(q) + stretch(r);
+        else if ((stretch_order(q) < stretch_order(r)) && (stretch(r) != 0))
+        {
+          stretch(q) = stretch(r);
+          stretch_order(q) = stretch_order(r);
+        }
+
+        if (shrink(q) == 0)
+          shrink_order(q) = normal;
+
+        if (shrink_order(q) == shrink_order(r))
+          shrink(q) = shrink(q) + shrink(r);
+        else if ((shrink_order(q) < shrink_order(r)) && (shrink(r) != 0))
+        {
+          shrink(q) = shrink(r);
+          shrink_order(q) = shrink_order(r);
+        }
+        cur_val = q;
+      }
+    }
+  else
+  {
+    scan_int();
+
+    if (p < glue_val)
+      if (q == multiply)
+        if (p == int_val)
+          cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 2147483647L); /*  2^31 - 1 */
+        else
+          cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 1073741823L); /*  2^30 - 1 */
+      else
+        cur_val = x_over_n(eqtb[l].cint, cur_val);
+    else
+    {
+      s = equiv(l);
+      r = new_spec(s);
+
+      if (q == multiply)
       {
-  mem[q + 3].cint = mem[r + 3].cint; 
-  mem[q].hh.b1 = mem[r].hh.b1; 
-      } 
-      cur_val = q; 
-    } 
-  } 
-  else {
-    scan_int(); 
-    if (p < 2)
-    if (q == 91)
-    if (p == 0)
-    cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 2147483647L); 
-/*  2^31 - 1 */
-    else cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 1073741823L); 
-/*  2^30 - 1 */
-    else cur_val = x_over_n(eqtb[l].cint, cur_val); 
-    else {
-      s = eqtb[l].hh.v.RH;  /* l may be used ... */
-      r = new_spec(s); 
-      if (q == 91)
+        width(r) = mult_and_add(width(s), cur_val, 0, 1073741823L);  /* 2^30 - 1 */
+        stretch(r) = mult_and_add(stretch(s), cur_val, 0, 1073741823L);  /* 2^30 - 1 */
+        shrink(r) = mult_and_add(shrink(s), cur_val, 0, 1073741823L);  /* 2^30 - 1 */
+      }
+      else
       {
-  mem[r + 1].cint = mult_and_add(mem[s + 1].cint, cur_val, 0, 
-  1073741823L);  /* 2^30 - 1 */
-  mem[r + 2].cint = mult_and_add(mem[s + 2].cint, cur_val, 0, 
-  1073741823L);  /* 2^30 - 1 */
-  mem[r + 3].cint = mult_and_add(mem[s + 3].cint, cur_val, 0, 
-  1073741823L);  /* 2^30 - 1 */
-      } 
-      else {
-  mem[r + 1].cint = x_over_n(mem[s + 1].cint, cur_val); 
-  mem[r + 2].cint = x_over_n(mem[s + 2].cint, cur_val); 
-  mem[r + 3].cint = x_over_n(mem[s + 3].cint, cur_val); 
-      } 
-      cur_val = r; 
-    } 
-  } 
-  if (arith_error){
-         print_err("Arithmetic overflow");
-         help2("I can't carry out that multiplication or division,",
-                 "since the result is out of range.");
-/* 423 in tex82.bug */
-         if (p >= 2) delete_glue_ref(cur_val);
-    error(); 
-    return; 
-  } 
-  if (p < 2)
-  if ((a >= 4)) 
-  geq_word_define(l, cur_val); 
-  else eq_word_define(l, cur_val); 
-  else {
-      
-    trap_zero_glue(); 
-    if ((a >= 4)) 
-    geq_define(l, 117, cur_val); 
-    else eq_define(l, 117, cur_val); 
-  } 
-} 
+        width(r) = x_over_n(width(s), cur_val);
+        stretch(r) = x_over_n(stretch(s), cur_val);
+        shrink(r) = x_over_n(shrink(s), cur_val);
+      }
+      cur_val = r;
+    }
+  }
+
+  if (arith_error)
+  {
+    print_err("Arithmetic overflow");
+    help2("I can't carry out that multiplication or division,",
+        "since the result is out of range.");
+
+    if (p >= glue_val)
+      delete_glue_ref(cur_val);
+
+    error();
+    return;
+  }
+
+  if (p < glue_val)
+  {
+    if ((a >= 4))
+      geq_word_define(l, cur_val);
+    else
+      eq_word_define(l, cur_val);
+  }
+  else
+  {
+    trap_zero_glue();
+
+    if ((a >= 4))
+      geq_define(l, glue_ref, cur_val);
+    else
+      eq_define(l, glue_ref, cur_val);
+  }
+}
 /* called only from itex.c */
 /* sec 1243 */
-void alter_aux (void) 
+void alter_aux (void)
 {
-  halfword c; 
-  if (cur_chr != abs(mode)) {
+  halfword c;
+
+  if (cur_chr != abs(mode))
+  {
     report_illegal_case();
   }
-  else {
-    c = cur_chr; 
-    scan_optional_equals(); 
-    if (c == 1)
+  else
+  {
+    c = cur_chr;
+    scan_optional_equals();
+
+    if (c == vmode)
+    {
+      scan_dimen(false, false, false);
+      prev_depth = cur_val;
+    }
+    else
     {
-      scan_dimen(false, false, false); 
-      cur_list.aux_field.cint = cur_val; 
-    } 
-    else {
-      scan_int(); 
-      if ((cur_val <= 0)||(cur_val > 32767)) 
+      scan_int();
+
+      if ((cur_val <= 0) || (cur_val > 32767))
       {
-                 print_err("Bad space factor");
-                 help1("I allow only values in the range 1..32767 here.");
-  int_error(cur_val); 
-      } 
-      else space_factor = cur_val; 
-    } 
-  } 
+        print_err("Bad space factor");
+        help1("I allow only values in the range 1..32767 here.");
+        int_error(cur_val);
+      }
+      else
+        space_factor = cur_val;
+    }
+  }
 }
 /* sec 1244 */
-void alter_prev_graf (void) 
+void alter_prev_graf (void)
 {
-  integer p; 
-  nest[nest_ptr]= cur_list; 
-  p = nest_ptr; 
-  while(abs(nest[p].mode_field)!= 1)decr(p); 
-  scan_optional_equals(); 
-  scan_int(); 
+  integer p;
+
+  nest[nest_ptr] = cur_list;
+  p = nest_ptr;
+
+  while(abs(nest[p].mode_field) != vmode)
+    decr(p);
+
+  scan_optional_equals();
+  scan_int();
+
   if (cur_val < 0)
   {
-         print_err("Bad ");
+    print_err("Bad ");
     print_esc("prevgraf");
-       help1("I allow only nonnegative values here.");
-    int_error(cur_val); 
-  } 
-  else {
-      
-    nest[p].pg_field = cur_val; 
-    cur_list = nest[nest_ptr]; 
-  } 
+    help1("I allow only nonnegative values here.");
+    int_error(cur_val);
+  }
+  else
+  {
+    nest[p].pg_field = cur_val;
+    cur_list = nest[nest_ptr];
+  }
 }
 /* sec 1245 */
-void alter_page_so_far (void) 
+void alter_page_so_far (void)
 {
-  char c; 
-  c = cur_chr; 
-  scan_optional_equals(); 
-  scan_dimen(false, false, false); 
-  page_so_far[c]= cur_val; 
+  char c;
+
+  c = cur_chr;
+  scan_optional_equals();
+  scan_dimen(false, false, false);
+  page_so_far[c] = cur_val;
 }
 /* sec 1246 */
-void alter_integer (void) 
+void alter_integer (void)
 {
-  char c; 
-  c = cur_chr; 
-  scan_optional_equals(); 
-  scan_int(); 
-  if (c == 0)dead_cycles = cur_val; 
-  else insert_penalties = cur_val; 
+  char c;
+
+  c = cur_chr;
+  scan_optional_equals();
+  scan_int();
+
+  if (c == 0)
+    dead_cycles = cur_val;
+  else
+    insert_penalties = cur_val;
 }
 /* sec 1247 */
-void alter_box_dimen (void) 
-{ 
-  small_number c; 
-  eight_bits b; 
-  c = cur_chr; 
-  scan_eight_bit_int(); 
-  b = cur_val; 
-  scan_optional_equals(); 
-  scan_dimen(false, false, false); 
-  if (eqtb[(hash_size + 1578) + b].hh.v.RH != 0)
-  mem[eqtb[(hash_size + 1578) + b].hh.v.RH + c].cint = cur_val; 
+void alter_box_dimen (void)
+{
+  small_number c;
+  eight_bits b;
+
+  c = cur_chr;
+  scan_eight_bit_int();
+  b = cur_val;
+  scan_optional_equals();
+  scan_dimen(false, false, false);
+
+  if (box(b) != 0)
+    mem[box(b) + c].cint = cur_val;
 }
 /* sec 1257 */
 void new_font_(small_number a)
-{/* 50 */ 
-  halfword u; 
-  scaled s; 
-  internal_font_number f; 
-  str_number t; 
-  char old_setting; 
-  str_number flushablestring; 
-  if (job_name == 0) open_log_file(); 
-  get_r_token(); 
-  u = cur_cs; 
-  if (u >= hash_base)      /* if u >= hash_base then t <- text(u); p.1257 */
-    t = hash[u].v.RH; 
-  else if (u >= single_base)   /* if u >= single_base then ... */
-/*    if u=null_cs then t:="FONT"@+else t:=u-single_base */
-  if (u == null_cs)
-    t = 1213;     /* FONT */
-  else t = u - single_base;   /* else t <- u - single_base */
-  else {
-    old_setting = selector; 
-    selector = 21; 
+{
+  halfword u;
+  scaled s;
+  internal_font_number f;
+  str_number t;
+  char old_setting;
+  str_number flushable_string;
+
+  if (job_name == 0)
+    open_log_file();
+
+  get_r_token();
+  u = cur_cs;
+
+  if (u >= hash_base)
+    t = text(u);
+  else if (u >= single_base)
+    if (u == null_cs)
+      t = 1213;     /* FONT */
+    else
+      t = u - single_base;
+  else
+  {
+    old_setting = selector;
+    selector = 21;
     print_string("FONT");
-    print(u - active_base); 
-    selector = old_setting; 
-    {
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-#ifdef ALLOCATESTRING
-    if (pool_ptr + 1 > current_pool_size)
-      str_pool = realloc_str_pool (increment_pool_size);
-    if (pool_ptr + 1 > current_pool_size) {     /* 94/Jan/24 */
-      overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/9 */
-      return;     // abort_flag set
-    }
-#else
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-      if (pool_ptr + 1 > pool_size) {
-      overflow("pool size", pool_size - init_pool_ptr); /* pool size */
-      return;     // abort_flag set
-    }
-#endif
-    } 
-    t = make_string(); 
-  } 
-  if ((a >= 4)) geq_define(u, 87, 0); 
-  else eq_define(u, 87, 0); 
-  scan_optional_equals(); 
-  scan_file_name(); 
-
-/* paragraph 1258 */
-  name_in_progress = true; 
-  if (scan_keyword("at"))  /* at */
+    print(u - active_base);
+    selector = old_setting;
+    str_room(1);
+    t = make_string();
+  }
+
+  if ((a >= 4))
+    geq_define(u, set_font, 0);
+  else
+    eq_define(u, set_font, 0);
+
+  scan_optional_equals();
+  scan_file_name();
+
+  name_in_progress = true;
+
+  if (scan_keyword("at"))
   {
-    scan_dimen(false, false, false); 
+    scan_dimen(false, false, false);
     s = cur_val; 
-    if ((s <= 0)||(s >= 134217728L)) /* 2^27 */
+
+    if ((s <= 0) || (s >= 134217728L)) /* 2^27 */
     {
-      print_err("Improper `at' size(");
-      print_scaled(s); 
+      print_err("Improper `at' size (");
+      print_scaled(s);
       print_string("pt), replaced by 10pt");
-         help2("I can only handle fonts at positive sizes that are",
-                 "less than 2048pt, so I've changed what you said to 10pt.");
-      error(); 
+      help2("I can only handle fonts at positive sizes that are",
+        "less than 2048pt, so I've changed what you said to 10pt.");
+      error();
       s = 10 * 65536L;    /* 10pt */
-    } 
-  } 
-  else if (scan_keyword("scaled")) /* scaled */
+    }
+  }
+  else if (scan_keyword("scaled"))
+  {
+    scan_int();
+    s = - (integer) cur_val;
+
+    if ((cur_val <= 0) || (cur_val > 32768L))
+    {
+      print_err("Illegal magnification has been changed to 1000");
+      help1("The magnification ratio must be between 1 and 32768.");
+      int_error(cur_val);
+      s = -1000;
+    }
+  }
+  else
+    s = -1000;
+
+  name_in_progress = false;
+
+  flushable_string = str_ptr - 1;
+
+  if (trace_flag) /* debugging stuff only 98/Oct/5 */
   {
-    scan_int(); 
-    s = - (integer) cur_val; 
-    if ((cur_val <= 0)||(cur_val > 32768L))  {
-               print_err("Illegal magnification has been changed to 1000");
-               help1("The magnification ratio must be between 1 and 32768.");
-      int_error(cur_val); 
-      s = -1000; 
-    } 
-  } 
-  else s = -1000; 
-  name_in_progress = false; 
-
-  flushablestring = str_ptr - 1; 
-  if (trace_flag)   {         /* debugging stuff only 98/Oct/5 */
     int i, k1, k2, l1, l2;
-    char *sch=log_line;
+    char *sch = log_line;
     k1 = str_start[cur_area];
     k2 = str_start[cur_name];
-    l1 = str_start[cur_area + 1] - str_start[cur_area];
-    l2 = str_start[cur_name + 1] - str_start[cur_name];
+    l1 = length(cur_area);
+    l2 = length(cur_name);
     show_char('\n');
     show_line("FONT ", 0);
-    for (i = 0; i < l1; i++) {
-      *sch++ = str_pool[i+k1];
-    }
-    for (i = 0; i < l2; i++) {
-      *sch++ = str_pool[i+k2];
+
+    for (i = 0; i < l1; i++)
+    {
+      *sch++ = str_pool[i + k1];
+    }
+
+    for (i = 0; i < l2; i++)
+    {
+      *sch++ = str_pool[i + k2];
     }
+
     *sch++ = ' ';
     *sch++ = '\0';
     show_line(log_line, 0);
   }
-/*  if (ignore_frozen) goto lab69; */     /* 98/Oct/5 */
 
-/* paragraph 1260 for f <- fontbase+1 to font_ptr do */
+  for (f = font_base + 1; f < font_ptr; f++)
   {
-    register integer for_end; 
-    f = 1; 
-    for_end = font_ptr; 
-    if (f <= for_end) 
-      do 
-/* if str_eq_str(font_name[f],cur_name) ^ str_eq_str(font_area[f],cur_area) */
-        if (str_eq_str(font_name[f], cur_name)&&
-           str_eq_str(font_area[f], cur_area))  {
-          if (cur_name == flushablestring){
+    if (str_eq_str(font_name[f], cur_name) && str_eq_str(font_area[f], cur_area))
+    {
+      if (cur_name == flushable_string)
+      {
+        flush_string();
+        cur_name = font_name[f];
+      }
+
+      if (s > 0)
+      {
+        if (s == font_size[f])
+        {
+          if (ignore_frozen == 0 || f > frozenfontptr)
+          {
+            if (trace_flag)
             {
-              decr(str_ptr); 
-              pool_ptr = str_start[str_ptr]; 
-            } 
-            cur_name = font_name[f]; 
-          } 
-/*    if (ignore_frozen) continue; */       /* 98/Oct/5 */
-          if (s > 0) {   /* if pt size was specified */
-            if (s == font_size[f]){
-/*              if (ignore_frozen == 0)  */
-              if (ignore_frozen == 0 || f > frozenfontptr) { /* 99/Mar/26 */
-                if (trace_flag) {
-                  sprintf(log_line, "SKIPPING %ld ", s);
-                  show_line(log_line, 0);
-                }
-                goto lab50;
-              }
-            }
-          } 
-/* else if font_size[f] = xn_over_d(font_dsize[f],-s,1000) then goto common_ending */
-          else if (font_size[f]== xn_over_d(font_dsize[f],
-            - (integer) s, 1000)) { /* if using design size */
-/*            if (ignore_frozen == 0) */
-            if (ignore_frozen == 0 || f > frozenfontptr) { /* 99/Mar/26 */
-              if (trace_flag) {
-                sprintf(log_line, "SKIPPING %ld ", s);
-                show_line(log_line, 0);
-              }
-              goto lab50;
+              sprintf(log_line, "SKIPPING %ld ", s);
+              show_line(log_line, 0);
             }
+            goto lab50;
+          }
+        }
+      }
+      else if (font_size[f] == xn_over_d(font_dsize[f], - (integer) s, 1000))
+      {
+        if (ignore_frozen == 0 || f > frozenfontptr) /* 99/Mar/26 */
+        {
+          if (trace_flag)
+          {
+            sprintf(log_line, "SKIPPING %ld ", s);
+            show_line(log_line, 0);
           }
-        } 
-    while(f++ < for_end);
-  } 
+          goto lab50;
+        }
+      }
+    }
+  }
+
+  if (trace_flag)
+    show_line("READING ", 0);
 
-/* lab69: */  /* 98/Oct/5 */
-/* end of paragraph 1257 */
-  if (trace_flag) show_line("READING ", 0);  /* debugging only */
   f = read_font_info(u, cur_name, cur_area, s); 
 
-/* common_ending: equiv[u] <- f;  */  /* use existing font info */
-  lab50:
-  if (trace_flag) {
-    sprintf(log_line, "NEW FONT %d ", f); /* debugging only */
+lab50:
+  if (trace_flag)
+  {
+    sprintf(log_line, "NEW FONT %d ", f);
     show_line(log_line, 0);
   }
-  eqtb[u].hh.v.RH = f; 
-/*  eqtb[(hash_size + 524) + f]= eqtb[u];*/ /* eqtb[frozen_null+font+f] */
-  eqtb[(hash_size + hash_extra + 524) + f]= eqtb[u]; /* 96/Jan/10 */
-#ifdef SHORTHASH            /*  debugging only  1996/Jan/20 */
-  if (t > 65535L) {
+
+  equiv(u) = f;
+  eqtb[font_id_base + f] = eqtb[u];
+
+#ifdef SHORTHASH
+  if (t > 65535L)
+  {
     sprintf(log_line, "ERROR: %s too large %d\n",  "hash_used", t);
     show_line(log_line, 1);
   }
 #endif
-/*  hash[(hash_size + 524) + f].v.RH = t;  */
-  hash[(hash_size + hash_extra + 524) + f].v.RH = t; /* 96/Jan/10 */
+  font_id_text(f) = t;
 }
 /* sec 1265 */
-void new_interaction (void) 
-{ 
-  print_ln(); 
-  interaction = cur_chr; 
-  if (interaction == 0) selector = 16; 
-  else selector = 17; 
-  if (log_opened) selector = selector + 2; 
+void new_interaction (void)
+{
+  print_ln();
+  interaction = cur_chr;
+
+  if (interaction == batch_mode)
+    selector = no_print;
+  else
+    selector = term_only;
+
+  if (log_opened)
+    selector = selector + 2;
 }
 /* sec 1270 */
-void do_assignments (void) 
-{/* 10 */ 
-  while(true){
-    do {
-    get_x_token(); 
-    } while(!((cur_cmd != 10)&&(cur_cmd != 0))); 
-    if (cur_cmd <= 70)
-    return; 
-    set_box_allowed = false; 
-    prefixed_command(); 
-    set_box_allowed = true; 
-  } 
+void do_assignments (void)
+{
+  while (true)
+  {
+    do
+      {
+        get_x_token();
+      }
+    while (!((cur_cmd != spacer) && (cur_cmd != relax)));
+
+    if (cur_cmd <= max_non_prefixed_command)
+      return;
+
+    set_box_allowed = false;
+    prefixed_command();
+    set_box_allowed = true;
+  }
 }
 /* sec 1275 */
-void open_or_close_in (void) 
+void open_or_close_in (void)
 {
-  char c; 
-  char n; 
-  c = cur_chr; 
-  scan_four_bit_int(); 
-  n = cur_val; 
-  if (read_open[n]!= 2)
+  char c;
+  char n;
+
+  c = cur_chr;
+  scan_four_bit_int();
+  n = cur_val;
+
+  if (read_open[n] != closed)
   {
-    (void) a_close(read_file[n]); 
-    read_open[n]= 2; 
-  } 
+    (void) a_close(read_file[n]);
+    read_open[n] = closed;
+  }
+
   if (c != 0)
   {
-    scan_optional_equals(); 
-    scan_file_name(); 
-    pack_file_name(cur_name, cur_area, cur_ext); 
+    scan_optional_equals();
+    scan_file_name();
+    pack_file_name(cur_name, cur_area, cur_ext);
+
 /* *** some changes in following in 3.14159 *** */
 /*  if current extension is *not* empty, try to open using name as is */
 /*  string 335 is "" the empty string */
-    if ((cur_ext != 335) && a_open_in(read_file[n], TEXINPUTPATH)) 
-    read_open[n]= 1; 
+    if ((cur_ext != 335) && a_open_in(read_file[n], TEXINPUTPATH))
+      read_open[n] = 1;
 /*  we get here if extension is "", or file with extension failed to open */
 /*  if current extension is not `tex,' and `tex' is not irrelevant, try it */
 /*  string 785 is  .tex */
-    else if ((cur_ext != 785)&&(name_length + 5 < PATHMAX)&& 
-/* *** some changes in above file name handling *** */
-/*       (! extensionirrelevantp(name_of_file, "tex"))) */
-       (! extensionirrelevantp(name_of_file, name_length, "tex")))
-  {
-      name_of_file[name_length + 1]= 46;    /* .tex  */
-      name_of_file[name_length + 2]= 116; 
-      name_of_file[name_length + 3]= 101; 
-      name_of_file[name_length + 4]= 120; 
-      name_of_file[name_length + 5]= 32; 
-      name_length = name_length + 4; 
-      if (a_open_in(read_file[n], TEXINPUTPATH)) 
-      read_open[n]= 1; 
-      else {
-/*    more changes here in 3.14159 *** */
-      name_length = name_length - 4;      /* remove ".tex" again */
-      name_of_file[name_length + 1]= 32;  /* '  '  */
-/*    string 335 is "" the empty string */
-      if ((cur_ext == 335)&& a_open_in(read_file[n], TEXINPUTPATH)) 
-        read_open[n]= 1; 
-      else if (maketextex () && a_open_in(read_file[n], TEXINPUTPATH)) 
-        read_open[n]= 1; 
-    } 
-    } 
-  } 
+    else if ((cur_ext != 785) && (name_length + 5 < PATHMAX))
+      {
+        strncpy((char *) name_of_file + name_length + 1, ".tex ", 5);
+        name_length = name_length + 4;
+
+        if (a_open_in(read_file[n], TEXINPUTPATH))
+          read_open[n] = just_open;
+        else
+        {
+          name_length = name_length - 4;      /* remove ".tex" again */
+          name_of_file[name_length + 1] = ' ';
+
+          if ((cur_ext == 335) && a_open_in(read_file[n], TEXINPUTPATH))
+            read_open[n] = 1;
+        }
+      }
+  }
 }
 /* sec 1279 */
-void issue_message (void) 
+void issue_message (void)
 {
-  char old_setting; 
-  char c; 
-  str_number s; 
-  c = cur_chr; 
-  mem[lig_trick].hh.v.RH = scan_toks(false, true); 
-  old_setting = selector; 
-  selector = 21; 
-  token_show(def_ref); 
-  selector = old_setting; 
-  flush_list(def_ref); 
-  {
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-#ifdef ALLOCATESTRING
-  if (pool_ptr + 1 > current_pool_size)
-      str_pool = realloc_str_pool (increment_pool_size);
-  if (pool_ptr + 1 > current_pool_size){ /* in case it failed 94/Jan/24 */
-    overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/7 */
-    return;     // abort_flag set
-  }
-#else
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-    if (pool_ptr + 1 > pool_size){
-    overflow("pool size", pool_size - init_pool_ptr); /* pool size */
-    return;     // abort_flag set
-  }
-#endif
-  } 
-  s = make_string(); 
+  char old_setting;
+  char c;
+  str_number s;
+
+  c = cur_chr;
+  link(garbage) = scan_toks(false, true);
+  old_setting = selector;
+  selector = new_string;
+  token_show(def_ref);
+  selector = old_setting;
+  flush_list(def_ref);
+  str_room(1);
+  s = make_string();
+
   if (c == 0)
   {
-    if (term_offset +(str_start[s + 1]- str_start[s])> max_print_line - 
-    2)
-    print_ln(); 
-    else if ((term_offset > 0)||(file_offset > 0)) 
-    print_char(' ');
-    slow_print(s); 
-#ifndef f_WINDOWS
-    fflush(stdout); 
+    if (term_offset + length(s) > max_print_line - 2)
+      print_ln();
+    else if ((term_offset > 0) || (file_offset > 0))
+      print_char(' ');
+
+    slow_print(s);
+
+#ifndef _WINDOWS
+    fflush(stdout);
 #endif
-  } 
-  else {
-    print_err("");  
-    slow_print(s); 
+  }
+  else
+  {
+    print_err("");
+    slow_print(s);
+
     if (err_help != 0)
-    use_err_help = true; 
+      use_err_help = true;
     else if (long_help_seen)
-               help1("(That was another \\errmessage.)");
-    else {
-  
-      if (interaction < 3)
-      long_help_seen = true; 
-         help4("This error message was generated by an \\errmessage",
-                 "command, so I can't give any explicit help.",
-                 "Pretend that you're Hercule Poirot: Examine all clues,",
-                 "and deduce the truth by order and method."); 
-    } 
-    error(); 
-    use_err_help = false; 
-  } 
-  {
-    decr(str_ptr); 
-    pool_ptr = str_start[str_ptr]; 
-  } 
+      help1("(That was another \\errmessage.)");
+    else
+    {
+      if (interaction < error_stop_mode)
+        long_help_seen = true;
+
+      help4("This error message was generated by an \\errmessage",
+        "command, so I can't give any explicit help.",
+        "Pretend that you're Hercule Poirot: Examine all clues,",
+        "and deduce the truth by order and method.");
+    }
+
+    error();
+    use_err_help = false;
+  }
+
+  flush_string();
 }
 /* sec 1288 */
-void shift_case (void) 
+void shift_case (void)
 {
-  halfword b; 
-  halfword p; 
-  halfword t; 
-  eight_bits c; 
-  b = cur_chr; 
-  p = scan_toks(false, false); 
-  p = mem[def_ref].hh.v.RH;
-  while (p != 0) {      /* while p <> null ... p.1288 */
-    t = info(p); /* t <- info(p) p.1289 */ 
-/*    if (t < 4352) */
-    if (t < 4095 + single_base)    /* 4095 + 257 = cs_tokenflag + single_base */
-    {
-      c = t % 256;  
-      if (eqtb[b + c].hh.v.RH != 0)
-      mem[p].hh.v.LH = t - c + eqtb[b + c].hh.v.RH; 
-    } 
-    p = link(p); 
-  } 
-  begin_token_list(mem[def_ref].hh.v.RH, 3); 
+  halfword b;
+  halfword p;
+  halfword t;
+  eight_bits c;
+
+  b = cur_chr;
+  p = scan_toks(false, false);
+  p = link(def_ref);
+
+  while (p != 0)
   {
-    mem[def_ref].hh.v.RH = avail; 
-    avail = def_ref; 
-  ;
-#ifdef STAT
-    decr(dyn_used); 
-#endif /* STAT */
-  } 
+    t = info(p); 
+
+    if (t < cs_token_flag + single_base)
+    {
+      c = t % 256;
+
+      if (equiv(b + c) != 0)
+        info(p) = t - c + equiv(b + c);
+    }
+
+    p = link(p);
+  }
+
+  begin_token_list(link(def_ref), 3);
+  free_avail(def_ref);
 }
 /* sec 1293 */
-void show_whatever (void) 
+void show_whatever (void)
 {
-  halfword p; 
+  halfword p;
+
   switch(cur_chr)
   {
-  case 3:
-    {
-      begin_diagnostic();
-      show_activities();
-    }
-    break;
-  case 1:
-    {
-      scan_eight_bit_int();
-      begin_diagnostic();
-      print_nl("> \box");
-      print_int(cur_val);
-      print_char('=');
-      if (eqtb[(hash_size + 1578) + cur_val].hh.v.RH == 0)
-        print_string("void");
-      else
-        show_box(eqtb[(hash_size + 1578) + cur_val].hh.v.RH);
-    }
-    break;
-  case 0:
-    {
-      get_token();
-      if (interaction == 3)
-        ;
-      print_nl("> ");
-      if (cur_cs != 0)
+    case show_lists:
+      {
+        begin_diagnostic();
+        show_activities();
+      }
+      break;
+
+    case show_box_code:
       {
-        sprint_cs(cur_cs);
+        scan_eight_bit_int();
+        begin_diagnostic();
+        print_nl("> \\box");
+        print_int(cur_val);
         print_char('=');
+
+        if (box(cur_val) == 0)
+          print_string("void");
+        else
+          show_box(box(cur_val));
       }
-      print_meaning();
-      goto lab50;
-    }
-    break;
-  default:
-    {
-      p = the_toks();
-      if (interaction == 3)
-        ; 
-      print_nl(" > ");
-      token_show(temp_head);
-      flush_list(mem[temp_head].hh.v.RH);
-      goto lab50;
-    }
-    break;
+      break;
+
+    case show_code:
+      {
+        get_token();
+
+        if (interaction == error_stop_mode)
+          ;
+
+        print_nl("> ");
+
+        if (cur_cs != 0)
+        {
+          sprint_cs(cur_cs);
+          print_char('=');
+        }
+
+        print_meaning();
+        goto lab50;
+      }
+      break;
+
+    default:
+      {
+        p = the_toks();
+
+        if (interaction == error_stop_mode)
+          ;
+
+        print_nl("> ");
+        token_show(temp_head);
+        flush_list(link(temp_head));
+        goto lab50;
+      }
+      break;
   }
+
   end_diagnostic(true);
   print_err("OK");
-  if (selector == 19)
-  if (tracing_online <= 0)
-  {
-    selector = 17;
-    print_string(" (see the transcript file)");
-    selector = 19;
-  }
+
+  if (selector == term_and_log)
+    if (tracing_online <= 0)
+    {
+      selector = term_only;
+      print_string(" (see the transcript file)");
+      selector = term_and_log;
+    }
+
 lab50:
-  if (interaction < 3) {
+
+  if (interaction < error_stop_mode)
+  {
     help_ptr = 0;
     decr(error_count);
-  } else if (tracing_online > 0) {
-         help3("This isn't an error message; I'm just \\showing something.",
-                 "Type `I\\show...' to show more (e.g., \\show\\cs,",
-                 "\\showthe\\count10, \\showbox255, \\showlists).");
-  } else {
+  }
+  else if (tracing_online > 0)
+  {
+    help3("This isn't an error message; I'm just \\showing something.",
+      "Type `I\\show...' to show more (e.g., \\show\\cs,",
+      "\\showthe\\count10, \\showbox255, \\showlists).");
+  }
+  else
+  {
     help5("This isn't an error message; I'm just \\showing something.",
       "Type `I\\show...' to show more (e.g., \\show\\cs,",
       "\\showthe\\count10, \\showbox255, \\showlists).",
-                 "And type `I\\tracingonline=1\\show...' to show boxes and",
-                 "lists on your terminal as well as in the transcript file."); 
+      "And type `I\\tracingonline=1\\show...' to show boxes and",
+      "lists on your terminal as well as in the transcript file.");
   }
+
   error();
-} 
-/* sec 1339 */
+}
+/* sec 1349 */
 void new_whatsit_(small_number s, small_number w)
 {
-  halfword p; 
-  p = get_node(w); 
-  mem[p].hh.b0 = 8; 
-  mem[p].hh.b1 = s; 
-  mem[tail].hh.v.RH = p; 
-  tail = p; 
-} 
+  halfword p;
+
+  p = get_node(w);
+  type(p) = whatsit_node;
+  subtype(p) = s;
+  link(tail) = p;
+  tail = p;
+}
 /* sec 1350 */
 void new_write_whatsit_(small_number w)
 {
-  new_whatsit(cur_chr, w); 
-  if (w != 2) {
+  new_whatsit(cur_chr, w);
+
+  if (w != write_node_size)
+  {
     scan_four_bit_int();
-  } else {
-    scan_int(); 
+  }
+  else
+  {
+    scan_int();
+
     if (cur_val < 0)
-      cur_val = 17; 
+      cur_val = 17;
     else if (cur_val > 15)
-      cur_val = 16; 
+      cur_val = 16;
   }
-  mem[tail + 1].hh.v.LH = cur_val;
+
+  write_stream(tail) = cur_val;
 }
 /* sec 1348 */
-void do_extension (void) 
+void do_extension (void)
 {
 /*  integer i, j, k;  */
-  integer k; 
+  integer k;
 /*  halfword p, q, r;  */
-  halfword p; 
+  halfword p;
+
   switch(cur_chr)
-  {case 0 : 
-    {
-      new_write_whatsit(3); 
-      scan_optional_equals(); 
-      scan_file_name(); 
-      mem[tail + 1].hh.v.RH = cur_name; 
-      mem[tail + 2].hh.v.LH = cur_area; 
-      mem[tail + 2].hh.v.RH = cur_ext; 
-    } 
-    break; 
-  case 1 : 
-    {
-      k = cur_cs; 
-      new_write_whatsit(2); 
-      cur_cs = k; 
-      p = scan_toks(false, false); 
-      mem[tail + 1].hh.v.RH = def_ref; 
-    } 
-    break; 
-  case 2 : 
-    {
-      new_write_whatsit(2); 
-      mem[tail + 1].hh.v.RH = 0; 
-    } 
-    break; 
-  case 3 : 
-    {
-      new_whatsit(3, 2); 
-      mem[tail + 1].hh.v.LH = 0; 
-      p = scan_toks(false, true); 
-      mem[tail + 1].hh.v.RH = def_ref; 
-    } 
-    break; 
-  case 4 : 
-    {
-      get_x_token(); 
-      if ((cur_cmd == 59)&&(cur_chr <= 2)) 
+  {
+    case open_node:
       {
-  p = tail; 
-  do_extension(); 
-  out_what(tail);
-  flush_node_list(tail); 
-  tail = p; 
-  mem[p].hh.v.RH = 0; 
-      } 
-      else back_input(); 
-    } 
-    break; 
-  case 5 : 
-    if (abs(mode)!= 102){
-    report_illegal_case();
+        new_write_whatsit(open_node_size);
+        scan_optional_equals();
+        scan_file_name();
+        open_name(tail) = cur_name;
+        open_area(tail) = cur_area;
+        open_ext(tail) = cur_ext;
+      }
+      break;
+
+    case write_node:
+      {
+        k = cur_cs;
+        new_write_whatsit(write_node_size);
+        cur_cs = k;
+        p = scan_toks(false, false);
+        write_tokens(tail) = def_ref;
+      }
+      break;
+
+    case close_node:
+      {
+        new_write_whatsit(write_node_size);
+        write_tokens(tail) = 0;
+      }
+      break;
+
+    case special_node:
+      {
+        new_whatsit(special_node, write_node_size);
+        write_stream(tail) = 0;
+        p = scan_toks(false, true);
+        write_tokens(tail) = def_ref;
+      }
+      break;
+
+    case immediate_code:
+      {
+        get_x_token();
+
+        if ((cur_cmd == extension) && (cur_chr <= close_node))
+        {
+          p = tail;
+          do_extension();
+          out_what(tail);
+          flush_node_list(tail);
+          tail = p;
+          link(p) = 0;
+        }
+        else
+          back_input();
+      }
+      break;
+
+    case set_language_code:
+      if (abs(mode) != hmode)
+      {
+        report_illegal_case();
+      }
+      else
+      {
+        new_whatsit(language_node, small_node_size);
+        scan_int();
+
+        if (cur_val <= 0)
+          clang = 0;
+        else if (cur_val > 255)
+          clang = 0;
+        else
+          clang = cur_val;
+
+        what_lang(tail) = clang;
+        what_lhm(tail) = norm_min(left_hyphen_min);
+        what_rhm(tail) = norm_min(right_hyphen_min);
+      }
+      break;
+
+    default:
+      {
+        confusion("ext1");
+        return;       // abort_flag set
+      }
+      break;
   }
-    else {
-      new_whatsit(4, 2); 
-      scan_int(); 
-      if (cur_val <= 0) clang = 0; 
-      else if (cur_val > 255)
-      clang = 0; 
-      else clang = cur_val; 
-      mem[tail + 1].hh.v.RH = clang; 
-      mem[tail + 1].hh.b0 = norm_min(left_hyphen_min); 
-      mem[tail + 1].hh.b1 = norm_min(right_hyphen_min); 
-    } 
-    break; 
-    default: 
-    {
-      confusion("display");
-      return;       // abort_flag set
-    }
-    break; 
-  } 
-} 
+}
 /* sec 1376 */
-void fix_language (void) 
-{ 
+void fix_language (void)
+{
 /*  ASCII_code l;  */
   int l;                  /* 95/Jan/7 */
+
   if (language <= 0)
     l = 0; 
   else if (language > 255)
     l = 0;
-  else l = language;
-  if (l != clang) {
-    new_whatsit(4, 2);
-    mem[tail + 1].hh.v.RH = l;
+  else
+    l = language;
+
+  if (l != clang)
+  {
+    new_whatsit(language_node, small_node_size);
+    what_lang(tail) = l;
     clang = l;
-    mem[tail + 1].hh.b0 = norm_min(left_hyphen_min);
-    mem[tail + 1].hh.b1 = norm_min(right_hyphen_min);
+    what_lhm(tail) = norm_min(left_hyphen_min);
+    what_rhm(tail) = norm_min(right_hyphen_min);
   }
 }
 /* sec 1068 */
-void handle_right_brace (void) 
-{ 
-  halfword p, q; 
-  scaled d; 
-  integer f; 
+void handle_right_brace (void)
+{
+  halfword p, q;
+  scaled d;
+  integer f;
 
   switch(cur_group)
-  {case 1 : 
-    unsave(); 
-    break; 
-  case 0 : 
-    {
-                 print_err("Too many }'s");
-               help2("You've closed more groups than you opened.",
-                       "Such booboos are generally harmless, so keep going.");
+  {
+    case simple_group:
+      unsave();
+      break;
+
+    case bottom_level:
+      {
+        print_err("Too many }'s");
+        help2("You've closed more groups than you opened.",
+          "Such booboos are generally harmless, so keep going.");
         error();
-    } 
-    break; 
-  case 14 : 
-  case 15 : 
-  case 16 : 
-    extra_right_brace();
-    break; 
-  case 2 : 
-    package(0); 
-    break; 
-  case 3 : 
-    {
-      adjust_tail = adjust_head; 
-      package(0); 
-    } 
-    break; 
-  case 4 : 
-    {
-      end_graf(); 
-      package(0); 
-    } 
-    break; 
-  case 5 : 
-    {
-      end_graf();
-      package(4);
-    } 
-    break; 
-  case 11 : 
-    {
-      end_graf(); 
-      q = eqtb[(hash_size + 792)].hh.v.RH; 
-      incr(mem[q].hh.v.RH); 
-      d = split_max_depth; 
-      f = floating_penalty; 
-      unsave(); 
-      decr(save_ptr); 
-      p = vpackage(mem[head].hh.v.RH, 0, 1, 1073741823L);  /* 2^30 - 1 */
-      pop_nest(); 
-      if (save_stack[save_ptr + 0].cint < 255) {
-        {
-          mem[tail].hh.v.RH = get_node(5);
-          tail = mem[tail].hh.v.RH;
-        }
-        mem[tail].hh.b0 = 3;
-        mem[tail].hh.b1 = save_stack[save_ptr + 0].cint;
-        mem[tail + 3].cint = mem[p + 3].cint + mem[p + 2].cint;
-        mem[tail + 4].hh.v.LH = mem[p + 5].hh.v.RH;
-        mem[tail + 4].hh.v.RH = q;
-        mem[tail + 2].cint = d;
-        mem[tail + 1].cint = f; 
-      } else {
-        {
-          mem[tail].hh.v.RH = get_node(2);
-          tail = mem[tail].hh.v.RH;
-        }
-        mem[tail].hh.b0 = 5;
-        mem[tail].hh.b1 = 0;
-        mem[tail + 1].cint = mem[p + 5].hh.v.RH;
-        delete_glue_ref(q);
-      } 
-      free_node(p, 7); 
-      if (nest_ptr == 0) {
-        build_page();
       }
-    } 
-    break; 
-  case 8 : 
-    {
-      if ((cur_input.loc_field != 0)||((cur_input.index_field != 6)&&(
-      cur_input.index_field != 3)))
-      {
-                 print_err("Unbalanced output routine");
-                 help2("Your sneaky output routine has problematic {'s and/or }'s.",
-                         "I can't handle that very well; good luck.");
-  error(); 
-  do {
-      get_token(); 
-  } while(!(cur_input.loc_field == 0)); 
-      } 
-      end_token_list(); 
-      end_graf(); 
-      unsave(); 
-      output_active = false; 
-      insert_penalties = 0; 
-      if (eqtb[(hash_size + 1833)].hh.v.RH != 0)
-      {
-                 print_err("Output routine didn't use all of ");
-      print_esc("box");
-      print_int(255); 
-         help3("Your \\output commands should empty \\box255,",
-                 "e.g., by saying `\\ship_out\\box255'.",
-                 "Proceed; I'll discard its present contents.");
-      box_error(255); 
-    }
-      if (tail != head)
-      {
-  mem[page_tail].hh.v.RH = mem[head].hh.v.RH; 
-  page_tail = tail; 
-      } 
-      if (mem[page_head].hh.v.RH != 0)
+      break;
+
+    case semi_simple_group:
+    case math_shift_group:
+    case math_left_group:
+      extra_right_brace();
+      break;
+
+    case hbox_group:
+      package(0);
+      break;
+
+    case adjust_hbox_group:
       {
-  if (mem[contrib_head].hh.v.RH == 0)
-  nest[0].tail_field = page_tail; 
-  mem[page_tail].hh.v.RH = mem[contrib_head].hh.v.RH; 
-  mem[contrib_head].hh.v.RH = mem[page_head].hh.v.RH; 
-  mem[page_head].hh.v.RH = 0; 
-  page_tail = page_head; 
-      } 
-      pop_nest(); 
-      build_page(); 
-    } 
-    break; 
-  case 10 : 
-    build_discretionary(); 
-    break; 
-  case 6 : 
-/* align_group: begin back_input; cur_tok:=cs_token_flag+frozen_cr; */
-    {
-      back_input(); 
-/*      cur_tok = (hash_size + 4610);  */
-/*      cur_tok = (hash_size + 4095 + 515);  */
-      cur_tok = (hash_size + hash_extra + 4095 + 515);
-         print_err("Missing ");
-      print_esc("cr");
-      print_string("inserted");
-         help1("I'm guessing that you meant to end an alignment here.");
-      ins_error(); 
-    } 
-    break; 
-  case 7 : 
-    {
-      end_graf(); 
-      unsave(); 
-      align_peek(); 
-    } 
-    break; 
-  case 12 : 
-    {
-      end_graf(); 
-      unsave(); 
-      save_ptr = save_ptr - 2; 
-      p = vpackage(mem[head].hh.v.RH, save_stack[
-      save_ptr + 1].cint, save_stack[save_ptr + 0].cint,
-      1073741823L);   /* 2^30 - 1 */
-      pop_nest(); 
+        adjust_tail = adjust_head;
+        package(0);
+      }
+      break;
+
+    case vbox_group:
       {
-  mem[tail].hh.v.RH = new_noad(); 
-  tail = mem[tail].hh.v.RH; 
-      } 
-      mem[tail].hh.b0 = 29; 
-      mem[tail + 1].hh.v.RH = 2; 
-      mem[tail + 1].hh.v.LH = p; 
-    } 
-    break; 
-  case 13 : 
-    build_choices(); 
-    break; 
-  case 9 : 
-    {
-      unsave(); 
-      decr(save_ptr); 
-      mem[save_stack[save_ptr + 0].cint].hh.v.RH = 3; 
-      p = fin_mlist(0); 
-      mem[save_stack[save_ptr + 0].cint].hh.v.LH = p; 
-      if (p != 0)
-      if (mem[p].hh.v.RH == 0)
-      if (mem[p].hh.b0 == 16)
+        end_graf();
+        package(0);
+      }
+      break;
+
+    case vtop_group:
       {
-  if (mem[p + 3].hh.v.RH == 0)
-  if (mem[p + 2].hh.v.RH == 0)
-  {
-    mem[save_stack[save_ptr + 0].cint].hh = mem[p + 1].hh; 
-    free_node(p, 4); 
-  } 
-      } 
-      else if (mem[p].hh.b0 == 28)
-      if (save_stack[save_ptr + 0].cint == tail + 1)
-      if (mem[tail].hh.b0 == 16)
+        end_graf();
+        package(vtop_code);
+      }
+      break;
+
+    case insert_group:
       {
-  q = head; 
-  while(mem[q].hh.v.RH != tail)q = mem[q].hh 
-  .v.RH; 
-  mem[q].hh.v.RH = p; 
-  free_node(tail, 4); 
-  tail = p; 
-      } 
-    } 
-    break; 
-    default: 
-    {
-      confusion("rightbrace");
-      return;       // abort_flag set
-    }
-    break; 
-  } 
-} 
-/* sec 1030 */
-/* main control loop */
-void main_control (void) 
-{/* 60 21 70 80 90 91 92 95 100 101 110 111 112 120 10 */
-    integer t; 
-  integer bSuppress;    /* 199/Jan/5 */
+        end_graf();
+        q = split_top_skip;
+        add_glue_ref(q);
+        d = split_max_depth;
+        f = floating_penalty;
+        unsave();
+        decr(save_ptr);
+        p = vpackage(link(head), 0, 1, 1073741823L);  /* 2^30 - 1 */
+        pop_nest();
 
-  if (every_job != 0)/* everyjob */
-    begin_token_list(every_job, 12); 
+        if (saved(0) < 255)
+        {
+          tail_append(get_node(ins_node_size));
+          type(tail) = ins_node;
+          subtype(tail) = saved(0);
+          height(tail) = height(p) + depth(p);
+          ins_ptr(tail) = list_ptr(p);
+          split_top_ptr(tail) = q;
+          depth(tail) = d;
+          float_cost(tail) = f;
+        }
+        else
+        {
+          tail_append(get_node(small_node_size));
+          type(tail) = adjust_node;
+          subtype(tail) = 0;
+          adjust_ptr(tail) = list_ptr(p);
+          delete_glue_ref(q);
+        }
+        free_node(p, box_node_size);
 
-lab60:
-  get_x_token();       /* big_switch */
-lab21:
-  if (interrupt != 0)
-    if (OK_to_interrupt){
-      back_input(); 
+        if (nest_ptr == 0)
+        {
+          build_page();
+        }
+      }
+      break;
+    case output_group:
       {
-        if (interrupt != 0){
-          pause_for_instructions();
+        if ((cur_input.loc_field != 0) || ((token_type != output_text) && (token_type != backed_up)))
+        {
+          print_err("Unbalanced output routine");
+          help2("Your sneaky output routine has problematic {'s and/or }'s.",
+            "I can't handle that very well; good luck.");
+          error();
+
+          do
+            {
+              get_token();
+            }
+          while (!(cur_input.loc_field == 0));
         }
-      }  
-      goto lab60; 
-    } 
-  ;
-#ifdef DEBUG
-  if (panicking)check_mem(false); 
-#endif /* DEBUG */
-  if (tracing_commands > 0)
-    show_cur_cmd_chr(); 
 
-/*  the big switch --- don't bother to test abort_flag ??? */
-  switch(abs(mode)+ cur_cmd){
-       case 113 : 
-       case 114 : 
-       case 170 : 
-         goto lab70; 
-         break; 
-       case 118 : 
-       {
-         scan_char_num(); 
-         cur_chr = cur_val; 
-         goto lab70; 
-       } 
-       break; 
-       case 167 : 
-       {
-         get_x_token(); 
-         if ((cur_cmd == 11)||(cur_cmd == 12)||(cur_cmd == 68)||(
-           cur_cmd == 16)) 
-           cancel_boundary = true; 
-         goto lab21; 
-       } 
-       break; 
-  case 112 : 
-    if (space_factor == 1000)goto lab120; 
-    else {
-    app_space();
+        end_token_list();
+        end_graf();
+        unsave();
+        output_active = false;
+        insert_penalties = 0;
+
+        if (box(255) != 0)
+        {
+          print_err("Output routine didn't use all of ");
+          print_esc("box");
+          print_int(255);
+          help3("Your \\output commands should empty \\box255,",
+            "e.g., by saying `\\shipout\\box255'.",
+            "Proceed; I'll discard its present contents.");
+          box_error(255);
+        }
+
+        if (tail != head)
+        {
+          link(page_tail) = link(head);
+          page_tail = tail;
+        }
+
+        if (link(page_head) != 0)
+        {
+          if (link(contrib_head) == 0)
+            nest[0].tail_field = page_tail;
+
+          link(page_tail) = link(contrib_head);
+          link(contrib_head) = link(page_head);
+          link(page_head) = 0;
+          page_tail = page_head;
+        }
+        pop_nest();
+        build_page();
+      }
+      break;
+
+    case disc_group:
+      build_discretionary();
+      break;
+
+    case align_group:
+      {
+        back_input();
+        cur_tok = cs_token_flag + frozen_cr;
+        print_err("Missing ");
+        print_esc("cr");
+        print_string("inserted");
+        help1("I'm guessing that you meant to end an alignment here.");
+        ins_error();
+      }
+      break;
+
+    case no_align_group:
+      {
+        end_graf();
+        unsave();
+        align_peek();
+      }
+      break;
+
+    case vcenter_group:
+      {
+        end_graf();
+        unsave();
+        save_ptr = save_ptr - 2;
+        p = vpackage(link(head), saved(1), saved(0), 1073741823L);   /* 2^30 - 1 */
+        pop_nest();
+        tail_append(new_noad());
+        type(tail) = vcenter_noad;
+        math_type(nucleus(tail)) = sub_box;
+        info(nucleus(tail)) = p;
+      }
+      break;
+
+    case math_choice_group:
+      build_choices();
+      break;
+
+    case math_group:
+      {
+        unsave();
+        decr(save_ptr);
+        math_type(saved(0)) = sub_mlist;
+        p = fin_mlist(0);
+        info(saved(0)) = p;
+
+        if (p != 0)
+          if (link(p) == 0)
+            if (type(p) == ord_noad)
+            {
+              if (math_type(subscr(p)) == 0)
+                if (math_type(supscr(p)) == 0)
+                {
+                  mem[saved(0)].hh = mem[nucleus(p)].hh;
+                  free_node(p, noad_size);
+                }
+            }
+            else if (type(p) == accent_noad)
+              if (saved(0) == nucleus(tail))
+                if (type(tail) == ord_noad)
+                {
+                  q = head;
+
+                  while(link(q) != tail)
+                    q = link(q);
+
+                  link(q) = p;
+                  free_node(tail, noad_size);
+                  tail = p;
+                }
+      }
+      break;
+    default:
+      {
+        confusion("rightbrace");
+        return;       // abort_flag set
+      }
+      break;
   }
-    break; 
-  case 166 : 
-  case 267 : 
-    goto lab120; 
-    break; 
-  case 1 : 
-  case 102 : 
-  case 203 : 
-  case 11 : 
-  case 213 : 
-  case 268 : 
- ; 
-    break; 
-  case 40 : 
-  case 141 : 
-  case 242 : 
-    {
-      do {
-      get_x_token(); 
-      } while(!(cur_cmd != 10)); 
-      goto lab21; 
-    } 
-    break; 
-  case 15 : 
-    if (its_all_over ())return; 
-    break; 
-  case 23 : 
-  case 123 : 
-  case 224 : 
-  case 71 : 
-  case 172 : 
-  case 273 : 
-  case 39 : 
-  case 45 : 
-  case 49 : 
-  case 150 : 
-  case 7 : 
-  case 108 : 
-  case 209 : 
-    report_illegal_case(); 
-    break; 
-  case 8 : 
-  case 109 : 
-  case 9 : 
-  case 110 : 
-  case 18 : 
-  case 119 : 
-  case 70 : 
-  case 171 : 
-  case 51 : 
-  case 152 : 
-  case 16 : 
-  case 117 : 
-  case 50 : 
-  case 151 : 
-  case 53 : 
-  case 154 : 
-  case 67 : 
-  case 168 : 
-  case 54 : 
-  case 155 : 
-  case 55 : 
-  case 156 : 
-  case 57 : 
-  case 158 : 
-  case 56 : 
-  case 157 : 
-  case 31 : 
-  case 132 : 
-  case 52 : 
-  case 153 : 
-  case 29 : 
-  case 130 : 
-  case 47 : 
-  case 148 : 
-  case 212 : 
-  case 216 : 
-  case 217 : 
-  case 230 : 
-  case 227 : 
-  case 236 : 
-  case 239 : 
-    insert_dollar_sign(); 
-    break; 
-  case 37 : 
-  case 137 : 
-  case 238 : 
+}
+/* sec 1030 */
+void main_control (void) 
+{
+  integer t;
+  integer bSuppress; /* 199/Jan/5 */
+
+  if (every_job != 0)
+    begin_token_list(every_job, every_job_text);
+
+lab60:
+  get_x_token();       /* big_switch */
+
+lab21:
+  if (interrupt != 0)
+    if (OK_to_interrupt)
     {
+      back_input();
       {
-      mem[tail].hh.v.RH = scan_rule_spec(); 
-      tail = mem[tail].hh.v.RH; 
-      } 
-      if (abs(mode)== 1)
-      cur_list.aux_field.cint = ignore_depth; 
-      else if (abs(mode)== 102)
-      space_factor = 1000; 
-    } 
-    break; 
-  case 28 : 
-  case 128 : 
-  case 229 : 
-  case 231 : 
-    append_glue(); 
-    break; 
-  case 30 : 
-  case 131 : 
-  case 232 : 
-  case 233 : 
-    append_kern(); 
-    break; 
-  case 2 : 
-  case 103 : 
-    new_save_level(1); 
-    break; 
-  case 62 : 
-  case 163 : 
-  case 264 : 
-    new_save_level(14); 
-    break; 
-  case 63 : 
-  case 164 : 
-  case 265 : 
-    if (cur_group == 14) unsave(); 
-    else off_save();
-    break; 
-  case 3 : 
-  case 104 : 
-  case 205 : 
-    handle_right_brace(); 
-    break; 
-  case 22 : 
-  case 124 : 
-  case 225 : 
-    {
-      t = cur_chr; 
-      scan_dimen(false, false, false); 
-      if (t == 0)scan_box(cur_val);
-      else scan_box(- (integer) cur_val);
-    } 
-    break; 
-  case 32 : 
-  case 133 : 
-  case 234 : 
-/* scan_box(leader_flag-a_leaders+cur_chr); */
-    scan_box(1073742237L + cur_chr); /* 2^30 + 513 - 100 ? */
-    break; 
-  case 21 : 
-  case 122 : 
-  case 223 : 
-    begin_box(0); 
-    break; 
-  case 44 : 
-    new_graf(cur_chr > 0); 
-    break; 
-  case 12 : 
-  case 13 : 
-  case 17 : 
-  case 69 : 
-  case 4 : 
-  case 24 : 
-  case 36 : 
-  case 46 : 
-  case 48 : 
-  case 27 : 
-  case 34 : 
-  case 65 : 
-  case 66 : 
-    {
-      back_input(); 
-      new_graf(true); 
-    } 
-    break; 
-  case 145 : 
-  case 246 : 
-    indent_in_hmode(); 
-    break; 
-  case 14 : 
-    {
-      normal_paragraph(); 
-      if (mode > 0){
-      build_page();
-    }
-    } 
-    break; 
-  case 115 : 
-    {
-      if (align_state < 0){
-      off_save();
-    }
-      end_graf(); 
-      if (mode == 1){
-      build_page();
+        if (interrupt != 0)
+        {
+          pause_for_instructions();
+        }
+      }
+      goto lab60;
     }
-    } 
-    break; 
-  case 116 : 
-  case 129 : 
-  case 138 : 
-  case 126 : 
-  case 134 : 
-    head_for_vmode(); 
-    break; 
-  case 38 : 
-  case 139 : 
-  case 240 : 
-  case 140 : 
-  case 241 : 
-    begin_insert_or_adjust(); 
-    break; 
-  case 19 : 
-  case 120 : 
-  case 221 : 
-    make_mark(); 
-    break; 
-  case 43 : 
-  case 144 : 
-  case 245 : 
-    append_penalty(); 
-    break; 
-  case 26 : 
-  case 127 : 
-  case 228 : 
-    delete_last(); 
-    break; 
-  case 25 : 
-  case 125 : 
-  case 226 : 
-    unpackage(); 
-    break; 
-  case 146 : 
-    append_italic_correction(); 
-    break; 
-  case 247 : 
-    {
-      mem[tail].hh.v.RH = new_kern(0); 
-      tail = mem[tail].hh.v.RH; 
-    } 
-    break; 
-  case 149 : 
-  case 250 : 
-    append_discretionary(); 
-    break; 
-  case 147 : 
-    make_accent(); 
-    break; 
-  case 6 : 
-  case 107 : 
-  case 208 : 
-  case 5 : 
-  case 106 : 
-  case 207 : 
-    align_error(); 
-    break; 
-  case 35 : 
-  case 136 : 
-  case 237 : 
-    noalign_error(); 
-    break; 
-  case 64 : 
-  case 165 : 
-  case 266 : 
-    omit_error(); 
-    break; 
-  case 33 : 
-  case 135 : 
-    init_align(); 
-    break; 
-  case 235 : 
-    if (privileged ())
-    if (cur_group == 15)init_align();
-    else off_save();
-
-    break; 
-  case 10 : 
-  case 111 : 
-    do_endv(); 
-    break; 
-  case 68 : 
-  case 169 : 
-  case 270 : 
-    cs_error(); 
-    break; 
-  case 105 : 
-    init_math(); 
-    break; 
-  case 251 : 
-    if (privileged ())
-    if (cur_group == 15) start_eq_no(); 
-    else off_save();
-    break; 
-  case 204 : 
-    {
+
+#ifdef DEBUG
+  if (panicking)
+    check_mem(false);
+#endif
+
+  if (tracing_commands > 0)
+    show_cur_cmd_chr();
+
+/*  the big switch --- don't bother to test abort_flag ??? */
+  switch(abs(mode) + cur_cmd)
+  {
+    case hmode + letter:
+    case hmode + other_char:
+    case hmode + char_given:
+      goto lab70;
+      break;
+
+    case hmode + char_num:
       {
-  mem[tail].hh.v.RH = new_noad(); 
-  tail = mem[tail].hh.v.RH; 
-      } 
-      back_input(); 
-      scan_math(tail + 1); 
-    } 
-    break; 
-  case 214 : 
-  case 215 : 
-  case 271 : 
-    set_math_char(eqtb[(hash_size + 2907) + cur_chr].hh.v.RH); 
-    break; 
-  case 219 : 
-    {
-      scan_char_num(); 
-      cur_chr = cur_val; 
-      set_math_char(eqtb[(hash_size + 2907) + cur_chr].hh.v.RH); 
-    } 
-    break; 
-  case 220 : 
-    {
-      scan_fifteen_bit_int(); 
-      set_math_char(cur_val); 
-    } 
-    break; 
-  case 272 : 
-    set_math_char(cur_chr); 
-    break; 
-  case 218 : 
-    {
-      scan_twenty_seven_bit_int(); 
-      set_math_char(cur_val / 4096);  
-/*      set_math_char(cur_val >> 12); */
-    } 
-    break; 
-  case 253 : 
-    {
+        scan_char_num();
+        cur_chr = cur_val;
+        goto lab70;
+      }
+      break;
+
+    case hmode + no_boundary:
       {
-      mem[tail].hh.v.RH = new_noad(); 
-      tail = mem[tail].hh.v.RH; 
-      } 
-      mem[tail].hh.b0 = cur_chr; 
-      scan_math(tail + 1); 
-    } 
-    break; 
-  case 254 : 
-    math_limit_switch(); 
-    break; 
-  case 269 : 
-    math_radical(); 
-    break; 
-  case 248 : 
-  case 249 : 
-    math_ac(); 
-    break; 
-  case 259 : 
-    {
-      scan_spec(12, false); 
-      normal_paragraph(); 
-      push_nest(); 
-      mode = -1; 
-      cur_list.aux_field.cint = ignore_depth; 
-      if (every_vbox != 0)/* everyvbox */
-      begin_token_list(every_vbox, 11); 
-    } 
-    break; 
-  case 256 : 
-    {
-      mem[tail].hh.v.RH = new_style(cur_chr); 
-      tail = mem[tail].hh.v.RH; 
-    } 
-    break; 
-  case 258 : 
-    {
+        get_x_token();
+
+        if ((cur_cmd == letter) || (cur_cmd == other_char) ||
+          (cur_cmd == char_given) || (cur_cmd == char_num))
+          cancel_boundary = true;
+        goto lab21;
+      }
+      break;
+
+    case hmode + spacer:
+      if (space_factor == 1000)
+        goto lab120;
+      else
+        app_space();
+      break;
+
+    case hmode + ex_space:
+    case mmode + ex_space:
+      goto lab120;
+      break;
+
+    case any_mode(relax):
+    case vmode + spacer:
+    case mmode + spacer:
+    case mmode + no_boundary:
+      ;
+      break;
+
+    case any_mode(ignore_spaces):
       {
-      mem[tail].hh.v.RH = new_glue(0); 
-      tail = mem[tail].hh.v.RH; 
-      } 
-      mem[tail].hh.b1 = 98; 
-    } 
-    break; 
-  case 257 : 
-    append_choices(); 
-    break; 
-  case 211 : 
-  case 210 : 
-    sub_sup(); 
-    break; 
-  case 255 : 
-    math_fraction(); 
-    break; 
-  case 252 : 
-    math_left_right(); 
-    break; 
-  case 206 : 
-    if (cur_group == 15)after_math(); 
-    else off_save();
-    break; 
-  case 72 : 
-  case 173 : 
-  case 274 : 
-  case 73 : 
-  case 174 : 
-  case 275 : 
-  case 74 : 
-  case 175 : 
-  case 276 : 
-  case 75 : 
-  case 176 : 
-  case 277 : 
-  case 76 : 
-  case 177 : 
-  case 278 : 
-  case 77 : 
-  case 178 : 
-  case 279 : 
-  case 78 : 
-  case 179 : 
-  case 280 : 
-  case 79 : 
-  case 180 : 
-  case 281 : 
-  case 80 : 
-  case 181 : 
-  case 282 : 
-  case 81 : 
-  case 182 : 
-  case 283 : 
-  case 82 : 
-  case 183 : 
-  case 284 : 
-  case 83 : 
-  case 184 : 
-  case 285 : 
-  case 84 : 
-  case 185 : 
-  case 286 : 
-  case 85 : 
-  case 186 : 
-  case 287 : 
-  case 86 : 
-  case 187 : 
-  case 288 : 
-  case 87 : 
-  case 188 : 
-  case 289 : 
-  case 88 : 
-  case 189 : 
-  case 290 : 
-  case 89 : 
-  case 190 : 
-  case 291 : 
-  case 90 : 
-  case 191 : 
-  case 292 : 
-  case 91 : 
-  case 192 : 
-  case 293 : 
-  case 92 : 
-  case 193 : 
-  case 294 : 
-  case 93 : 
-  case 194 : 
-  case 295 : 
-  case 94 : 
-  case 195 : 
-  case 296 : 
-  case 95 : 
-  case 196 : 
-  case 297 : 
-  case 96 : 
-  case 197 : 
-  case 298 : 
-  case 97 : 
-  case 198 : 
-  case 299 : 
-  case 98 : 
-  case 199 : 
-  case 300 : 
-  case 99 : 
-  case 200 : 
-  case 301 : 
-  case 100 : 
-  case 201 : 
-  case 302 : 
-  case 101 : 
-  case 202 : 
-  case 303 : 
-    prefixed_command(); 
-    break; 
-  case 41 : 
-  case 142 : 
-  case 243 : 
-    {
-      get_token(); 
-      after_token = cur_tok; 
-    } 
-    break; 
-  case 42 : 
-  case 143 : 
-  case 244 : 
-    {
-      get_token(); 
-      save_for_after(cur_tok); 
-    } 
-    break; 
-  case 61 : 
-  case 162 : 
-  case 263 : 
-    open_or_close_in(); 
-    break; 
-  case 59 : 
-  case 160 : 
-  case 261 : 
-    issue_message(); 
-    break; 
-  case 58 : 
-  case 159 : 
-  case 260 : 
-    shift_case(); 
-    break; 
-  case 20 : 
-  case 121 : 
-  case 222 : 
-    show_whatever(); 
-    break; 
-  case 60 : 
-  case 161 : 
-  case 262 : 
-    do_extension(); 
-    break; 
+        do
+          {
+            get_x_token();
+          }
+        while(!(cur_cmd != spacer));
+        goto lab21;
+      }
+      break;
+
+    case vmode + stop:
+      if (its_all_over())
+        return;
+      break;
+
+    case vmode + vmove:
+    case hmode + hmove:
+    case mmode + hmove:
+    case any_mode(last_item):
+    case vmode + vadjust:
+    case vmode + ital_corr:
+    case non_math(eq_no):
+    case any_mode(mac_param):
+      report_illegal_case();
+      break;
+
+    case non_math(sup_mark):
+    case non_math(sub_mark):
+    case non_math(math_char_num):
+    case non_math(math_given):
+    case non_math(math_comp):
+    case non_math(delim_num):
+    case non_math(left_right):
+    case non_math(above):
+    case non_math(radical):
+    case non_math(math_style):
+    case non_math(math_choice):
+    case non_math(vcenter):
+    case non_math(non_script):
+    case non_math(mkern):
+    case non_math(limit_switch):
+    case non_math(mskip):
+    case non_math(math_accent):
+    case mmode + endv:
+    case mmode + par_end:
+    case mmode + stop:
+    case mmode + vskip:
+    case mmode + un_vbox:
+    case mmode + valign:
+    case mmode + hrule:
+      insert_dollar_sign();
+      break;
+
+    case vmode + hrule:
+    case hmode + vrule:
+    case mmode + vrule:
+      {
+        tail_append(scan_rule_spec());
+
+        if (abs(mode) == vmode)
+          prev_depth = ignore_depth;
+        else if (abs(mode) == hmode)
+          space_factor = 1000;
+      }
+      break;
+
+    case vmode + vskip:
+    case hmode + hskip:
+    case mmode + hskip:
+    case mmode + mskip:
+      append_glue();
+      break;
+
+    case any_mode(kern):
+    case mmode + mkern:
+      append_kern();
+      break;
+
+    case non_math(left_brace):
+      new_save_level(simple_group);
+      break;
+
+    case any_mode(begin_group):
+      new_save_level(semi_simple_group);
+      break;
+
+    case any_mode(end_group):
+      if (cur_group == semi_simple_group)
+        unsave();
+      else
+        off_save();
+      break;
+
+    case any_mode(right_brace):
+      handle_right_brace();
+      break;
+
+    case vmode + hmove:
+    case hmode + vmove:
+    case mmode + vmove:
+      {
+        t = cur_chr;
+        scan_dimen(false, false, false);
+
+        if (t == 0)
+          scan_box(cur_val);
+        else
+          scan_box(- (integer) cur_val);
+      }
+      break;
+
+    case any_mode(leader_ship):
+      scan_box(leader_flag - a_leaders + cur_chr);
+      break;
+
+    case any_mode(make_box):
+      begin_box(0);
+      break;
+
+    case vmode + start_par:
+      new_graf(cur_chr > 0);
+      break;
+
+    case vmode + letter:
+    case vmode + other_char:
+    case vmode + char_num:
+    case vmode + char_given:
+    case vmode + math_shift:
+    case vmode + un_hbox:
+    case vmode + vrule:
+    case vmode + accent:
+    case vmode + discretionary:
+    case vmode + hskip:
+    case vmode + valign:
+    case vmode + ex_space:
+    case vmode + no_boundary:
+      {
+        back_input();
+        new_graf(true);
+      }
+      break;
+
+    case hmode + start_par:
+    case mmode + start_par:
+      indent_in_hmode();
+      break;
+
+    case vmode + par_end:
+      {
+        normal_paragraph();
+
+        if (mode > 0)
+          build_page();
+      }
+      break;
+
+    case hmode + par_end:
+      {
+        if (align_state < 0)
+          off_save();
+
+        end_graf();
+
+        if (mode == 1)
+          build_page();
+      }
+      break;
+
+    case hmode + stop:
+    case hmode + vskip:
+    case hmode + hrule:
+    case hmode + un_vbox:
+    case hmode + halign:
+      head_for_vmode();
+      break;
+
+    case any_mode(insert):
+    case hmode + vadjust:
+    case mmode + vadjust:
+      begin_insert_or_adjust();
+      break;
+
+    case any_mode(mark):
+      make_mark();
+      break;
+
+    case any_mode(break_penalty):
+      append_penalty();
+      break;
+
+    case any_mode(remove_item):
+      delete_last();
+      break;
+
+    case vmode + un_vbox:
+    case hmode + un_hbox:
+    case mmode + un_hbox:
+      unpackage();
+      break;
+
+    case hmode + ital_corr:
+      append_italic_correction();
+      break;
+
+    case mmode + ital_corr:
+      tail_append(new_kern(0));
+      break;
+
+    case hmode + discretionary:
+    case mmode + discretionary:
+      append_discretionary();
+      break;
+
+    case hmode + accent:
+      make_accent();
+      break;
+
+    case any_mode(car_ret):
+    case any_mode(tab_mark):
+      align_error();
+      break;
+
+    case any_mode(no_align):
+      noalign_error();
+      break;
+
+    case any_mode(omit):
+      omit_error();
+      break;
+
+    case vmode + halign:
+    case hmode + valign:
+      init_align();
+      break;
+
+    case mmode + halign:
+      if (privileged ())
+        if (cur_group == math_shift_group)
+          init_align();
+        else
+          off_save();
+      break;
+
+    case vmode + endv:
+    case hmode + endv:
+      do_endv();
+      break;
+
+    case any_mode(end_cs_name):
+      cs_error();
+      break;
+
+    case hmode + math_shift:
+      init_math();
+      break;
+
+    case mmode + eq_no:
+      if (privileged ())
+        if (cur_group == math_shift_group)
+          start_eq_no();
+        else
+          off_save();
+      break;
+
+    case mmode + left_brace:
+      {
+        tail_append(new_noad());
+        back_input();
+        scan_math(nucleus(tail));
+      }
+      break;
+
+    case mmode + letter:
+    case mmode + other_char:
+    case mmode + char_given:
+      set_math_char(math_code(cur_chr));
+      break;
+
+    case mmode + char_num:
+      {
+        scan_char_num();
+        cur_chr = cur_val;
+        set_math_char(math_code(cur_chr));
+      }
+      break;
+
+    case mmode + math_char_num:
+      {
+        scan_fifteen_bit_int();
+        set_math_char(cur_val);
+      }
+      break;
+
+    case mmode + math_given:
+      set_math_char(cur_chr);
+      break;
+
+    case mmode + delim_num:
+      {
+        scan_twenty_seven_bit_int();
+        set_math_char(cur_val / 4096);
+      }
+      break;
+
+    case mmode + math_comp:
+      {
+        tail_append(new_noad());
+        type(tail) = cur_chr;
+        scan_math(nucleus(tail));
+      }
+      break;
+
+    case mmode + limit_switch:
+      math_limit_switch();
+      break;
+
+    case mmode + radical:
+      math_radical();
+      break;
+
+    case mmode + accent:
+    case mmode + math_accent:
+      math_ac();
+      break;
+
+    case mmode + vcenter:
+      {
+        scan_spec(vcenter_group, false);
+        normal_paragraph();
+        push_nest();
+        mode = -1;
+        prev_depth = ignore_depth;
+
+        if (every_vbox != 0)
+          begin_token_list(every_vbox, every_vbox_text);
+      }
+      break;
+
+    case mmode + math_style:
+      tail_append(new_style(cur_chr));
+      break;
+
+    case mmode + non_script:
+      {
+        tail_append(new_glue(0));
+        subtype(tail) = cond_math_glue;
+      }
+      break;
+
+    case mmode + math_choice:
+      append_choices();
+      break;
+
+    case mmode + sub_mark:
+    case mmode + sup_mark:
+      sub_sup();
+      break;
+
+    case mmode + above:
+      math_fraction();
+      break;
+
+    case mmode + left_right:
+      math_left_right();
+      break;
+
+    case mmode + math_shift:
+      if (cur_group == math_shift_group)
+        after_math();
+      else
+        off_save();
+      break;
+
+    case any_mode(toks_register):
+    case any_mode(assign_toks):
+    case any_mode(assign_int):
+    case any_mode(assign_dimen):
+    case any_mode(assign_glue):
+    case any_mode(assign_mu_glue):
+    case any_mode(assign_font_dimen):
+    case any_mode(assign_font_int):
+    case any_mode(set_aux):
+    case any_mode(set_prev_graf):
+    case any_mode(set_page_dimen):
+    case any_mode(set_page_int):
+    case any_mode(set_box_dimen):
+    case any_mode(set_shape):
+    case any_mode(def_code):
+    case any_mode(def_family):
+    case any_mode(set_font):
+    case any_mode(def_font):
+    case any_mode(tex_register):
+    case any_mode(advance):
+    case any_mode(multiply):
+    case any_mode(divide):
+    case any_mode(prefix):
+    case any_mode(let):
+    case any_mode(shorthand_def):
+    case any_mode(read_to_cs):
+    case any_mode(def):
+    case any_mode(set_box):
+    case any_mode(hyph_data):
+    case any_mode(set_interaction):
+      prefixed_command();
+      break;
+
+    case any_mode(after_assignment):
+      {
+        get_token();
+        after_token = cur_tok;
+      }
+      break;
+
+    case any_mode(after_group):
+      {
+        get_token();
+        save_for_after(cur_tok);
+      }
+      break;
+
+    case any_mode(in_stream):
+      open_or_close_in();
+      break;
+
+    case any_mode(message):
+      issue_message();
+      break;
+
+    case any_mode(case_shift):
+      shift_case();
+      break;
+
+    case any_mode(xray):
+      show_whatever();
+      break;
+
+    case any_mode(extension):
+      do_extension();
+      break;
   } /* end of big switch */
   goto lab60; /*  main_loop */
 
 lab70:
-  main_s = eqtb[(hash_size + 2651) + cur_chr].hh.v.RH; 
-  if (main_s == 1000)
-    space_factor = 1000; 
-  else if (main_s < 1000)
-  {
-    if (main_s > 0)
-    space_factor = main_s; 
-  } 
-  else if (space_factor < 1000)
-    space_factor = 1000; 
-  else space_factor = main_s; 
-  main_f = eqtb[(hash_size + 1834)].hh.v.RH; 
-  bchar = font_bchar[main_f]; 
-  false_bchar = font_false_bchar[main_f]; 
+  adjust_space_factor();
+  main_f = cur_font;
+  bchar = font_bchar[main_f];
+  false_bchar = font_false_bchar[main_f];
+
   if (mode > 0)
-  if (language != clang)
-  fix_language(); 
+    if (language != clang)
+      fix_language();
   {
-    lig_stack = avail; 
+    lig_stack = avail;
+
     if (lig_stack == 0)
-    lig_stack = get_avail(); 
-    else {
-      avail = mem[lig_stack].hh.v.RH; 
-      mem[lig_stack].hh.v.RH = 0; 
-  ;
+      lig_stack = get_avail();
+    else
+    {
+      avail = mem[lig_stack].hh.v.RH;
+      mem[lig_stack].hh.v.RH = 0;
 #ifdef STAT
-      incr(dyn_used); 
+      incr(dyn_used);
 #endif /* STAT */
-    } 
-  } 
-  mem[lig_stack].hh.b0 = main_f; 
-  cur_l = cur_chr; 
-  mem[lig_stack].hh.b1 = cur_l; 
-  cur_q = tail; 
+    }
+  }
+
+  font(lig_stack) = main_f;
+  cur_l = cur_chr;
+  character(lig_stack) = cur_l;
+  cur_q = tail;
+
   if (cancel_boundary)
   {
-/*  begin cancel_boundary:=false; main_k:=non_address; l.20093 */
-    cancel_boundary = false; 
-/* main_k:=non_address 3.14159 */
-/*    main_k = font_mem_size; */    /* OK ? 1993/Nov/29 */
-    main_k = non_address;     /* i.e. --- 1995/Jan/15 3.14159 */
-  } 
-  else main_k = bchar_label[main_f]; 
-/* if main_k=non_address then goto main_loop_move+2; l.20096 */
-/*  if (main_k == font_mem_size) */
-  if (main_k == non_address)   /* i.e. 0 --- 1995/Jan/15 */
-/* cur_r:=cur_l; cur_l:=non_char; */
-  goto lab92; 
-  cur_r = cur_l; 
-  cur_l = 256;            /* cur_l:=non_char; */
-/* goto main_lig_loop+1; l.20071 */
-  goto lab111; 
-
-/* main_loop_wrapup:@<Make a ligature node, if |ligature_present|;
-  insert a null discretionary, if appropriate@>; */
-/* @d wrapup(#)==if cur_l<non_char then */
-/*  main_loop_wrapup */
-lab80: if (cur_l < 256)
-  {
-/*  begin if character(tail)=qi(hyphen_char[main_f]) then
-  if link(cur_q)>null then ... l.20107 */
-    if (mem[tail].hh.b1 == hyphen_char[main_f])
-/*    if (mem[cur_q].hh.v.RH > 0) */ /* NO! */
-    if (mem[cur_q].hh.v.RH != 0) /* BUG FIX l.20107 */
-    ins_disc = true; 
-    if (ligature_present)
-    {
-      main_p = new_ligature(main_f, cur_l, mem[cur_q].hh.v.RH); 
-      if (lft_hit)
-      {
-  mem[main_p].hh.b1 = 2; 
-  lft_hit = false; 
-      } 
-      if (rt_hit)
-      if (lig_stack == 0)
-      {
-  incr(mem[main_p].hh.b1); 
-  rt_hit = false; 
-      } 
-      mem[cur_q].hh.v.RH = main_p; 
-      tail = main_p; 
-      ligature_present = false; 
-    } 
-/*   if ins_disc then l.20110 */
-    if (ins_disc)
-    {
-      ins_disc = false; 
-/*   if mode>0 then tail_append(new_disc); l.20112 */
-      if (mode > 0)
-      {
-  mem[tail].hh.v.RH = new_disc(); 
-  tail = mem[tail].hh.v.RH; 
-      } 
-    } 
-  } 
+    cancel_boundary = false;
+    main_k = non_address;
+  }
+  else
+    main_k = bchar_label[main_f];
+
+  if (main_k == non_address)
+    goto lab92;
+
+  cur_r = cur_l;
+  cur_l = non_char;
+  goto lab111;
+
+lab80: 
+  wrapup(rt_hit);
 
 /*  main_loop_move */
 lab90:
-  if (lig_stack == 0) goto lab21; 
-  cur_q = tail; 
-  cur_l = mem[lig_stack].hh.b1; 
+  if (lig_stack == 0)
+    goto lab21;
+
+  cur_q = tail;
+  cur_l = character(lig_stack);
 
 lab91:
-  if (!(lig_stack >= hi_mem_min)) goto lab95; 
+  if (!(lig_stack >= hi_mem_min))
+    goto lab95;
 
-lab92: if ((cur_chr < font_bc[main_f])||(cur_chr > font_ec[main_f])) 
+lab92:
+  if ((cur_chr < font_bc[main_f]) || (cur_chr > font_ec[main_f]))
   {
-    char_warning(main_f, cur_chr); 
-    {
-      mem[lig_stack].hh.v.RH = avail; 
-      avail = lig_stack; 
-  ;
-#ifdef STAT
-      decr(dyn_used); 
-#endif /* STAT */
-    } 
-    goto lab60; 
-  } 
-  main_i = font_info[char_base[main_f]+ cur_l].qqqq; 
-  if (!(main_i.b0 > 0)) 
+    char_warning(main_f, cur_chr);
+    free_avail(lig_stack);
+    goto lab60;
+  }
+
+  main_i = char_info(main_f, cur_l);
+
+  if (!(main_i.b0 > 0))
   {
-    char_warning(main_f, cur_chr); 
-    {
-      mem[lig_stack].hh.v.RH = avail; 
-      avail = lig_stack; 
-  ;
-#ifdef STAT
-      decr(dyn_used); 
-#endif /* STAT */
-    } 
+    char_warning(main_f, cur_chr);
+    free_avail(lig_stack);
     goto lab60; 
-  } 
+  }
   {
-    link(tail) = lig_stack; 
-    tail = lig_stack; 
-  } 
+    link(tail) = lig_stack;
+    tail = lig_stack;
+  }
 
 /*  main_loop_lookahead */
 lab100:
-  get_next(); 
-  if (cur_cmd == 11) goto lab101; 
-  if (cur_cmd == 12) goto lab101; 
-  if (cur_cmd == 68) goto lab101; 
-  x_token(); 
-  if (cur_cmd == 11) goto lab101; 
-  if (cur_cmd == 12) goto lab101; 
-  if (cur_cmd == 68) goto lab101; 
-  if (cur_cmd == 16) {
-    scan_char_num(); 
-    cur_chr = cur_val; 
-    goto lab101; 
-  } 
-  if (cur_cmd == 65) bchar = 256; 
-  cur_r = bchar; 
-  lig_stack = 0; 
-  goto lab110; 
-
-lab101: main_s = eqtb[(hash_size + 2651) + cur_chr].hh.v.RH; 
-  if (main_s == 1000)
-  space_factor = 1000; 
-  else if (main_s < 1000)
+  get_next();
+
+  if (cur_cmd == letter)
+    goto lab101;
+  if (cur_cmd == other_char)
+    goto lab101;
+  if (cur_cmd == char_given)
+    goto lab101;
+
+  x_token();
+
+  if (cur_cmd == letter)
+    goto lab101;
+  if (cur_cmd == other_char)
+    goto lab101;
+  if (cur_cmd == char_given)
+    goto lab101;
+
+  if (cur_cmd == char_num)
   {
-    if (main_s > 0)
-    space_factor = main_s; 
-  } 
-  else if (space_factor < 1000)
-  space_factor = 1000; 
-  else space_factor = main_s; 
+    scan_char_num();
+    cur_chr = cur_val;
+    goto lab101;
+  }
+
+  if (cur_cmd == no_boundary)
+    bchar = non_char;
+
+  cur_r = bchar;
+  lig_stack = 0;
+  goto lab110;
+
+lab101:
+  adjust_space_factor();
+
   {
-    lig_stack = avail; 
+    lig_stack = avail;
+
     if (lig_stack == 0)
-    lig_stack = get_avail(); 
-    else {
-      avail = mem[lig_stack].hh.v.RH; 
-      mem[lig_stack].hh.v.RH = 0; 
-  ;
+      lig_stack = get_avail();
+    else
+    {
+      avail = mem[lig_stack].hh.v.RH;
+      mem[lig_stack].hh.v.RH = 0;
 #ifdef STAT
-      incr(dyn_used); 
+      incr(dyn_used);
 #endif /* STAT */
-    } 
-  } 
-  mem[lig_stack].hh.b0 = main_f; 
-  cur_r = cur_chr; 
-  mem[lig_stack].hh.b1 = cur_r; 
+    }
+  }
+
+  font(lig_stack) = main_f;
+  cur_r = cur_chr;
+  character(lig_stack) = cur_r;
+
   if (cur_r == false_bchar)
-    cur_r = 256; 
+    cur_r = non_char;
 
 // main_lig_loop:@<If there's a ligature/kern command relevant to |cur_l| and
 //  |cur_r|, adjust the text appropriately; exit to |main_loop_wrapup|@>;
 lab110:
-/*  if char_tag(main_i)<>lig_tag then goto main_loop_wrapup; */
-  if (((main_i.b2) % 4)!= 1)
+
+  if (char_tag(main_i) != lig_tag)
+    goto lab80;
+
+  if (cur_r == non_char)
     goto lab80;
-/* 425 in tex82.bug */
-  if (cur_r == 256)
-         goto lab80;
-/*  main_k:=lig_kern_start(main_f)(main_i); */
-  main_k = lig_kern_base[main_f]+ main_i.b3; 
-/*  main_j:=font_info[main_k].qqqq; */
-  main_j = font_info[main_k].qqqq; 
-/* if skip_byte(main_j)<=stop_flag then goto main_lig_loop+2; */
-  if (main_j.b0 <= 128)goto lab112; 
-/* main_k:=lig_kern_restart(main_f)(main_j); */
-  main_k = lig_kern_base[main_f]+ 256 * main_j.b2 + main_j.b3 + 32768L - 256 * 
- (128); 
+
+  main_k = lig_kern_start(main_f, main_i);
+  main_j = font_info[main_k].qqqq;
+
+  if (skip_byte(main_j) <= stop_flag)
+    goto lab112;
+
+  main_k = lig_kern_restart(main_f, main_j);
 
 /* main_lig_loop+1:main_j:=font_info[main_k].qqqq; */
-lab111: main_j = font_info[main_k].qqqq; 
+lab111:
+  main_j = font_info[main_k].qqqq;
 
-/* main_lig_loop+2:if next_char(main_j)=cur_r then l.20184 */
 lab112:
-/*  provide for suppression of f-ligatures 99/Jan/5 */
+/* provide for suppression of f-ligatures 99/Jan/5 */
   bSuppress = 0;
-  if (suppress_f_ligs && main_j.b1 == cur_r && main_j.b2 == 0) {
-    if (cur_l == 'f') 
-        bSuppress = 1;
-  }
 
-/*  if (main_j.b1 == cur_r)*/
-  if (main_j.b1 == cur_r && bSuppress == 0)  /* 99/Jan/5 */
-/*  if skip_byte(main_j)<=stop_flag then l.20185 */
-//   @<Do ligature or kern command, returning to |main_lig_loop|
-//    or |main_loop_wrapup| or |main_loop_move|@>;
-  if (main_j.b0 <= 128)
-  {
-/* begin if op_byte(main_j)>=kern_flag then l.20225 */
-    if (main_j.b2 >= 128)
-    {
-/* @d wrapup(#)==if cur_l<non_char then */
-      if (cur_l < 256)
-      {
-/* if character(tail)=qi(hyphen_char[main_f]) then if link(cur_q)>null */
-  if (mem[tail].hh.b1 == hyphen_char[main_f])
-/*  if (mem[cur_q].hh.v.RH > 0) */ /* 94/Mar/22 ?????????????? */
-  if (mem[cur_q].hh.v.RH != 0) /* BUG FIX l.20107l.20186  */
-  ins_disc = true; 
-/*   if ligature_present then pack_lig(#); */
-  if (ligature_present)
-  {
-    main_p = new_ligature(main_f, cur_l, mem[cur_q].hh.v.RH); 
-    if (lft_hit)
-    {
-      mem[main_p].hh.b1 = 2; 
-      lft_hit = false; 
-    } 
-    if (rt_hit)
-    if (lig_stack == 0)
-    {
-      incr(mem[main_p].hh.b1); 
-      rt_hit = false; 
-    } 
-    mem[cur_q].hh.v.RH = main_p; 
-    tail = main_p; 
-    ligature_present = false; 
-  } 
-  if (ins_disc)
+  if (suppress_f_ligs && next_char(main_j) == cur_r && op_byte(main_j) == no_tag)
   {
-    ins_disc = false; 
-    if (mode > 0)
-    {
-      mem[tail].hh.v.RH = new_disc(); 
-      tail = mem[tail].hh.v.RH; 
-    } 
-  } 
-      } 
-      {
-  mem[tail].hh.v.RH = new_kern(font_info[kern_base[
-  main_f]+ 256 * main_j.b2 + main_j.b3].cint); 
-  tail = mem[tail].hh.v.RH; 
-      } 
-      goto lab90; 
-    } 
-/* begin if cur_l=non_char then lft_hit:=true; */
-    if (cur_l == 256)
-    lft_hit = true; 
-    else if (lig_stack == 0)
-    rt_hit = true; 
+    if (cur_l == 'f')
+      bSuppress = 1;
+  }
+
+  if (next_char(main_j) == cur_r && bSuppress == 0)  /* 99/Jan/5 */
+    if (skip_byte(main_j) <= stop_flag)
     {
-      if (interrupt != 0){
-      pause_for_instructions();
-    }
-    } 
-    switch(main_j.b2)
-    {case 1 : 
-    case 5 : 
-      {
-  cur_l = main_j.b3; 
-  main_i = font_info[char_base[main_f]+ cur_l].qqqq; 
-  ligature_present = true; 
-      } 
-      break; 
-    case 2 : 
-    case 6 : 
+      if (op_byte(main_j) >= kern_flag)
       {
-  cur_r = main_j.b3; 
-  if (lig_stack == 0)
-  {
-    lig_stack = new_lig_item(cur_r); 
-    bchar = 256; 
-  } 
-  else if ((lig_stack >= hi_mem_min)) 
-  {
-    main_p = lig_stack; 
-    lig_stack = new_lig_item(cur_r); 
-    mem[lig_stack + 1].hh.v.RH = main_p; 
-  } 
-  else mem[lig_stack].hh.b1 = cur_r; 
-      } 
-      break; 
-    case 3 : 
-      {
-  cur_r = main_j.b3; 
-  main_p = lig_stack; 
-  lig_stack = new_lig_item(cur_r); 
-  mem[lig_stack].hh.v.RH = main_p; 
-      } 
-      break; 
-    case 7 : 
-    case 11 : 
+        wrapup(rt_hit);
+        tail_append(new_kern(char_kern(main_f, main_j)));
+        goto lab90;
+      }
+
+      if (cur_l == non_char)
+        lft_hit = true;
+      else if (lig_stack == 0)
+        rt_hit = true;
+
       {
-  if (cur_l < 256) /* if cur_l<non_char then  */
-/*  begin if character(tail)=qi(hyphen_char[main_f]) then if link(cur_q)>null
-then */
-  {
-    if (mem[tail].hh.b1 == hyphen_char[main_f])
-/*    if (mem[cur_q].hh.v.RH > 0) */  /* 94/Mar/22 */
-    if (mem[cur_q].hh.v.RH != 0) /* BUG FIX ???????????? */
-    ins_disc = true; 
-    if (ligature_present)
-    {
-      main_p = new_ligature(main_f, cur_l, mem[cur_q].hh.v.RH); 
-      if (lft_hit)
+        if (interrupt != 0)
+        {
+          pause_for_instructions();
+        }
+      }
+
+      switch (op_byte(main_j))
       {
-        mem[main_p].hh.b1 = 2; 
-        lft_hit = false; 
-      } 
-/*      if (false)
-      if (lig_stack == 0){
-        incr(mem[main_p].hh.b1); 
-        rt_hit = false; 
-      } */              /* removed 99/Jan/6 */
-    mem[cur_q].hh.v.RH = main_p; 
-      tail = main_p; 
-      ligature_present = false; 
-    } 
-    if (ins_disc)
+        case 1:
+        case 5:
+          {
+            cur_l = rem_byte(main_j);
+            main_i = char_info(main_f, cur_l);
+            ligature_present = true;
+          }
+          break;
+        case 2:
+        case 6:
+          {
+            cur_r = rem_byte(main_j);
+
+            if (lig_stack == 0)
+            {
+              lig_stack = new_lig_item(cur_r);
+              bchar = non_char;
+            }
+            else if ((lig_stack >= hi_mem_min))
+            {
+              main_p = lig_stack;
+              lig_stack = new_lig_item(cur_r);
+              lig_ptr(lig_stack) = main_p;
+            }
+            else
+              character(lig_stack) = cur_r;
+          }
+          break;
+        case 3:
+          {
+            cur_r = rem_byte(main_j);
+            main_p = lig_stack;
+            lig_stack = new_lig_item(cur_r);
+            link(lig_stack) = main_p;
+          }
+          break;
+        case 7:
+        case 11:
+          {
+            wrapup(false);
+            cur_q = tail;
+            cur_l = rem_byte(main_j);
+            main_i = char_info(main_f, cur_l);
+            ligature_present = true;
+          }
+          break;
+        default:
+          {
+            cur_l = rem_byte(main_j);
+            ligature_present = true;
+            if (lig_stack == 0)
+              goto lab80;
+            else
+              goto lab91;
+          }
+          break;
+      }
+
+      if (op_byte(main_j) > 4)
+        if (op_byte(main_j) != 7)
+          goto lab80;
+
+      if (cur_l < non_char)
+        goto lab110;
+
+      main_k = bchar_label[main_f];
+      goto lab111;
+    }
+
+    if (skip_byte(main_j) == 0)
+      incr(main_k);
+    else
     {
-      ins_disc = false; 
-      if (mode > 0)
-      {
-        mem[tail].hh.v.RH = new_disc(); 
-        tail = mem[tail].hh.v.RH; 
-      } 
-    } 
-  } 
-  cur_q = tail; 
-  cur_l = main_j.b3; 
-  main_i = font_info[char_base[main_f]+ cur_l].qqqq; 
-  ligature_present = true; 
-      } 
-      break; 
-      default: 
-      {
-  cur_l = main_j.b3; 
-  ligature_present = true; 
-  if (lig_stack == 0)
-  goto lab80; 
-  else goto lab91; 
-      } 
-      break; 
-    } 
-    if (main_j.b2 > 4)
-    if (main_j.b2 != 7)
-    goto lab80; 
-    if (cur_l < 256)
-    goto lab110; 
-    main_k = bchar_label[main_f]; 
-    goto lab111; 
-  } 
-  if (main_j.b0 == 0)
-  incr(main_k); 
-  else {
-    if (main_j.b0 >= 128)
-    goto lab80; 
-    main_k = main_k + main_j.b0 + 1; 
-  } 
-  goto lab111; 
+      if (skip_byte(main_j) >= stop_flag)
+        goto lab80;
+
+      main_k = main_k + skip_byte(main_j) + 1;
+    }
+
+    goto lab111;
 
 /*  main_move_log */
-lab95: main_p = mem[lig_stack + 1].hh.v.RH; 
-/* if main_p>null then tail_append(main_p); l.20137 */
-/*  if (main_p > 0) */ /* 92/Mar/22 */
+lab95:
+  main_p = lig_ptr(lig_stack);
+
   if (main_p != 0)     /* BUG FIX */
-  {
-    mem[tail].hh.v.RH = main_p; 
-    tail = mem[tail].hh.v.RH; 
-  } 
-  temp_ptr = lig_stack; 
-  lig_stack = mem[temp_ptr].hh.v.RH; 
-  free_node(temp_ptr, 2); 
-  main_i = font_info[char_base[main_f]+ cur_l].qqqq; 
-  ligature_present = true; 
+    tail_append(main_p);
+
+  temp_ptr = lig_stack;
+  lig_stack = link(temp_ptr);
+  free_node(temp_ptr, small_node_size);
+  main_i = char_info(main_f, cur_l);
+  ligature_present = true;
+
   if (lig_stack == 0)
-/*   if main_p>null then goto main_loop_lookahead l.20142 */
-/*  if (main_p > 0) */ /* 94/Mar/2 */
-  if (main_p != 0)   /* BUG FIX */
-  goto lab100; 
-  else cur_r = bchar; 
-  else cur_r = mem[lig_stack].hh.b1; 
-  goto lab110; 
+    if (main_p != 0)   /* BUG FIX */
+      goto lab100;
+    else
+      cur_r = bchar;
+  else
+    cur_r = character(lig_stack);
+
+  goto lab110;
 
 /*  append_normal_space */
-lab120: if (eqtb[(hash_size + 794)].hh.v.RH == 0)
+lab120:
+  if (space_skip == 0)
   {
     {
-      main_p = font_glue[eqtb[(hash_size + 1834)].hh.v.RH]; 
+      main_p = font_glue[cur_font];
+
       if (main_p == 0)
       {
-  main_p = new_spec(0); 
-  main_k = param_base[eqtb[(hash_size + 1834)].hh.v.RH]+ 2; 
-  mem[main_p + 1].cint = font_info[main_k].cint; 
-  mem[main_p + 2].cint = font_info[main_k + 1].cint; 
-  mem[main_p + 3].cint = font_info[main_k + 2].cint; 
-  font_glue[eqtb[(hash_size + 1834)].hh.v.RH]= main_p; 
-      } 
-    } 
-    temp_ptr = new_glue(main_p); 
-  } 
-  else temp_ptr = new_param_glue(12); 
-  mem[tail].hh.v.RH = temp_ptr; 
-  tail = temp_ptr; 
-  goto lab60; 
-} /* end of main_control */
-/* give_err_help etc followed here in the old tex8.c */
+        main_p = new_spec(zero_glue);
+        main_k = param_base[cur_font] + space_code;
+        width(main_p) = font_info[main_k].cint;
+        stretch(main_p) = font_info[main_k + 1].cint;
+        shrink(main_p) = font_info[main_k + 2].cint;
+        font_glue[cur_font] = main_p;
+      }
+    }
+    temp_ptr = new_glue(main_p);
+  }
+  else
+    temp_ptr = new_param_glue(space_skip_code);
+
+  link(tail) = temp_ptr;
+  tail = temp_ptr;
+  goto lab60;
+}
+/* give_err_help etc followed here in the old tex8.c */
\ No newline at end of file