OSDN Git Service

updated with TeX Live 2014.
[putex/putex.git] / src / texsourc / itex.c
index e7c8b9f..87c35d0 100644 (file)
@@ -109,12 +109,12 @@ void initialize (void)
 
     if (flag)
     {
-      puts("Inverted mapping xord[] pairs:\n");
+      puts("Inverted mapping xord[] pairs:");
 
       for (k = 0; k < 256; k++)
       {
         if (xord[k] != 127)
-          printf("%d => %d\n", k, xord[k]);
+          printf("%lld => %d\n", k, xord[k]);
       }
     }
   }
@@ -142,7 +142,7 @@ void initialize (void)
   mode = 1;
   head = contrib_head;
   tail = contrib_head;
-  cur_list.aux_field.cint = ignore_depth;
+  prev_depth = ignore_depth;
   mode_line = 0;
   prev_graf = 0;
   shown_mode = 0;
@@ -297,13 +297,13 @@ void initialize_aux (void)
 void line_break_ (integer final_widow_penalty)
 {
   boolean auto_breaking;
-  halfword prev_p;
-  halfword q, r, s, prevs;
+  pointer prev_p;
+  pointer q, r, s, prev_s;
   internal_font_number f;
-/*  small_number j;  */
-  int j;                /* 95/Jan/7 */
-/*  unsigned char c;  */
-  unsigned int c;           /* 95/Jan/7 */
+  /* small_number j; */
+  int j;
+  /* unsigned char c; */
+  unsigned int c;
 
   pack_begin_line = mode_line;
   link(temp_head) = link(head);
@@ -338,11 +338,11 @@ void line_break_ (integer final_widow_penalty)
   background[2 + stretch_order(q)] = stretch(q);
   background[2 + stretch_order(r)] = background[2 + stretch_order(r)] + stretch(r);
   background[6] = shrink(q) + shrink(r);
-  minimum_demerits = 1073741823L; /* 2^30 - 1 *//* 40000000 hex - 1 */
-  minimal_demerits[tight_fit] = 1073741823L;
-  minimal_demerits[decent_fit] = 1073741823L;
-  minimal_demerits[loose_fit] = 1073741823L;
-  minimal_demerits[very_loose_fit] = 1073741823L;
+  minimum_demerits = awful_bad;
+  minimal_demerits[tight_fit] = awful_bad;
+  minimal_demerits[decent_fit] = awful_bad;
+  minimal_demerits[loose_fit] = awful_bad;
+  minimal_demerits[very_loose_fit] = awful_bad;
 
   if (par_shape_ptr == 0)
     if (hang_indent == 0)
@@ -387,9 +387,9 @@ void line_break_ (integer final_widow_penalty)
   }
 
   if (looseness == 0)
-    easyline = last_special_line;
+    easy_line = last_special_line;
   else
-    easyline = empty_flag;
+    easy_line = empty_flag;
 
   threshold = pretolerance;
 
@@ -435,11 +435,11 @@ void line_break_ (integer final_widow_penalty)
 #endif
 
       cur_lang = init_cur_lang;
-      lhyf = init_l_hyf;
-      rhyf = init_r_hyf;
+      l_hyf = init_l_hyf;
+      r_hyf = init_r_hyf;
     }
 
-    q = get_node(3);
+    q = get_node(active_node_size);
     type(q) = unhyphenated;
     fitness(q) = decent_fit;
     link(q) = active;
@@ -448,17 +448,11 @@ void line_break_ (integer final_widow_penalty)
     total_demerits(q) = 0;
     link(active) = q;
     act_width = background[1];
-    active_width[2] = background[2];
-    active_width[3] = background[3];
-    active_width[4] = background[4];
-    active_width[5] = background[5];
-    active_width[6] = background[6];
-
+    do_all_six(store_background);
     passive = 0;
     printed_node = temp_head;
     pass_number = 0;
-    font_in_short_display = 0;
-
+    font_in_short_display = null_font;
     cur_p = link(temp_head);
     auto_breaking = true;
     prev_p = cur_p;
@@ -478,7 +472,7 @@ void line_break_ (integer final_widow_penalty)
         while (!(!is_char_node(cur_p)));
       }
 
-      switch(type(cur_p))
+      switch (type(cur_p))
       {
         case hlist_node:
         case vlist_node:
@@ -490,8 +484,8 @@ void line_break_ (integer final_widow_penalty)
           if (subtype(cur_p) == language_node)
           {
             cur_lang = what_lang(cur_p);
-            lhyf = what_lhm(cur_p);
-            rhyf = what_rhm(cur_p);
+            l_hyf = what_lhm(cur_p);
+            r_hyf = what_rhm(cur_p);
           }
           break;
 
@@ -501,7 +495,7 @@ void line_break_ (integer final_widow_penalty)
             {
               if (is_char_node(prev_p))
                 try_break(0, unhyphenated);
-              else if ((mem[prev_p].hh.b0 < 9))
+              else if (precedes_break(prev_p))
                 try_break(0, unhyphenated);
               else if ((type(prev_p) == kern_node) && (subtype(prev_p) != explicit))
                 try_break(0, unhyphenated);
@@ -515,8 +509,8 @@ void line_break_ (integer final_widow_penalty)
 
             if (second_pass && auto_breaking)
             {
-              prevs = cur_p;
-              s = link(prevs);
+              prev_s = cur_p;
+              s = link(prev_s);
 
               if (s != 0)
               {
@@ -529,7 +523,7 @@ void line_break_ (integer final_widow_penalty)
                   }
                   else if (type(s) == ligature_node)
                     if (lig_ptr(s) == 0)
-                      goto lab22;
+                      goto continu;
                     else
                     {
                       q = lig_ptr(s);
@@ -537,42 +531,42 @@ void line_break_ (integer final_widow_penalty)
                       hf = font(q);
                     }
                   else if ((type(s) == kern_node) && (subtype(s) == normal))
-                    goto lab22;
+                    goto continu;
                   else if (type(s) == whatsit_node)
                   {
                     if (subtype(s) == language_node)
                     {
                       cur_lang = what_lang(s);
-                      lhyf = what_lhm(s);
-                      rhyf = what_rhm(s);
+                      l_hyf = what_lhm(s);
+                      r_hyf = what_rhm(s);
                     }
-                    goto lab22;
+                    goto continu;
                   }
                   else
-                    goto lab31;
+                    goto done1;
 
                   if (lc_code(c) != 0)
-                    if ((lc_code(c) == (halfword) c) || (uc_hyph > 0)) /* fixed signed tyoe */
-                      goto lab32;
+                    if ((lc_code(c) == (halfword) c) || (uc_hyph > 0))
+                      goto done2;
                     else
-                      goto lab31;
-lab22:
-                  prevs = s;
-                  s = link(prevs);
+                      goto done1;
+continu:
+                  prev_s = s;
+                  s = link(prev_s);
                 }
-lab32:
+done2:
                 hyf_char = hyphen_char[hf];
 
                 if (hyf_char < 0)
-                  goto lab31; 
+                  goto done1; 
 
                 if (hyf_char > 255)
-                  goto lab31; /* ? */
+                  goto done1; /* ? */
 
-                ha = prevs;
+                ha = prev_s;
 
-                if (lhyf + rhyf > 63)
-                  goto lab31;
+                if (l_hyf + r_hyf > 63)
+                  goto done1;
 
                 hn = 0;
 
@@ -581,44 +575,44 @@ lab32:
                   if (is_char_node(s))
                   {
                     if (font(s) != hf)
-                      goto lab33;
+                      goto done3;
 
-                    hyfbchar = character(s);
+                    hyf_bchar = character(s);
 
-                    c = hyfbchar;     /*  unsigned char c;  */
+                    c = hyf_bchar;
 
                     if (lc_code(c) == 0)
-                      goto lab33;
+                      goto done3;
 
                     if (hn == 63)
-                      goto lab33;
+                      goto done3;
 
                     hb = s;
                     incr(hn);
                     hu[hn] = c;
                     hc[hn]= lc_code(c);
-                    hyfbchar = non_char;
+                    hyf_bchar = non_char;
                   }
                   else if (type(s) == ligature_node)
                   {
                     if (font(lig_char(s)) != hf)
-                      goto lab33;
+                      goto done3;
 
                     j = hn;
                     q = lig_ptr(s);
 
                     if (q != 0) /* 94/Mar/23 BUG FIX */
-                      hyfbchar = character(q);
+                      hyf_bchar = character(q);
 
                     while (q != 0) /* 94/Mar/23 BUG FIX */
                     {
                       c = character(q);
 
                       if (lc_code(c) == 0)
-                        goto lab33;
+                        goto done3;
 
                       if (j == 63)
-                        goto lab33;
+                        goto done3;
 
                       incr(j);
                       hu[j] = c;
@@ -630,68 +624,74 @@ lab32:
                     hn = j;
 
                     if (odd(subtype(s)))
-                      hyfbchar = font_bchar[hf];
+                      hyf_bchar = font_bchar[hf];
                     else
-                      hyfbchar = non_char;
+                      hyf_bchar = non_char;
                   }
                   else if ((type(s) == kern_node) && (subtype(s) == normal))
                   {
                     hb = s;
-                    hyfbchar = font_bchar[hf];
+                    hyf_bchar = font_bchar[hf];
                   }
                   else
-                    goto lab33;
+                    goto done3;
 
                   s = link(s);
                 }
-lab33:;
-                if (hn < lhyf + rhyf)
-                  goto lab31;
+done3:
+                if (hn < l_hyf + r_hyf)
+                  goto done1;
 
                 while (true)
                 {
                   if (!(is_char_node(s)))
-                    switch(type(s))
+                    switch (type(s))
                     {
                       case ligature_node:
                         break;
+    
                       case kern_node:
                         if (subtype(s) != normal)
-                          goto lab34;
+                          goto done4;
                         break;
+
                       case whatsit_node:
                       case glue_node:
                       case penalty_node:
                       case ins_node:
                       case adjust_node:
                       case mark_node:
-                        goto lab34;
+                        goto done4;
                         break;
+
                       default:
-                        goto lab31;
+                        goto done1;
                         break;
                     }
                   s = link(s);
                 }
-lab34:;
+done4:
                 hyphenate();
               }
-lab31:;
+done1:;
             }
           }
           break;
+
         case kern_node:
           if (subtype(cur_p) == explicit)
             kern_break();
           else
             act_width = act_width + width(cur_p);
           break;
+
         case ligature_node:
           {
             f = font(lig_char(cur_p));
             act_width = act_width + char_width(f, char_info(f, character(lig_char(cur_p))));
           }
           break;
+
         case disc_node:
           {
             s = pre_break(cur_p);
@@ -708,24 +708,26 @@ lab31:;
                   f = font(s);
                   disc_width = disc_width + char_width(f, char_info(f, character(s)));
                 }
-                else switch(type(s))
+                else switch (type(s))
                 {
                   case ligature_node:
                     {
                       f = font(lig_char(s));
-                      disc_width = disc_width + font_info[width_base[f] + font_info[char_base[f]+ mem[s + 1].hh.b1].qqqq.b0].cint;
+                      disc_width = disc_width + char_width(f, char_info(f, character(lig_char(s))));
                     }
                     break;
+
                   case hlist_node:
                   case vlist_node:
                   case rule_node:
                   case kern_node:
                     disc_width = disc_width + width(s);
                     break;
+
                   default:
                     {
                       confusion("disc3");
-                      return;       // abort_flag set
+                      return;
                     }
                     break;
                 }
@@ -737,6 +739,7 @@ lab31:;
               try_break(hyphen_penalty, hyphenated);
               act_width = act_width - disc_width;
             }
+
             r = replace_count(cur_p);
             s = link(cur_p);
 
@@ -747,7 +750,7 @@ lab31:;
                 f = font(s);
                 act_width = act_width + char_width(f, char_info(f, character(s)));
               }
-              else switch(type(s))
+              else switch (type(s))
               {
                 case ligature_node:
                   {
@@ -766,7 +769,7 @@ lab31:;
                 default:
                   {
                     confusion("disc4");
-                    return;       // abort_flag set
+                    return;
                   }
                   break;
               }
@@ -777,7 +780,7 @@ lab31:;
 
             prev_p = cur_p;
             cur_p = s;
-            goto lab35;
+            goto done5;
           }
           break;
 
@@ -800,14 +803,14 @@ lab31:;
         default:
           {
             confusion("paragraph");
-            return;       // abort_flag set
+            return;
           }
           break;
       }
 
       prev_p = cur_p;
       cur_p = link(cur_p);
-lab35:;
+done5:;
     }
 
     if (cur_p == 0)
@@ -817,11 +820,11 @@ lab35:;
       if (link(active) != active)
       {
         r = link(active);
-        fewest_demerits = 1073741823L; /* 2^30 - 1 */
+        fewest_demerits = awful_bad;
 
         do
           {
-            if (type(r) != 2)
+            if (type(r) != delta_node)
               if (total_demerits(r) < fewest_demerits)
               {
                 fewest_demerits = total_demerits(r);
@@ -836,7 +839,7 @@ lab35:;
 
         if (looseness == 0)
         {
-          goto lab30;           /* normal exit */
+          goto done; /* normal exit */
         }
 
         {
@@ -872,7 +875,7 @@ lab35:;
 
         if ((actual_looseness == looseness) || final_pass)
         {
-          goto lab30;
+          goto done;
         }
       }
     }
@@ -883,10 +886,10 @@ lab35:;
     {
       cur_p = link(q);
 
-      if (type(q) == 2)
-        free_node(q, 7);
+      if (type(q) == delta_node)
+        free_node(q, delta_node_size);
       else
-        free_node(q, 3);
+        free_node(q, active_node_size);
 
       q = cur_p;
     }
@@ -896,11 +899,11 @@ lab35:;
     while (q != 0)
     {
       cur_p = link(q);
-      free_node(q, 2);
+      free_node(q, passive_node_size);
       q = cur_p;
     }
 
-    if (! second_pass)
+    if (!second_pass)
     {
 #ifdef STAT
       if (tracing_paragraphs > 0)
@@ -908,7 +911,7 @@ lab35:;
 #endif
       threshold = tolerance;
       second_pass = true;
-      second_pass_count++;          /* 96 Feb 9 */
+      second_pass_count++;
       final_pass = (emergency_stretch <= 0);
     }
     else
@@ -920,12 +923,12 @@ lab35:;
 
       background[2] = background[2] + emergency_stretch;
       final_pass = true;
-      ++final_pass_count;         /* 96 Feb 9 */
+      ++final_pass_count;
     }
   }
 
-lab30:
-  if (best_line == 2)
+done:
+  if (best_line == decent_fit)
     single_line++;
 
 #ifdef STAT
@@ -943,10 +946,10 @@ lab30:
   {
     cur_p = link(q);
 
-    if (type(q) == 2)
-      free_node(q, 7);
+    if (type(q) == delta_node)
+      free_node(q, delta_node_size);
     else
-      free_node(q, 3);
+      free_node(q, active_node_size);
 
     q = cur_p;
   }
@@ -956,7 +959,7 @@ lab30:
   while (q != 0)
   {
     cur_p = link(q);
-    free_node(q, 2);
+    free_node(q, passive_node_size);
     q = cur_p;
   }
 
@@ -1001,9 +1004,9 @@ void prefixed_command (void)
   {
     print_err("You can't use `");
     print_esc("long");
-    print_string("' or `");
+    prints("' or `");
     print_esc("outer");
-    print_string("' with `");
+    prints("' with `");
     print_cmd_chr(cur_cmd, cur_chr); 
     print_char('\'');
     help1("I'll pretend you didn't say \\long or \\outer here.");
@@ -1197,7 +1200,7 @@ void prefixed_command (void)
               add_token_ref(q);
               define(p, call, q);
             }
-            goto lab30;
+            goto done;
           }
         }
 
@@ -1288,9 +1291,9 @@ void prefixed_command (void)
           print_int(cur_val);
 
           if (p < del_code_base)
-            print_string("), should be in the range 0..");
+            prints("), should be in the range 0..");
           else
-            print_string("), should be at most ");
+            prints("), should be at most ");
 
           print_int(n);
           help1("I'm going to use 0 instead of that illegal code value.");
@@ -1402,7 +1405,7 @@ void prefixed_command (void)
         if (is_initex)
         {
           new_patterns();
-          goto lab30;
+          goto done;
         }
 #endif
         print_err("Patterns can be loaded only by INITEX");
@@ -1420,7 +1423,7 @@ void prefixed_command (void)
       else
       {
         new_hyph_exceptions();
-        goto lab30;
+        goto done;
       }
       break;
 
@@ -1460,12 +1463,12 @@ void prefixed_command (void)
     default:
       {
         confusion("prefix");
-        return;       // abort_flag set
+        return;
       }
       break;
   }
 
-lab30:
+done:
   if (after_token != 0)
   {
     cur_tok = after_token;
@@ -1483,40 +1486,40 @@ boolean load_fmt_file (void)
   undump_int(x);
 
   if (x != BEGINFMTCHECKSUM)
-    goto lab_bad_fmt;
+    goto bad_fmt;
 
   undump_int(x); /* mem_bot */
 
   if (x != mem_bot)
-    goto lab_bad_fmt;
+    goto bad_fmt;
 
   undump_int(x); /* mem_top */
 
 #ifdef ALLOCATEMAIN
 /* we already read this once earlier to grab mem_top */
   if (trace_flag)
-    printf("Read from fmt file mem_top = %d TeX words\n", x);
+    printf("Read from fmt file mem_top = %lld TeX words\n", x);
 
   mem = allocate_main_memory(x); /* allocate main memory at this point */
 
   if (mem == NULL)
-    exit(1);                     /* redundant sanity test ! */
+    exit(EXIT_FAILURE);
 
-  initialize_aux();              /* do `mem' part of initialize */
+  initialize_aux(); /* do `mem' part of initialize */
 #endif
 
   if (x != mem_top)
-    goto lab_bad_fmt;
+    goto bad_fmt;
 
   undump_int(x); /* eqtb_size */
 
   if (x != eqtb_size)
-    goto lab_bad_fmt;
+    goto bad_fmt;
 
   undump_int(x); /* hash_prime */
 
   if (x != hash_prime)
-    goto lab_bad_fmt;
+    goto bad_fmt;
 
   undump_int(x); /* hyphen_prime */
 
@@ -1527,19 +1530,19 @@ boolean load_fmt_file (void)
 #endif
 
   if (x != hyphen_prime)
-    goto lab_bad_fmt;
+    goto bad_fmt;
 
   {
     undump_int(x); /* pool_size */
 
     if (x < 0)
-      goto lab_bad_fmt; 
+      goto bad_fmt; 
 
 #ifdef ALLOCATESTRING
     if (x > current_pool_size)
     {
       if (trace_flag)
-        printf("undump string pool reallocation (%d > %d)\n", x, current_pool_size);
+        printf("undump string pool reallocation (%lld > %d)\n", x, current_pool_size);
 
       str_pool = realloc_str_pool (x - current_pool_size + increment_pool_size);
     }
@@ -1549,8 +1552,8 @@ boolean load_fmt_file (void)
     if (x > pool_size)
 #endif
     {
-      printf("%s%s\n",  "---! Must increase the ", "string pool size");
-      goto lab_bad_fmt;
+      printf("%s%s\n", "---! Must increase the ", "string pool size");
+      goto bad_fmt;
     }
     else
       pool_ptr = x;
@@ -1560,33 +1563,33 @@ boolean load_fmt_file (void)
     undump_int(x);  /* max_strings */
 
     if (x < 0)
-      goto lab_bad_fmt;
+      goto bad_fmt;
 
 #ifdef ALLOCATESTRING
     if (x > current_max_strings)
     {
       if (trace_flag)
-        printf("undump string pointer reallocation (%d > %d)\n", x, current_max_strings);
+        printf("undump string pointer reallocation (%lld > %d)\n", x, current_max_strings);
 
       str_start = realloc_str_start(x - current_max_strings + increment_max_strings);
     }
 
-    if (x > current_max_strings) /* 94/Jan/24 */
+    if (x > current_max_strings)
 #else
     if (x > max_strings)
 #endif
     {
-      printf("%s%s\n",  "---! Must increase the ", "max strings");
-      goto lab_bad_fmt;
+      printf("%s%s\n", "---! Must increase the ", "max strings");
+      goto bad_fmt;
     }
     else
       str_ptr = x;
   }
 
-  if (undumpthings(str_start[0], str_ptr + 1)) /* undump string ptrs */
+  if (undumpthings(str_start[0], str_ptr + 1))
     return -1;
 
-  if (undumpthings(str_pool[0], pool_ptr)) /*  undump string pool */
+  if (undumpthings(str_pool[0], pool_ptr))
     return -1;
 
   init_str_ptr = str_ptr;
@@ -1604,7 +1607,7 @@ boolean load_fmt_file (void)
       p = q + node_size(q);
 
       if ((p > lo_mem_max) || ((q >= rlink(q)) && (rlink(q) != rover)))
-        goto lab_bad_fmt;
+        goto bad_fmt;
 
       q = rlink(q);
     }
@@ -1617,7 +1620,7 @@ boolean load_fmt_file (void)
   {
 /*  or call add_variable_space(mem_bot - (mem_min + 1)) */
     if (trace_flag)
-      puts("Splicing in mem_min space in undump!\n");
+      puts("Splicing in mem_min space in undump!");
 
     p = llink(rover);
     q = mem_min + 1;
@@ -1648,7 +1651,7 @@ boolean load_fmt_file (void)
       undump_int(x);
 
       if ((x < 1) || (k + x > (eqtb_size + 1)))
-        goto lab_bad_fmt;
+        goto bad_fmt;
 
       if (undumpthings(eqtb[k], x))
         return -1;
@@ -1657,7 +1660,7 @@ boolean load_fmt_file (void)
       undump_int(x);
 
       if ((x < 0) || (k + x > (eqtb_size + 1)))
-        goto lab_bad_fmt;
+        goto bad_fmt;
 
       for (j = k; j <= k + x - 1; j++)
         eqtb[j] = eqtb[k - 1];
@@ -1686,22 +1689,22 @@ boolean load_fmt_file (void)
   undump_int(cs_count);
 
   if (trace_flag)
-    printf("itex undump cs_count %d ", cs_count);
+    printf("itex undump cs_count %lld ", cs_count);
 
   {
     undump_int(x); /* font_mem_size */
 
     if (x < 7)
-      goto lab_bad_fmt;
+      goto bad_fmt;
 
 #ifdef ALLOCATEFONT
     if (trace_flag)
-      printf("Read from fmt fmem_ptr = %d\n", x);
+      printf("Read from fmt fmem_ptr = %lld\n", x);
 
     if (x > current_font_mem_size)
     {
       if (trace_flag)
-        printf("Undump realloc font_info (%d > %d)\n", x, current_font_mem_size);
+        printf("Undump realloc font_info (%lld > %d)\n", x, current_font_mem_size);
 
       font_info = realloc_font_info (x - current_font_mem_size + increment_font_mem_size);
     }
@@ -1711,8 +1714,8 @@ boolean load_fmt_file (void)
     if (x > font_mem_size)
 #endif
     {
-      puts("---! Must increase the font mem size\n");
-      goto lab_bad_fmt;
+      puts("---! Must increase the font mem size");
+      goto bad_fmt;
     }
     else
       fmem_ptr = x;
@@ -1726,12 +1729,12 @@ boolean load_fmt_file (void)
       undump_int(x); /* font_max */
 
       if (x < 0)
-        goto lab_bad_fmt;
+        goto bad_fmt;
 
       if (x > font_max)
       {
-        puts("---! Must increase the font max\n"); 
-        goto lab_bad_fmt;
+        puts("---! Must increase the font max"); 
+        goto bad_fmt;
       }
       else
         font_ptr = x;
@@ -1867,7 +1870,7 @@ boolean load_fmt_file (void)
     undump_int(x);
 
     if (x < 0)
-      goto lab_bad_fmt;
+      goto bad_fmt;
 
 #ifdef ALLOCATETRIES
     if (!is_initex)
@@ -1879,8 +1882,8 @@ boolean load_fmt_file (void)
 
     if (x > trie_size)
     {
-      puts("---! Must increase the trie size\n");
-      goto lab_bad_fmt;
+      puts("---! Must increase the trie size");
+      goto bad_fmt;
     }
     else
       j = x;
@@ -1904,12 +1907,12 @@ boolean load_fmt_file (void)
     undump_int(x);
 
     if (x < 0)
-      goto lab_bad_fmt;
+      goto bad_fmt;
 
     if (x > trie_op_size)
     {
       puts("---! Must increase the trie op size\n");
-      goto lab_bad_fmt;
+      goto bad_fmt;
     }
     else
       j = x;
@@ -1963,12 +1966,12 @@ boolean load_fmt_file (void)
   undump_int(x);
   
   if ((x != ENDFMTCHECKSUM) || feof(fmt_file))
-    goto lab_bad_fmt;
+    goto bad_fmt;
 
   return true;
 
-lab_bad_fmt:;
-  puts("(Fatal format file error; I'm stymied)\n");
+bad_fmt:
+  puts("(Fatal format file error; I'm stymied)");
 
   return false;
 }
@@ -1984,17 +1987,15 @@ void final_cleanup (void)
 
   while (input_ptr > 0)
   {
-    if (state == 0)
-    {
+    if (state == token_list)
       end_token_list();
-    }
     else
       end_file_reading();
   }
 
   while (open_parens > 0)
   {
-    print_string(" )");
+    prints(" )");
     decr(open_parens);
   }
 
@@ -2002,7 +2003,7 @@ void final_cleanup (void)
   {
     print_nl("(");
     print_esc("end occurred ");
-    print_string("inside a group at level ");
+    prints("inside a group at level ");
     print_int(cur_level - 1);
     print_char(')');
   }
@@ -2011,21 +2012,21 @@ void final_cleanup (void)
   {
     print_nl("(");
     print_esc("end occurred ");
-    print_string("when ");
+    prints("when ");
     print_cmd_chr('i', cur_if);
 
     if (if_line != 0)
     {
-      print_string("on line ");
+      prints("on line ");
       print_int(if_line);
     }
 
-    print_string(" was incomplete)");
+    prints(" was incomplete)");
     if_line = mem[cond_ptr + 1].cint;
-    cur_if = mem[cond_ptr].hh.b1;
+    cur_if = subtype(cond_ptr);
     temp_ptr = cond_ptr;
-    cond_ptr = mem[cond_ptr].hh.rh;
-    free_node(temp_ptr, 2);
+    cond_ptr = link(cond_ptr);
+    free_node(temp_ptr, if_node_size);
   }
 
   if (history != spotless)
@@ -2050,7 +2051,8 @@ void final_cleanup (void)
 
       if (last_glue != max_halfword)
         delete_glue_ref(last_glue);
-      store_fmt_file(); // returns a value ?
+
+      store_fmt_file();
     }
 #endif
 
@@ -2064,7 +2066,7 @@ void show_frozen (void)
   int i, j, n;
 
   fprintf(log_file, "\n");
-  fprintf(log_file, "(%d fonts frozen in format file:\n", font_ptr);
+  fprintf(log_file, "(%lld fonts frozen in format file:\n", font_ptr);
 
   for (i = 1; i <= font_ptr; i++)
   {
@@ -2090,7 +2092,7 @@ int main_program (void)
   history = fatal_error_stop;
 
   if (ready_already == 314159L)
-    goto lab1;
+    goto start_of_TEX;
 
   bad = 0;
 
@@ -2145,7 +2147,7 @@ int main_program (void)
     bad = 15;
 
 #ifdef INCREASEFONTS
-  if (font_max > 1024)
+  if (font_max > 65535)
 #else
   if (font_max > 256)
 #endif
@@ -2174,7 +2176,7 @@ int main_program (void)
     printf("%s%s%ld\n", "Ouch---my internal constants have been clobbered!",
         "---case ", (long) bad);
 
-    goto lab9999;
+    goto final_end;
   }
 
   initialize();
@@ -2183,7 +2185,7 @@ int main_program (void)
   if (is_initex)
   {
     if (!get_strings_started())
-      goto lab9999;
+      goto final_end;
 
     init_prim();
     init_str_ptr = str_ptr;
@@ -2194,32 +2196,40 @@ int main_program (void)
 
   ready_already = 314159L;
 
-lab1:
+start_of_TEX:
   selector = term_only;
   tally = 0;
   term_offset = 0;
   file_offset = 0;
-  show_line(tex_version, 0);
 
+  {
+    char dist_ver[256];
 #ifdef _WIN32
   #ifdef _WIN64
-    printf(log_line, " (%s %s/Windows 64bit)", application, yandyversion);
+    sprintf(dist_ver, "%s (%s %s/Win64)", tex_version, application, yandyversion);
   #else
-    printf(log_line, " (%s %s/Windows 32bit)", application, yandyversion);
+    sprintf(dist_ver, "%s (%s %s/Win32)", tex_version, application, yandyversion);
   #endif
 #else
-    printf(log_line, " (%s %s/Linux)", application, yandyversion);
+    sprintf(dist_ver, "%s (%s %s/Linux)", tex_version, application, yandyversion);
 #endif
+    prints(dist_ver);
+  }
 
-  if (format_ident > 0)
+  if (format_ident == 0)
+  {
+    prints(" (preloaded format=");
+    prints(format_name);
+    prints(")");
+    print_ln();
+  }
+  else
+  {
     slow_print(format_ident);
+    print_ln();
+  }
 
-  print_ln();
-
-#ifndef _WINDOWS
-  fflush(stdout);
-#endif
-
+  update_terminal();
   job_name = 0;
   name_in_progress = false;
   log_opened = false;
@@ -2251,35 +2261,33 @@ lab1:
       start = 1;
       index = 0;
       line = 0;
-      cur_input.name_field = 0;
+      name = 0;
       force_eof = false;
       align_state = 1000000L;
 
       if (!init_terminal())
-        goto lab9999;
+        goto final_end;
 
       limit = last;
       first = last + 1;
     }
     
-    if ((format_ident == 0) ||
-        (buffer[loc] == '&') ||
-        (buffer[loc] == '+'))
+    if ((format_ident == 0) || (buffer[loc] == '&') || (buffer[loc] == '+'))
     {
       if (format_ident != 0)
         initialize();
 
-      if (!open_fmt_file ())
-        goto lab9999;
+      if (!open_fmt_file())
+        goto final_end;
 
-      if (!load_fmt_file ())
+      if (!load_fmt_file())
       {
 #ifdef COMPACTFORMAT
         gzclose(gz_fmt_file);
 #else
         w_close(fmt_file);
 #endif
-        goto lab9999;
+        goto final_end;
       }
 
 #ifdef COMPACTFORMAT
@@ -2288,8 +2296,7 @@ lab1:
       w_close(fmt_file);
 #endif
 
-      while ((loc < limit) &&
-          (buffer[loc] == ' '))
+      while ((loc < limit) && (buffer[loc] == ' '))
         incr(loc);
     }
 
@@ -2306,8 +2313,7 @@ lab1:
     else
       selector = term_only;
 
-    if ((loc < limit) &&
-      (cat_code(buffer[loc]) != escape))
+    if ((loc < limit) && (cat_code(buffer[loc]) != escape))
       start_input();
   }
 
@@ -2328,7 +2334,7 @@ lab1:
   final_cleanup();
   close_files_and_terminate();
 
-lab9999:
+final_end:
   {
     int code;
 
@@ -2338,7 +2344,7 @@ lab9999:
 
     ready_already = 0;
 
-    if ((history != 0) && (history != 1))
+    if ((history != spotless) && (history != warning_issued))
       code = 1;
     else
       code = 0;
@@ -2348,7 +2354,7 @@ lab9999:
 }
 
 #ifdef ALLOCATEMAIN
-/* add a block of variable size node space below mem_bot */
+/* add a block of variable size node space below mem_bot(0) */
 void add_variable_space(int size)
 {
   halfword p;
@@ -2362,10 +2368,10 @@ void add_variable_space(int size)
 
   mem_min = t - (size + 1);     /* first word in new block - 1 */
 
-  if (mem_min < mem_start)      /* sanity test */
+  if (mem_min < mem_start)
   {
     if (trace_flag)
-      puts("WARNING: mem_min < mem_start!\n");
+      puts("WARNING: mem_min < mem_start!");
 
     mem_min = mem_start;
   }
@@ -2384,15 +2390,13 @@ void add_variable_space(int size)
 }
 #endif
 
-/**************************************************************************/
-
 #ifdef INITEX
 /* split out to allow sharing of code from do_initex and newpattern */
 void reset_trie (void)
 {
   integer k;
 
-  for (k = - (integer) trie_op_size; k <= trie_op_size; k++)
+  for (k = -(integer)trie_op_size; k <= trie_op_size; k++)
     trie_op_hash[k] = 0;
 
   for (k = 0; k <= 255; k++)
@@ -2407,7 +2411,7 @@ void reset_trie (void)
   trie_not_ready = true;
 }
 /* borrowed code from initialize() */
-void reset_hyphen (void)
+void reset_hyphen(void)
 {
   hyph_pointer z;
 
@@ -2422,9 +2426,9 @@ void reset_hyphen (void)
 /* split out to allow optimize for space, not time */
 void do_initex (void)
 {
-/*  integer i; */
+  /* integer i; */
   integer k;
-/*  hyph_pointer z; */
+  /* hyph_pointer z; */
 
   for (k = mem_bot + 1; k <= lo_mem_stat_max; k++)
     mem[k].cint = 0;
@@ -2439,15 +2443,15 @@ void do_initex (void)
     k = k + glue_spec_size;
   }
 
-  stretch(fil_glue) = 65535L;
+  stretch(fil_glue) = unity;
   stretch_order(fil_glue) = fil;
-  stretch(fill_glue) = 65535L;
+  stretch(fill_glue) = unity;
   stretch_order(fill_glue) = fill;
-  stretch(ss_glue) = 65535L;
+  stretch(ss_glue) = unity;
   stretch_order(ss_glue) = fil;
-  shrink(ss_glue) = 65535L;
+  shrink(ss_glue) = unity;
   shrink_order(ss_glue) = fil;
-  stretch(fil_neg_glue) = -65536L;
+  stretch(fil_neg_glue) = -unity;
   stretch_order(fil_neg_glue) = fil;
   rover = lo_mem_stat_max + 1;
   link(rover) = empty_flag;
@@ -2472,7 +2476,7 @@ void do_initex (void)
   link(mem_top) = page_ins_head;
   type(page_head) = glue_node;
   subtype(page_head) = normal;
-  avail = 0;                   /* avail <- null p.164 */
+  avail = 0;
   mem_end = mem_top;
   hi_mem_min = hi_mem_stat_min;
   var_used = lo_mem_stat_max + 1 - mem_bot;
@@ -2608,8 +2612,8 @@ void do_initex (void)
 
   reset_trie();
   text(frozen_protection) = 1184; /* "inaccessible" */
-  format_ident = 1251;
-  text(end_write) = 1290;
+  format_ident = 1251;            /* " (INITEX)" */
+  text(end_write) = 1290;         /* "endwrite" */
   eq_level(end_write) = level_one;
   eq_type(end_write) = outer_call;
   equiv(end_write) = 0;
@@ -2629,21 +2633,20 @@ boolean get_strings_started (void)
 
   for (k = 0; k <= 255; k++)
   {
-    if (((k < ' ') || (k > '~')))
+    if ( (k < ' ') || (k > '~') )
     {
       append_char('^');
       append_char('^');
 
       if (k < 64)
         append_char(k + 64);
+      else if (k < 128)
+        append_char(k - 64);
       else
-        if (k < 128)
-          append_char(k - 64);
-        else
-        {
-          append_lc_hex(k / 16);
-          append_lc_hex(k % 16);
-        }
+      {
+        append_lc_hex(k / 16);
+        append_lc_hex(k % 16);
+      }
     }
     else
       append_char(k);
@@ -2655,13 +2658,13 @@ boolean get_strings_started (void)
 
   if (g == 0)
   {
-    fprintf(stdout , "%s\n",  "! You have to increase POOLSIZE." );
+    fprintf(stdout, "%s\n", "! You have to increase POOLSIZE." );
     return false;
   }
 
   return true;
 }
-#endif /* INITEX */
+#endif
 
 #ifdef INITEX
 /* sec 0131 */
@@ -2670,7 +2673,7 @@ void sort_avail (void)
   pointer p, q, r;
   pointer old_rover;
 
-  p = get_node(1073741824L); /* 2^30 merge adjacent free nodes */
+  p = get_node(010000000000);
   p = rlink(rover);
   rlink(rover) = empty_flag;
   old_rover = rover;
@@ -2717,8 +2720,8 @@ void primitive_ (str_number s, quarterword c, halfword o)
 { 
   pool_pointer k;
   small_number j;
-/*  small_number l;  */
-  int l; /* 95/Jan/7 */
+  /* small_number l; */
+  int l;
 
   if (s < 256)
     cur_val = s + single_base;
@@ -2732,12 +2735,6 @@ void primitive_ (str_number s, quarterword c, halfword o)
 
     cur_val = id_lookup(0, l);
     flush_string();
-
-#ifdef SHORTHASH
-    if (s > 65535L)
-      puts("ERROR: hash entry too large\n");
-#endif
-
     text(cur_val) = s;
   }
 
@@ -2766,7 +2763,7 @@ trie_op_code new_trie_op_ (small_number d, small_number n, trie_op_code v)
       if (trie_op_ptr == trie_op_size)
       {
         overflow("pattern memory ops", trie_op_size);
-        return 0;     // abort_flag set
+        return 0;
       }
 
       u = trie_used[cur_lang];
@@ -2774,7 +2771,7 @@ trie_op_code new_trie_op_ (small_number d, small_number n, trie_op_code v)
       if (u == max_trie_op)
       {
         overflow("pattern memory ops per language", max_trie_op - min_trie_op);
-        return 0;     // abort_flag set
+        return 0;
       }
 
       incr(trie_op_ptr);
@@ -2870,8 +2867,7 @@ void first_fit_ (trie_pointer p)
       if (trie_size <= h + 256)
       {
         overflow("pattern memory", trie_size);
-/*      not dynamic ---- but can be set -h=... from command line in ini-TeX */
-        return;     // abort_flag set
+        return;
       }
 
       do
@@ -2885,24 +2881,26 @@ void first_fit_ (trie_pointer p)
     }
 
     if (trie_taken[h])
-      goto lab45;
+      goto not_found;
 
     q = trie_r[p];
 
     while (q > 0)
     {
       if (trie_trl[h + trie_c[q]] == 0)
-        goto lab45;
+        goto not_found;
 
       q = trie_r[q];
     }
 
-    goto lab40;
-lab45:
+    goto found;
+
+not_found:
     z = trie_trl[z];
   }
-lab40:
-  trie_taken[h] = true; /* h may be used without ... */
+
+found:
+  trie_taken[h] = true;
   trie_hash[p] = h;
   q = p;
 
@@ -2980,30 +2978,27 @@ void trie_fix_ (trie_pointer p)
 /* sec 0960 */
 void new_patterns (void)
 {
-/* ******************************************************************* */
-/*  was small_number k, l;  in 3.141 */
   char k, l;
-/* ******************************************************************* */
-  boolean digitsensed;
+  boolean digit_sensed;
   trie_op_code v;
   trie_pointer p, q;
-  boolean firstchild;
-/*  ASCII_code c;  */
-  int c;                /* 95/Jan/7 */
+  boolean first_child;
+  /* ASCII_code c; */
+  int c;
 
   if (!trie_not_ready) /* new stuff */
   {
     if (allow_patterns)
     {
       if (trace_flag)
-        puts("Resetting patterns\n");
+        puts("Resetting patterns");
 
       reset_trie();         /* RESET PATTERNS -  93/Nov/26 */
 
       if (reset_exceptions)
       {
         if (trace_flag)
-          puts("Resetting exceptions\n");
+          puts("Resetting exceptions");
 
         reset_hyphen();     /* RESET HYPHENEXCEPTIONS -  93/Nov/26 */
       }
@@ -3016,7 +3011,7 @@ void new_patterns (void)
     scan_left_brace();
     k = 0;
     hyf[0] = 0;
-    digitsensed = false;
+    digit_sensed = false;
 
     while (true)
     {
@@ -3026,7 +3021,7 @@ void new_patterns (void)
       {
         case letter:
         case other_char:
-          if (digitsensed || (cur_chr < '0') || (cur_chr > '9'))
+          if (digit_sensed || (cur_chr < '0') || (cur_chr > '9'))
           {
             if (cur_chr == '.')
               cur_chr = 0;
@@ -3047,13 +3042,13 @@ void new_patterns (void)
               incr(k);
               hc[k] = cur_chr;
               hyf[k] = 0;
-              digitsensed = false;
+              digit_sensed = false;
             }
           }
           else if (k < 63)
           {
             hyf[k] = cur_chr - '0';
-            digitsensed = true;
+            digit_sensed = true;
           }
           break;
         case spacer:
@@ -3077,9 +3072,9 @@ void new_patterns (void)
                 if (l > 0)
                   decr(l);
                 else
-                  goto lab31;
+                  goto done1;
               }
-lab31:
+done1:
               q = 0;
               hc[0] = cur_lang;
 
@@ -3087,21 +3082,20 @@ lab31:
                 c = hc[l];
                 incr(l);
                 p = trie_l[q];
-                firstchild = true;
+                first_child = true;
 
                 while ((p > 0) && (c > trie_c[p])) {
                   q = p;
                   p = trie_r[q];
-                  firstchild = false;
+                  first_child = false;
                 }
 
                 if ((p == 0) || (c < trie_c[p]))
                 {
                   if (trie_ptr == trie_size)
                   {
-                    overflow("pattern memory", trie_size);  /* pattern memory - NOT DYNAMIC */
-/*      not dynamic ---- but can be set -h=... from command line in ini-TeX */
-                    return;     // abort_flag set
+                    overflow("pattern memory", trie_size);
+                    return;
                   }
 
                   incr(trie_ptr);
@@ -3109,7 +3103,7 @@ lab31:
                   p = trie_ptr;
                   trie_l[p] = 0;
 
-                  if (firstchild)
+                  if (first_child)
                     trie_l[q]= p;
                   else
                     trie_r[q]= p;
@@ -3117,6 +3111,7 @@ lab31:
                   trie_c[p] = c;
                   trie_o[p] = min_trie_op;
                 }
+
                 q = p;
               }
 
@@ -3131,11 +3126,11 @@ lab31:
             }
 
             if (cur_cmd == right_brace)
-              goto lab30;
+              goto done;
 
             k = 0;
             hyf[0] = 0;
-            digitsensed = false;
+            digit_sensed = false;
           }
           break;
         default:
@@ -3148,7 +3143,7 @@ lab31:
           break;
       }
     }
-lab30:;
+done:;
   }
   else
   {
@@ -3164,9 +3159,9 @@ lab30:;
 void init_trie (void)
 {
   trie_pointer p;
-/*  integer j, k, t;  */
+  /* integer j, k, t; */
   integer j, k;
-  int t;                  /* 95/Jan/7 */
+  int t;
   trie_pointer r, s;
 
   op_start[0] = - (integer) min_trie_op;
@@ -3258,7 +3253,7 @@ void init_trie (void)
   trie_trc[0] = 63;
   trie_not_ready = false;
 }
-#endif /* INITEX */
+#endif
 
 #ifdef INITEX
 /* sec 1302 */
@@ -3270,12 +3265,11 @@ void store_fmt_file (void)
 
   if (!is_initex)
   {
-    puts("! \\dump is performed only by INITEX\n");
+    puts("! \\dump is performed only by INITEX");
 
     if (!knuth_flag)
-      puts("  (Use -i on the command line)\n");
+      puts("  (Use -i on the command line)");
 
-    abort_flag++;
     return;
   }
 
@@ -3287,7 +3281,7 @@ void store_fmt_file (void)
   }
 
   selector = new_string;
-  print_string(" (format=");
+  prints(" (format=");
   print(job_name);
   print_char(' ');
   print_int(year);
@@ -3334,7 +3328,7 @@ void store_fmt_file (void)
 
   print_ln();
   print_int(str_ptr);
-  print_string(" strings of total length ");
+  prints(" strings of total length ");
   print_int(pool_ptr);
 
   sort_avail();
@@ -3376,14 +3370,14 @@ void store_fmt_file (void)
   while (p != 0)
   {
     decr(dyn_used);
-    p = mem[p].hh.rh;
+    p = link(p);
   }
 
   dump_int(var_used);
   dump_int(dyn_used);
   print_ln();
   print_int(x);
-  print_string(" memory locations dumped; current usage is ");
+  prints(" memory locations dumped; current usage is ");
   print_int(var_used);
   print_char('&');
   print_int(dyn_used);
@@ -3399,24 +3393,28 @@ void store_fmt_file (void)
         if ((equiv(j) == equiv(j + 1)) &&
           (eq_type(j) == eq_type(j + 1)) &&
           (eq_level(j) == eq_level(j + 1)))
-          goto lab41;
+          goto found1;
+
         incr(j);
       }
 
       l = (int_base);
-      goto lab31;
-lab41:
+      goto done1;
+
+found1:
       incr(j);
       l = j;
+
       while (j < (int_base - 1))
       {
         if ((equiv(j) != equiv(j + 1)) ||
           (eq_type(j) != eq_type(j + 1)) ||
           (eq_level(j) != eq_level(j + 1)))
-          goto lab31;
+          goto done1;
         incr(j);
       }
-lab31:
+
+done1:
       dump_int(l - k);
 
       if (dumpthings(eqtb[k], l - k))
@@ -3434,23 +3432,27 @@ lab31:
       while (j < (eqtb_size))
       {
         if (eqtb[j].cint == eqtb[j + 1].cint)
-          goto lab42;
+          goto found2;
+
         incr(j);
       }
 
       l = (eqtb_size + 1);
-      goto lab32;
-lab42:
+      goto done2;
+
+found2:
       incr(j);
       l = j;
 
       while (j < (eqtb_size))
       {
         if (eqtb[j].cint != eqtb[j + 1].cint)
-          goto lab32;
+          goto done2;
+
         incr(j);
       }
-lab32:
+
+done2:
       dump_int(l - k);
 
       if (dumpthings(eqtb[k], l - k))
@@ -3468,7 +3470,7 @@ lab32:
   cs_count = frozen_control_sequence - 1 - hash_used;
 
   if (trace_flag)
-    printf("itex cs_count %d hash_size %d hash_extra %d hash_used %d",
+    printf("itex cs_count %lld hash_size %d hash_extra %d hash_used %d",
         cs_count, hash_size, hash_extra, hash_used);
 
   for (p = hash_base; p <= hash_used; p++)
@@ -3490,7 +3492,7 @@ lab32:
   dump_int(cs_count);
   print_ln();
   print_int(cs_count);
-  print_string(" multiletter control sequences");
+  prints(" multiletter control sequences");
 
   dump_int(fmem_ptr);
 
@@ -3579,18 +3581,18 @@ lab32:
 
       if (font_size[k] != font_dsize[k])
       {
-        print_string(" at ");
+        prints(" at ");
         print_scaled(font_size[k]);
-        print_string("pt");
+        prints("pt");
       }
     }
   }
 
   print_ln();
   print_int(fmem_ptr - 7);
-  print_string(" words of font info for ");
+  prints(" words of font info for ");
   print_int(font_ptr - 0);
-  print_string(" preloaded font");
+  prints(" preloaded font");
 
   if (font_ptr != 1)
     print_char('s');
@@ -3609,7 +3611,7 @@ lab32:
 
   print_ln();
   print_int(hyph_count);
-  print_string(" hyphenation exception");
+  prints(" hyphenation exception");
 
   if (hyph_count != 1)
     print_char('s');
@@ -3641,14 +3643,14 @@ lab32:
 
   print_nl("Hyphenation trie of length ");
   print_int(trie_max);
-  print_string(" has ");
+  prints(" has ");
   print_int(trie_op_ptr);
-  print_string(" op");
+  prints(" op");
 
   if (trie_op_ptr != 1)
     print_char('s');
 
-  print_string(" out of ");
+  prints(" out of ");
   print_int(trie_op_size);
 
   for (k = 255; k >= 0; k--)
@@ -3657,7 +3659,7 @@ lab32:
     {
       print_nl("  ");
       print_int(trie_used[k]);
-      print_string(" for language ");
+      prints(" for language ");
       print_int(k);
       dump_int(k);
       dump_int(trie_used[k]);
@@ -3682,6 +3684,7 @@ lab32:
 void init_prim (void)
 {
   no_new_control_sequence = false;
+  /* sec 0266 */
   primitive("lineskip", assign_glue, glue_base + line_skip_code);
   primitive("baselineskip", assign_glue, glue_base + baseline_skip_code);
   primitive("parskip", assign_glue, glue_base + par_skip_code);
@@ -3700,6 +3703,7 @@ void init_prim (void)
   primitive("thinmuskip", assign_mu_glue, glue_base + thin_mu_skip_code);
   primitive("medmuskip", assign_mu_glue, glue_base + med_mu_skip_code);
   primitive("thickmuskip", assign_mu_glue, glue_base + thick_mu_skip_code);
+  /* sec 0230 */
   primitive("output", assign_toks, output_routine_loc);
   primitive("everypar", assign_toks, every_par_loc);
   primitive("everymath", assign_toks, every_math_loc);
@@ -3709,6 +3713,7 @@ void init_prim (void)
   primitive("everyjob", assign_toks, every_job_loc);
   primitive("everycr", assign_toks, every_cr_loc);
   primitive("errhelp", assign_toks, err_help_loc);
+  /* sec 0238 */
   primitive("pretolerance", assign_int, int_base + pretolerance_code);
   primitive("tolerance", assign_int, int_base + tolerance_code);
   primitive("linepenalty", assign_int, int_base + line_penalty_code);
@@ -3764,6 +3769,7 @@ void init_prim (void)
   primitive("righthyphenmin", assign_int, int_base + right_hyphen_min_code);
   primitive("holdinginserts", assign_int, int_base + holding_inserts_code);
   primitive("errorcontextlines", assign_int, int_base + error_context_lines_code);
+  /* sec 0248 */
   primitive("parindent", assign_dimen, dimen_base + par_indent_code);
   primitive("mathsurround", assign_dimen, dimen_base + math_surround_code);
   primitive("lineskiplimit", assign_dimen, dimen_base + line_skip_limit_code);
@@ -3837,63 +3843,63 @@ void init_prim (void)
   par_token = cs_token_flag + par_loc;
   primitive("input", input, 0);
   primitive("endinput", input, 1);
-  primitive("topmark", top_bot_mark, 0);
-  primitive("firstmark", top_bot_mark, 1);
-  primitive("botmark", top_bot_mark, 2);
-  primitive("splitfirstmark", top_bot_mark, 3);
-  primitive("splitbotmark", top_bot_mark, 4);
-  primitive("count", tex_register, 0);
-  primitive("dimen", tex_register, 1);
-  primitive("skip", tex_register, 2);
-  primitive("muskip", tex_register, 3);
-  primitive("spacefactor", set_aux, 102);
-  primitive("prevdepth", set_aux, 1);
+  primitive("topmark", top_bot_mark, top_mark_code);
+  primitive("firstmark", top_bot_mark, first_mark_code);
+  primitive("botmark", top_bot_mark, bot_mark_code);
+  primitive("splitfirstmark", top_bot_mark, split_first_mark_code);
+  primitive("splitbotmark", top_bot_mark, split_bot_mark_code);
+  primitive("count", tex_register, int_val);
+  primitive("dimen", tex_register, dimen_val);
+  primitive("skip", tex_register, glue_val);
+  primitive("muskip", tex_register, mu_val);
+  primitive("spacefactor", set_aux, hmode);
+  primitive("prevdepth", set_aux, vmode);
   primitive("deadcycles", set_page_int, 0);
   primitive("insertpenalties", set_page_int, 1);
-  primitive("wd", set_box_dimen, 1);
-  primitive("ht", set_box_dimen, 3);
-  primitive("dp", set_box_dimen, 2);
-  primitive("lastpenalty", last_item, 0);
-  primitive("lastkern", last_item, 1);
-  primitive("lastskip", last_item, 2);
-  primitive("inputlineno", last_item, 3);
-  primitive("badness", last_item, 4);
-  primitive("number", convert, 0);
-  primitive("romannumeral", convert, 1);
-  primitive("string", convert, 2);
-  primitive("meaning", convert, 3);
-  primitive("fontname", convert, 4);
-  primitive("jobname", convert, 5);
-  primitive("if", if_test, 0);
-  primitive("ifcat", if_test, 1);
-  primitive("ifnum", if_test, 2);
-  primitive("ifdim", if_test, 3);
-  primitive("ifodd", if_test, 4);
-  primitive("ifvmode", if_test, 5);
-  primitive("ifhmode", if_test, 6);
-  primitive("ifmmode", if_test, 7);
-  primitive("ifinner", if_test, 8);
-  primitive("ifvoid", if_test, 9);
-  primitive("ifhbox", if_test, 10);
-  primitive("ifvbox", if_test, 11);
-  primitive("ifx", if_test, 12);
-  primitive("ifeof", if_test, 13);
-  primitive("iftrue", if_test, 14);
-  primitive("iffalse", if_test, 15);
-  primitive("ifcase", if_test, 16);
-  primitive("fi", fi_or_else, 2);
+  primitive("wd", set_box_dimen, width_offset);
+  primitive("ht", set_box_dimen, height_offset);
+  primitive("dp", set_box_dimen, depth_offset);
+  primitive("lastpenalty", last_item, int_val);
+  primitive("lastkern", last_item, dimen_val);
+  primitive("lastskip", last_item, glue_val);
+  primitive("inputlineno", last_item, input_line_no_code);
+  primitive("badness", last_item, badness_code);
+  primitive("number", convert, number_code);
+  primitive("romannumeral", convert, roman_numeral_code);
+  primitive("string", convert, string_code);
+  primitive("meaning", convert, meaning_code);
+  primitive("fontname", convert, font_name_code);
+  primitive("jobname", convert, job_name_code);
+  primitive("if", if_test, if_char_code);
+  primitive("ifcat", if_test, if_cat_code);
+  primitive("ifnum", if_test, if_int_code);
+  primitive("ifdim", if_test, if_dim_code);
+  primitive("ifodd", if_test, if_odd_code);
+  primitive("ifvmode", if_test, if_vmode_code);
+  primitive("ifhmode", if_test, if_hmode_code);
+  primitive("ifmmode", if_test, if_mmode_code);
+  primitive("ifinner", if_test, if_inner_code);
+  primitive("ifvoid", if_test, if_void_code);
+  primitive("ifhbox", if_test, if_hbox_code);
+  primitive("ifvbox", if_test, if_vbox_code);
+  primitive("ifx", if_test, ifx_code);
+  primitive("ifeof", if_test, if_eof_code);
+  primitive("iftrue", if_test, if_true_code);
+  primitive("iffalse", if_test, if_false_code);
+  primitive("ifcase", if_test, if_case_code);
+  primitive("fi", fi_or_else, fi_code);
   text(frozen_fi) = make_string_pool("fi");
   eqtb[frozen_fi] = eqtb[cur_val];
-  primitive("or", fi_or_else, 4);
-  primitive("else", fi_or_else, 3);
-  primitive("nullfont", set_font, 0);
+  primitive("or", fi_or_else, or_code);
+  primitive("else", fi_or_else, else_code);
+  primitive("nullfont", set_font, null_font);
   text(frozen_null_font) = 795;
   eqtb[frozen_null_font] = eqtb[cur_val];
-  primitive("span", tab_mark, 256);
-  primitive("cr", car_ret, 257);
+  primitive("span", tab_mark, span_code);
+  primitive("cr", car_ret, cr_code);
   text(frozen_cr) = make_string_pool("cr");
   eqtb[frozen_cr] = eqtb[cur_val];
-  primitive("crcr", car_ret, 258);
+  primitive("crcr", car_ret, cr_cr_code);
   text(frozen_end_template) = make_string_pool("endtemplate");
   text(frozen_endv) = make_string_pool("endtemplate");
   eq_type(frozen_endv) = endv;
@@ -3911,72 +3917,72 @@ void init_prim (void)
   primitive("pagedepth", set_page_dimen, 7);
   primitive("end", end_match, 0);
   primitive("dump", stop, 1);
-  primitive("hskip", hskip, 4);
-  primitive("hfil", hskip, 0);
-  primitive("hfill", hskip, 1);
-  primitive("hss", hskip, 2);
-  primitive("hfilneg", hskip, 3);
-  primitive("vskip", vskip, 4);
-  primitive("vfil", vskip, 0);
-  primitive("vfill", vskip, 1);
-  primitive("vss", vskip, 2);
-  primitive("vfilneg", vskip, 3);
-  primitive("mskip", mskip, 5);
-  primitive("kern", kern, 1);
-  primitive("mkern", mkern, 99);
+  primitive("hskip", hskip, skip_code);
+  primitive("hfil", hskip, fil_code);
+  primitive("hfill", hskip, fill_code);
+  primitive("hss", hskip, ss_code);
+  primitive("hfilneg", hskip, fil_neg_code);
+  primitive("vskip", vskip, skip_code);
+  primitive("vfil", vskip, fil_code);
+  primitive("vfill", vskip, fill_code);
+  primitive("vss", vskip, ss_code);
+  primitive("vfilneg", vskip, fil_neg_code);
+  primitive("mskip", mskip, mskip_code);
+  primitive("kern", kern, explicit);
+  primitive("mkern", mkern, mu_glue);
   primitive("moveleft", hmove, 1);
   primitive("moveright", hmove, 0);
   primitive("raise", vmove, 1);
   primitive("lower", vmove, 0);
-  primitive("box", make_box, 0);
-  primitive("copy", make_box, 1);
-  primitive("lastbox", make_box, 2);
-  primitive("vsplit", make_box, 3);
-  primitive("vtop", make_box, 4);
-  primitive("vbox", make_box, 5);
-  primitive("hbox", make_box, 106);
-  primitive("shipout", leader_ship, 99);
-  primitive("leaders", leader_ship, 100);
-  primitive("cleaders", leader_ship, 101);
-  primitive("xleaders", leader_ship, 102);
+  primitive("box", make_box, box_code);
+  primitive("copy", make_box, copy_code);
+  primitive("lastbox", make_box, last_box_code);
+  primitive("vsplit", make_box, vsplit_code);
+  primitive("vtop", make_box, vtop_code);
+  primitive("vbox", make_box, vtop_code + vmode);
+  primitive("hbox", make_box, vtop_code + hmode);
+  primitive("shipout", leader_ship, a_leaders - 1);
+  primitive("leaders", leader_ship, a_leaders);
+  primitive("cleaders", leader_ship, c_leaders);
+  primitive("xleaders", leader_ship, x_leaders);
   primitive("indent", start_par, 1);
   primitive("noindent", start_par, 0);
-  primitive("unpenalty", remove_item, 12);
-  primitive("unkern", remove_item, 11);
-  primitive("unskip", remove_item, 10);
-  primitive("unhbox", un_hbox, 0);
-  primitive("unhcopy", un_hbox, 1);
-  primitive("unvbox", un_vbox, 0);
-  primitive("unvcopy", un_vbox, 1);
+  primitive("unpenalty", remove_item, penalty_node);
+  primitive("unkern", remove_item, kern_node);
+  primitive("unskip", remove_item, glue_node);
+  primitive("unhbox", un_hbox, box_code);
+  primitive("unhcopy", un_hbox, copy_code);
+  primitive("unvbox", un_vbox, box_code);
+  primitive("unvcopy", un_vbox, copy_code);
   primitive("-", discretionary, 1);
   primitive("discretionary", discretionary, 0);
   primitive("eqno", eq_no, 0);
   primitive("leqno", eq_no, 1);
-  primitive("mathord", math_comp, 16);
-  primitive("mathop", math_comp, 17);
-  primitive("mathbin", math_comp, 18);
-  primitive("mathrel", math_comp, 19);
-  primitive("mathopen", math_comp, 20);
-  primitive("mathclose", math_comp, 21);
-  primitive("mathpunct", math_comp, 22);
-  primitive("mathinner", math_comp, 23);
-  primitive("underline", math_comp, 26);
-  primitive("overline", math_comp, 27);
-  primitive("displaylimits", limit_switch, 0);
-  primitive("limits", limit_switch, 1);
-  primitive("nolimits", limit_switch, 2);
-  primitive("displaystyle", math_style, 0);
-  primitive("textstyle", math_style, 2);
-  primitive("scriptstyle", math_style, 4);
-  primitive("scriptscriptstyle", math_style, 6);
-  primitive("above", above, 0);
-  primitive("over", above, 1);
-  primitive("atop", above, 2);
-  primitive("abovewithdelims", above, 3);
-  primitive("overwithdelims", above, 4);
-  primitive("atopwithdelims", above, 5);
-  primitive("left", left_right, 30);
-  primitive("right", left_right, 31);
+  primitive("mathord", math_comp, ord_noad);
+  primitive("mathop", math_comp, op_noad);
+  primitive("mathbin", math_comp, bin_noad);
+  primitive("mathrel", math_comp, rel_noad);
+  primitive("mathopen", math_comp, open_noad);
+  primitive("mathclose", math_comp, close_noad);
+  primitive("mathpunct", math_comp, punct_noad);
+  primitive("mathinner", math_comp, inner_noad);
+  primitive("underline", math_comp, under_noad);
+  primitive("overline", math_comp, over_noad);
+  primitive("displaylimits", limit_switch, normal);
+  primitive("limits", limit_switch, limits);
+  primitive("nolimits", limit_switch, no_limits);
+  primitive("displaystyle", math_style, display_style);
+  primitive("textstyle", math_style, text_style);
+  primitive("scriptstyle", math_style, script_style);
+  primitive("scriptscriptstyle", math_style, script_script_style);
+  primitive("above", above, above_code);
+  primitive("over", above, over_code);
+  primitive("atop", above, atop_code);
+  primitive("abovewithdelims", above, delimited_code + above_code);
+  primitive("overwithdelims", above, delimited_code + over_code);
+  primitive("atopwithdelims", above, delimited_code + atop_code);
+  primitive("left", left_right, left_noad);
+  primitive("right", left_right, right_noad);
   text(frozen_right) = make_string_pool("right");
   eqtb[frozen_right] = eqtb[cur_val]; 
   primitive("long", prefix, 1);
@@ -3986,49 +3992,49 @@ void init_prim (void)
   primitive("gdef", def, 1);
   primitive("edef", def, 2);
   primitive("xdef", def, 3);
-  primitive("let", let, 0);
-  primitive("futurelet", let, 1);
-  primitive("chardef", shorthand_def, 0);
-  primitive("mathchardef", shorthand_def, 1);
-  primitive("countdef", shorthand_def, 2);
-  primitive("dimendef", shorthand_def, 3);
-  primitive("skipdef", shorthand_def, 4);
-  primitive("muskipdef", shorthand_def, 5);
-  primitive("toksdef", shorthand_def, 6);
+  primitive("let", let, normal);
+  primitive("futurelet", let, normal + 1);
+  primitive("chardef", shorthand_def, char_def_code);
+  primitive("mathchardef", shorthand_def, math_char_def_code);
+  primitive("countdef", shorthand_def, count_def_code);
+  primitive("dimendef", shorthand_def, dimen_def_code);
+  primitive("skipdef", shorthand_def, skip_def_code);
+  primitive("muskipdef", shorthand_def, mu_skip_def_code);
+  primitive("toksdef", shorthand_def, toks_def_code);
   primitive("catcode", def_code, cat_code_base);
   primitive("mathcode", def_code, math_code_base);
   primitive("lccode", def_code, lc_code_base);
   primitive("uccode", def_code, uc_code_base);
   primitive("sfcode", def_code, sf_code_base);
-  primitive("delcode", def_code, (hash_size + 3474));
-  primitive("textfont", def_family, (hash_size + 1835));
-  primitive("scriptfont", def_family, (hash_size + 1851));
-  primitive("scriptscriptfont", def_family, (hash_size + 1867));
+  primitive("delcode", def_code, del_code_base);
+  primitive("textfont", def_family, math_font_base);
+  primitive("scriptfont", def_family, math_font_base + script_size);
+  primitive("scriptscriptfont", def_family, math_font_base + script_script_size);
   primitive("hyphenation", hyph_data, 0);
   primitive("patterns", hyph_data, 1);
   primitive("hyphenchar", assign_font_int, 0);
   primitive("skewchar", assign_font_int, 1);
-  primitive("batchmode", set_interaction, 0);
-  primitive("nonstopmode", set_interaction, 1);
-  primitive("scrollmode", set_interaction, 2);
-  primitive("errorstopmode", set_interaction, 3);
+  primitive("batchmode", set_interaction, batch_mode);
+  primitive("nonstopmode", set_interaction, nonstop_mode);
+  primitive("scrollmode", set_interaction, scroll_mode);
+  primitive("errorstopmode", set_interaction, error_stop_mode);
   primitive("openin", in_stream, 1);
   primitive("closein", in_stream, 0);
   primitive("message", message, 0);
   primitive("errmessage", message, 1);
-  primitive("lowercase", case_shift, (hash_size + 2139));
-  primitive("uppercase", case_shift, (hash_size + 2395));
-  primitive("show", xray, 0);
-  primitive("showbox", xray, 1);
-  primitive("showthe", xray, 2);
-  primitive("showlists", xray, 3);
-  primitive("openout", extension, 0);
-  primitive("write", extension, 1);
+  primitive("lowercase", case_shift, lc_code_base);
+  primitive("uppercase", case_shift, uc_code_base);
+  primitive("show", xray, show_code);
+  primitive("showbox", xray, show_box_code);
+  primitive("showthe", xray, show_the_code);
+  primitive("showlists", xray, show_lists);
+  primitive("openout", extension, open_node);
+  primitive("write", extension, write_node);
   write_loc = cur_val;
-  primitive("closeout", extension, 2);
-  primitive("special", extension, 3);
-  primitive("immediate", extension, 4);
-  primitive("setlanguage", extension, 5);
+  primitive("closeout", extension, close_node);
+  primitive("special", extension, special_node);
+  primitive("immediate", extension, immediate_code);
+  primitive("setlanguage", extension, set_language_code);
   no_new_control_sequence = true; 
 }
-#endif
\ No newline at end of file
+#endif