OSDN Git Service

pre-pTeX: tex0, tex1.c, tex2.c.
authormaqiyuan <maqiyuan@users.sourceforge.jp>
Wed, 23 Apr 2014 16:07:04 +0000 (00:07 +0800)
committermaqiyuan <maqiyuan@users.sourceforge.jp>
Wed, 23 Apr 2014 16:07:04 +0000 (00:07 +0800)
src/texsourc/coerce.h
src/texsourc/md5file.c
src/texsourc/subroute.c
src/texsourc/tex0.c
src/texsourc/tex1.c
src/texsourc/tex2.c
src/texsourc/texd.h
src/texsourc/yandy_pool.c

index 2bf43ab..c894131 100644 (file)
@@ -198,7 +198,7 @@ void end_diagnostic_(bool);
 void print_length_param_(integer);
 #define print_length_param(n) print_length_param_((integer) (n))
 void print_cmd_chr_(quarterword, halfword);
-#define print_cmd_chr(cmd, chrcode) print_cmd_chr_((quarterword) (cmd), (halfword) (chrcode))
+#define print_cmd_chr(cmd, chr_code) print_cmd_chr_((quarterword) (cmd), (halfword) (chr_code))
 void show_eqtb_(halfword);
 #define show_eqtb(n) show_eqtb_((halfword) (n))
 halfword id_lookup_(integer, integer);
index 1f5b025..03b2b72 100644 (file)
@@ -42,7 +42,7 @@ char * md5_file(const char * file_name)
   fclose(ship_file);
 
   for (i = 0; i < 16; ++i)
-    sprintf(md5_hex + i * 2, "%02x", md5_digest[i]);
+    sprintf(md5_hex + i * 2, "%02X", md5_digest[i]);
 
   return md5_hex;
 }
index 4f70b36..6a5be83 100644 (file)
@@ -29,7 +29,7 @@
 
 #pragma warning(disable:4996)
 #pragma warning(disable:4131) // old style declarator
-#pragma warning(disable:4135) // conversion between different integral types 
+#pragma warning(disable:4135) // conversion between different integral types
 #pragma warning(disable:4127) // conditional expression is constant
 
 #include <setjmp.h>
@@ -44,8 +44,6 @@
 #include <io.h>    // needed for _finddata_t 
 #include <ctype.h> // needed for isascii and isalpha
 
-//////////////////////////////////////////////////////////////////////////////////
-
 #define NAME_MAX 255      // max size of name component
 
 #define ISALPHA(c) (isascii (c) && isalpha(c))
 // default paths to look for things
 
 #define TEXPATH    "C:/yandy/yandytex/"
-
-#define TEXFORMATS TEXPATH "fmt"
-#define TEXPOOL    TEXPATH "pool"
-#define TEXFONTS   TEXPATH "tfm"
+#define TEXFORMATS "C:/yandy/yandytex/fmt"
+#define TEXPOOL    "C:/yandy/yandytex/pool"
+#define TEXFONTS   "C:/yandy/yandytex/tfm"
 #define TEXINPUTS  TEXPATH "tex//;" "C:/tex;" "C:/texinput"
 
 // structure used by fontmap
@@ -86,8 +83,7 @@ char * file_p(string fn);
 bool dir_p(string fn);
 string *find_dir_list (string path);
 void add_directory (string **dir_list_ptr, unsigned *dir_count_ptr, string dir);
-void expand_subdir (string **dir_list_ptr, unsigned *dir_count_ptr, string dirname,
-          struct _finddata_t findt, integer recurseflag);
+void expand_subdir (string **dir_list_ptr, unsigned *dir_count_ptr, string dirname, struct _finddata_t findt, integer recurseflag);
 void save_dir_list (string path,  string *dir_list);
 string *initialize_path_list (string env_name,  string default_path);
 int xfind_path_filename (string buffer, string filename,  string * dir_list);
@@ -532,23 +528,33 @@ void set_paths (int path_bits)
 /*  added code to look for some PC TeX flavour environment names 94/Jan/6 */
 /*  which, in case of formats, could lead to I'm stymied errors ... */
 
-  if (path_bits & TEXFORMATPATHBIT) {
+  if (path_bits & TEXFORMATPATHBIT)
+  {
     s = "TEXFORMATS";
     t = TEXFORMATS;
-    if (grabenv(s) == NULL) {   /* see if env var defined 94/May/19*/
+
+    if (grabenv(s) == NULL)   /* see if env var defined 94/May/19*/
+    {
       strcpy(buffer, texpath);  /* not, see if texpath\fmt is directory */
       strcat(buffer, PATH_SEP_STRING); 
       strcat(buffer, "fmt");
-      if (trace_flag) {
+
+      if (trace_flag)
+      {
         sprintf(log_line, "Checking `%s' = %s %s %s\n", buffer, texpath, PATH_SEP_STRING, "fmt"); /* 95/Jan/25 */
         show_line(log_line, 0);
       }
-      if (dir_p(buffer)) t = xstrdup(buffer); /* 96/Jan/20 */
-      else {
+
+      if (dir_p(buffer))
+        t = xstrdup(buffer); /* 96/Jan/20 */
+      else
+      {
         s = "TEXFMTS";      /* added PC-TeX version 94/Jan/6 */
         if (getenv(s) == NULL)  s = "TEXFMT"; /* em-TeX ... */
       }
-      if (trace_flag) {
+
+      if (trace_flag)
+      {
         sprintf(log_line, "\nSetting up %s (default %s) ", "TEXFORMATS", t);
         show_line(log_line, 0);
       }
@@ -559,7 +565,8 @@ void set_paths (int path_bits)
 /* if (t != TEXFORMATS) free (t); */
   }
 
-  if (path_bits & TEXPOOLPATHBIT) {
+  if (path_bits & TEXPOOLPATHBIT)
+  {
     s = "TEXPOOL";
     t = TEXPOOL;
     if (grabenv(s) == NULL) {     /* 1994/May/19 */
@@ -680,7 +687,8 @@ bool test_read_access (unsigned char *name, int path_index)
   string foundname;
 #endif  
 
-  if (open_trace_flag) {
+  if (open_trace_flag)
+  {
     sprintf(log_line, "Test read access for `%s' ", name);  /* C */
     show_line(log_line, 0);
   }
@@ -690,15 +698,19 @@ bool test_read_access (unsigned char *name, int path_index)
 #ifdef CACHEFILENAME
 /*  If file name and path_index matches - and saved filename exists */
 /*  then use cached full path / file name 96/Nov/16 */
-  if (cache_file_flag) {
+  if (cache_file_flag)
+  {
     if (path_index == last_path_index &&
-        strcmp((const char *)name, last_name) == 0 && *last_filename != '\0') { 
-      if (open_trace_flag) {
+        strcmp((const char *)name, last_name) == 0 && *last_filename != '\0')
+    {
+      if (open_trace_flag)
+      {
         sprintf(log_line, "\nFOUND `%s' (%d) IN CACHE: `%s' ",
             name, path_index, last_filename); 
 /*            name+1, path_index, last_filename); */
         show_line(log_line, 0);
       }
+
       strcpy((char *)name, last_filename); 
       return TRUE;
     }
@@ -1031,7 +1043,8 @@ char *file_p (string fn)
   long hFind;
   int ret;
 
-  if (open_trace_flag) {
+  if (open_trace_flag)
+  {
     sprintf(log_line, "Is `%s' a readable file? ", fn);
     show_line(log_line, 0);
   }
@@ -1039,11 +1052,14 @@ char *file_p (string fn)
 /*  allow for `normal' (_A_NORMAL) as well as `read-only' files */
 
   hFind = _findfirst (fn, &fi);
-  if (hFind > 0) {
+
+  if (hFind > 0)
+  {
     ret = 0;
     _findclose (hFind);
   }
-  else ret = -1;
+  else
+    ret = -1;
 
 /*  check whether found and whether *not* a sub-directory */
   if (ret == 0) {
@@ -1097,6 +1113,7 @@ bool dir_p (string fn)
   char tmpfn[FILENAME_MAX];       /* long enough ??? */
 
   strcpy (tmpfn, fn);           /* make copy so can modify */
+
   if (open_trace_flag)
   {
     sprintf(log_line, "Is `%s' a directory? ", tmpfn);
index 52cad19..ef20f26 100644 (file)
@@ -94,7 +94,7 @@ INLINE void print_err (const char * s)
 }
 INLINE void tex_help (unsigned int n, ...)
 {
-  unsigned int i;
+  int i;
   va_list help_arg;
 
   if (n > 6)
@@ -103,7 +103,7 @@ INLINE void tex_help (unsigned int n, ...)
   help_ptr = n;
   va_start(help_arg, n);
 
-  for (i = n - 1; i > n - 1; --i)
+  for (i = n - 1; i > -1; --i)
     help_line[i] = va_arg(help_arg, char *);
 
   va_end(help_arg);
@@ -392,7 +392,7 @@ void print_the_digs_ (eight_bits k)
   {
     decr(k);
 
-    if (dig[k]< 10)
+    if (dig[k] < 10)
       print_char('0' + dig[k]);
     else
       print_char('A' + dig[k]);
@@ -403,7 +403,9 @@ void print_int_ (integer n)
 {
   char k;
   integer m;
+
   k = 0;
+
   if (n < 0)
   {
     print_char('-');
@@ -414,14 +416,14 @@ void print_int_ (integer n)
     {
       m = -1 - n;
       n = m / 10;
-      m =(m % 10) + 1;
+      m = (m % 10) + 1;
       k = 1;
 
       if (m < 10)
-        dig[0]= (char) m;
+        dig[0] = (char) m;
       else
       {
-        dig[0]= 0;
+        dig[0] = 0;
         incr(n);
       }
     }
@@ -450,21 +452,21 @@ void print_cs_ (integer p)
       }
       else
       {
-        print_esc(""); print(p - 257);
+        print_esc(""); print(p - single_base);
 
         if (cat_code(p - single_base) == letter)
           print_char(' ');
       }
-    else if (p < 1)
+    else if (p < active_base)
       print_esc("IMPOSSIBLE.");
-    else print(p - 1);
+    else print(p - active_base);
   else if (p >= undefined_control_sequence)
     print_esc("IMPOSSIBLE.");
   else if ((text(p) >= str_ptr))
     print_esc("NONEXISTENT.");
   else
   {
-    print_esc(""); print(hash[p].v.RH);
+    print_esc(""); print(text(p));
     print_char(' ');
   }
 }
@@ -485,7 +487,7 @@ void sprint_cs_(halfword p)
     }
   else
   {
-    print_esc(""); print(hash[p].v.RH);
+    print_esc(""); print(text(p));
   }
 }
 /* sec 0518 */
@@ -525,9 +527,11 @@ void jump_out (void)
 
   {
     int code;
+
 #ifndef _WINDOWS
     fflush(stdout); 
 #endif
+
     ready_already = 0;
 
     if (trace_flag)
@@ -560,6 +564,7 @@ void error (void)
     {
 lab22:
       clear_for_error_prompt();
+
       { /* prompt_input */
         print_string("? ");
         term_input("? ", help_ptr);
@@ -798,12 +803,14 @@ void overflow_(char * s, integer n)
     {
       sprintf(log_line, "\n  (Maybe use -h=... on command line in ini-TeX)\n");
       show_line(log_line, 0);
-    } else if (!strcmp(s, "exception dictionary") && n == hyphen_prime)
+    }
+    else if (!strcmp(s, "exception dictionary") && n == hyphen_prime)
     {
       sprintf(log_line, "\n  (Maybe use -e=... on command line in ini-TeX)\n");
       show_line(log_line, 0);
     }
   }
+
   succumb();
 }
 /* sec 0095 */
@@ -860,6 +867,7 @@ bool init_terminal (void)
     fflush(stdout);
     flag = input_ln(stdin, true);
 #endif
+
     if (!flag)
     {
       show_char('\n');
@@ -905,6 +913,7 @@ str_number make_string (void)
 #endif
   incr(str_ptr);
   str_start[str_ptr] = pool_ptr;
+
   return (str_ptr - 1);
 }
 /* sec 0044 */
@@ -923,6 +932,7 @@ bool str_eq_buf_ (str_number s, integer k)
       result = false;
       goto lab45;
     }
+
     incr(j);
     incr(k);
   }
@@ -974,11 +984,13 @@ void print_hex_(integer n)
   k = 0;
   print_char('"');
 
-  do {
-    dig[k] = (unsigned char) (n % 16);
-    n = n / 16;
-    incr(k);
-  } while (!(n == 0));
+  do
+    {
+      dig[k] = (unsigned char) (n % 16);
+      n = n / 16;
+      incr(k);
+    }
+  while (!(n == 0));
 
   print_the_digs(k);
 }
@@ -1019,7 +1031,7 @@ void print_roman_int_(integer n)
     else
     {
       j = j + 2;
-      v = v / (str_pool[j - 1]- '0');
+      v = v / (str_pool[j - 1] - '0');
     }
   }
 }
@@ -1039,10 +1051,7 @@ void print_current_string (void)
 
 int stringlength (int str_ptr)
 {
-  int nstart, nnext;
-  nstart = str_start[str_ptr];
-  nnext = str_start[str_ptr + 1];
-  return (nnext - nstart) + 2;
+  return (str_start[str_ptr + 1] - str_start[str_ptr]) + 2;
 }
 
 char * add_string (char *s, char * str_string)
@@ -1068,38 +1077,53 @@ char * make_up_help_string (int nhelplines)
   int k, nlen = 0;
   
 //  get length of help for this specific message
-  for (k = nhelplines - 1; k >= 0; k--) {
-    //nlen += stringlength(help_line[k]);
+  for (k = nhelplines - 1; k >= 0; k--)
+  {
     nlen += strlen(help_line[k]);
   }
+
   nlen += 2; // for blank line separator: "\r\n"
-  if (addextrahelp) {
+
+  if (addextrahelp)
+  {
     nlen += stringlength(265);
     nlen += stringlength(266);
     nlen += stringlength(267);
+
     if (base_ptr > 0)
       nlen += stringlength(268);
+
     if (deletions_allowed)
       nlen += stringlength(269);
+
     nlen += stringlength(270);
   }
+
   helpstring = (char *) malloc(nlen + 1); // +1 = '\0'
   s = helpstring;
-  for (k = nhelplines-1; k >= 0; k--) {
+
+  for (k = nhelplines-1; k >= 0; k--)
+  {
     s = add_string(s, help_line[k]);
   }
-  if (addextrahelp) {
+
+  if (addextrahelp)
+  {
     strcpy(s, "\r\n");
     s += 2;
     s = add_string(s, "Type <return> to proceed, S to scroll future error messages,");
     s = add_string(s, "R to run without stopping, Q to run quietly,");
     s = add_string(s, "I to insert something, ");
+
     if (base_ptr > 0)
       s = add_string(s, "E to edit your file, ");
+
     if (deletions_allowed)
       s = add_string(s, "1 or ... or 9 to ignore the next 1 to 9 tokens of input,");
+
     s = add_string(s, "H for help, X to quit.");
   }
+
   return helpstring;
 }
 
@@ -1108,6 +1132,7 @@ char * make_up_query_string (int promptstr)
   char *querystr;
   int nstart, nnext, n;
   char *s;
+
   nstart = str_start[ promptstr];
   nnext = str_start[ promptstr + 1];
   n = nnext - nstart;
@@ -1116,6 +1141,7 @@ char * make_up_query_string (int promptstr)
   memcpy(s, &str_pool[nstart], n);  
   s += n;
   *s = '\0';
+
   return querystr;
 }
 
@@ -1136,10 +1162,15 @@ void term_input (char * term_str, int term_help_lines)
 //    free(helpstring);
 //  }
   show_line("\n", 0);    // force it to show what may be buffered up ???
-  helpstring = NULL;  
+  helpstring = NULL;
+
 #ifdef _WINDOWS
-  if (term_str != NULL) querystring = term_str;
-  if (term_help_lines != NULL) helpstring = make_up_help_string(term_help_lines);
+  if (term_str != NULL)
+    querystring = term_str;
+
+  if (term_help_lines != NULL)
+    helpstring = make_up_help_string(term_help_lines);
+
   if (helpstring == NULL && querystring != NULL)
   {
     if (strcmp(querystring, ": ") == 0)
@@ -1155,10 +1186,15 @@ void term_input (char * term_str, int term_help_lines)
     else if (strcmp(querystring, "*") == 0)   // get_next
       helpstring = xstrdup("Please type a control sequence\r\n(or ^z to exit)");
   }
+
   flag = ConsoleInput(querystring, helpstring, (char *) &buffer[first]);  // ???
 //  flag == 0 means trouble --- EOF on terminal
-  if (querystring != NULL) free(querystring);
-  if (helpstring != NULL) free(helpstring);
+  if (querystring != NULL)
+    free(querystring);
+
+  if (helpstring != NULL)
+    free(helpstring);
+
   helpstring = querystring = NULL;
 
   last = first + strlen((char *) &buffer[first]); /* -1 ? */
@@ -1185,9 +1221,11 @@ void term_input (char * term_str, int term_help_lines)
   print_ln();
 #else
   decr(selector);     // shut off echo
+
   if (last != first)
     for (k = first; k <= last - 1; k++)
       print(buffer[k]);
+
   print_ln();
   incr(selector);     // reset selector again
 #endif
@@ -1249,7 +1287,8 @@ scaled round_decimals_(small_number k)
 
   a = 0;
 
-  while (k > 0) {
+  while (k > 0)
+  {
     decr(k);
     a = (a + dig[k] * 131072L) / 10; /* 2^17 */
   }
@@ -1259,7 +1298,7 @@ scaled round_decimals_(small_number k)
 /* sec 0103 */
 /* This has some minor speedup changes - no real advantage probably ... */
 void print_scaled_(scaled s)
-{ 
+{
   scaled delta;
 
   if (s < 0)
@@ -1273,13 +1312,15 @@ void print_scaled_(scaled s)
   s = 10 * (s % 65536L) + 5;
   delta = 10;
 
-  do {
-    if (delta > 65536L)
-      s = s - 17232; /* 2^15 - 50000 - rounding */
-    print_char('0' + (s / 65536L));
-    s = 10 * (s % 65536L);
-    delta = delta * 10;
-  } while (!(s <= delta));
+  do
+    {
+      if (delta > 65536L)
+        s = s - 17232; /* 2^15 - 50000 - rounding */
+      print_char('0' + (s / 65536L));
+      s = 10 * (s % 65536L);
+      delta = delta * 10;
+    }
+  while (!(s <= delta));
 }
 /* sec 0105 */
 scaled mult_and_add_(integer n, scaled x, scaled y, scaled maxanswer)
@@ -1305,7 +1346,9 @@ scaled x_over_n_(scaled x, integer n)
 {
   register scaled Result;
   bool negative;
+
   negative = false;
+
   if (n == 0)
   {
     arith_error = true;
@@ -1344,6 +1387,7 @@ scaled xn_over_d_(scaled x, integer n, integer d)
   register scaled Result;
   bool positive;
   nonnegative_integer t, u, v;
+
   if (x >= 0)
     positive = true; 
   else
@@ -1358,7 +1402,8 @@ scaled xn_over_d_(scaled x, integer n, integer d)
 
   if (u / d >= 32768L)
     arith_error = true; 
-  else u = 32768L * (u / d) + (v / d);
+  else
+    u = 32768L * (u / d) + (v / d);
 
   if (positive)
   {
@@ -1397,7 +1442,7 @@ halfword badness_(scaled t, scaled s)
       return (r * r * r + 131072L) / 262144L;  /* 2^17 */
   }
 }
-
+/* sec 0114 */
 #ifdef DEBUG
 void print_word_(memory_word w)
 { 
@@ -1642,13 +1687,15 @@ void flush_list_(halfword p)          /* paragraph 123 */
   {
     r = p;
 
-    do {
-      q = r;
-      r = link(r);
+    do
+      {
+        q = r;
+        r = link(r);
 #ifdef STAT
-      decr(dyn_used);
+        decr(dyn_used);
 #endif /* STAT */
-    } while (!(r == 0));     /* r != null */
+      }
+    while (!(r == 0));     /* r != null */
 
     link(q) = avail;
     avail = p;
@@ -1665,113 +1712,122 @@ halfword get_node_(integer s)
 lab20:
 
   p = rover;
-  do {
-      q = p + mem[p].hh.v.LH;
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-      while ((mem[q].hh.v.RH == empty_flag)) {
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-        if (q == 0) {
-/* should never happen, since this field is reference count for zeroglue */
-        }  /* debugging code 93/DEC/15 */ /* eventually remove */
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-        t = mem[q + 1].hh.v.RH;
+
+  do
+    {
+      q = p + node_size(p);
+
+      while ((mem[q].hh.v.RH == empty_flag))
+      {
+        t = rlink(q);
+
         if (q == rover)
           rover = t;
-        mem[t + 1].hh.v.LH = mem[q + 1].hh.v.LH;
-        mem[mem[q + 1].hh.v.LH + 1].hh.v.RH = t;
-        q = q + mem[q].hh.v.LH;
+
+        llink(t) = llink(q);
+        rlink(llink(q)) = t;
+        q = q + node_size(q);
       }
+
       r = q - s;
+
       if (r > toint(p + 1)) 
       {
-        mem[p].hh.v.LH = r - p;
+        node_size(p) = r - p;
         rover = p;
         goto lab40;
       }
+
       if (r == p)
-        if (mem[p + 1].hh.v.RH != p)
+        if (rlink(p) != p)
         {
-          rover = mem[p + 1].hh.v.RH;
-          t = mem[p + 1].hh.v.LH;
-          mem[rover + 1].hh.v.LH = t;
-          mem[t + 1].hh.v.RH = rover;
+          rover = rlink(p);
+          t = llink(p);
+          llink(rover) = t;
+          rlink(t) = rover;
           goto lab40;
         }
-      mem[p].hh.v.LH = q - p;
-      p = mem[p + 1].hh.v.RH;
-  } while (!(p == rover));
+
+      node_size(p) = q - p;
+      p = rlink(p);
+    }
+  while (!(p == rover));
+
   if (s == 1073741824L)    /* 2^30 - special case - merge adjacent */
   {
-    Result = empty_flag;
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+    Result = max_halfword;
+
     if (trace_flag)
       show_line("Merged adjacent multi-word nodes\n", 0);
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+
     return Result;
   }
+
 /*  maybe try downward epxansion first instead ? */
   if (lo_mem_max + 2 < hi_mem_min)
-/*  if (lo_mem_max + 2 <= 262143L) */  /* NO! */
     if (lo_mem_max + 2 <= mem_bot + max_halfword)  /* silly ? flush 93/Dec/16 */
     {
-/*    if (hi_mem_min - lo_mem_max >= 1998) */
+      /* if (hi_mem_min - lo_mem_max >= 1998) */
       if (hi_mem_min - lo_mem_max >= (block_size + block_size - 2))
-/*    t = lo_mem_max + 1000;  */
+        /* t = lo_mem_max + 1000; */
         t = lo_mem_max + block_size;
       else
-        t = lo_mem_max + 1 +(hi_mem_min - lo_mem_max) / 2;
-      p = mem[rover + 1].hh.v.LH;
+        t = lo_mem_max + 1 + (hi_mem_min - lo_mem_max) / 2;
+
+      p = llink(rover);
       q = lo_mem_max;
-      mem[p + 1].hh.v.RH = q;
-      mem[rover + 1].hh.v.LH = q;
-/*    if (t > 262143L)   t = 262143L;  */ /* NO! */
+      rlink(p) = q;
+      llink(rover) = q;
+
       if (t > mem_bot + max_halfword)
         t = mem_bot + max_halfword;     /* silly ? flush 93/Dec/16 */
-      mem[q + 1].hh.v.RH = rover;
-      mem[q + 1].hh.v.LH = p;
-      mem[q].hh.v.RH = empty_flag;
-      mem[q].hh.v.LH = t - lo_mem_max; /* block size */
+
+      rlink(q) = rover;
+      llink(q) = p;
+      link(q) = empty_flag;
+      node_size(q) = t - lo_mem_max; /* block size */
       lo_mem_max = t;
-      mem[lo_mem_max].hh.v.RH = 0;
-      mem[lo_mem_max].hh.v.LH = 0;
+      link(lo_mem_max) = 0;
+      info(lo_mem_max) = 0;
       rover = q;
       goto lab20;
     }
-/*  overflow("main memory size", mem_max + 1 - mem_min);  */ /* what used to happen! */
+
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
 /* we've run out of space in the middle for variable length blocks */
 /* try and add new block from below mem_bot *//* first check if space ! */
-  if (mem_min - (block_size + 1) <= mem_start) {/* extend lower memory downwards */
-/*    realloc_main (mem_top/2, 0); */
+  if (mem_min - (block_size + 1) <= mem_start) /* extend lower memory downwards */
+  {
     mem = realloc_main (mem_top/2 + block_size, 0);  /* zzzaa = zmem = mem */
-    if (mem == NULL) {
+
+    if (mem == NULL)
+    {
       return 0;
     }
   }
-/*  if (trace_flag) show_line("Extending downwards by %d\n", block_size, 0); */
-  if (mem_min - (block_size + 1) <= mem_start) { /* check again */
-    if (trace_flag) {
+
+  if (mem_min - (block_size + 1) <= mem_start) /* check again */
+  {
+    if (trace_flag)
+    {
       sprintf(log_line, "mem_min %d, mem_start %d, block_size %d\n", mem_min, mem_start, block_size);
       show_line(log_line, 0);
     }
+
     overflow("main memory size", mem_max + 1 - mem_min); /* darn: allocation failed ! */
     return 0;     // abort_flag set
   }
 /* avoid function call in following ? */
   add_variable_space (block_size); /* now to be found in itex.c */
   goto lab20;         /* go try get_node again */
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
 
-  lab40: mem[r].hh.v.RH = 0; 
-  ;
+lab40:
+  link(r) = 0;
+
 #ifdef STAT
   var_used = var_used + s; 
 #endif /* STAT */
 
-/*  if (trace_flag) {
-    if (r == 0) show_line("r IS ZERO in ZGETNODE!\n", 0);
-  } */      /* debugging code 93/dec/15 */
-
   Result = r; 
   return Result; 
 } 
@@ -2547,7 +2603,7 @@ void show_node_list_(integer p)
 
           {
             {
-              str_pool[pool_ptr]= 46;
+              str_pool[pool_ptr] = 46;
               incr(pool_ptr);
             }
             show_node_list(mem[p + 5].hh.v.RH);
@@ -2559,28 +2615,29 @@ void show_node_list_(integer p)
       case rule_node:
         {
           print_esc("rule(");
-          print_rule_dimen(mem[p + 3].cint);
+          print_rule_dimen(height(p));
           print_char('+');
-          print_rule_dimen(mem[p + 2].cint);
+          print_rule_dimen(depth(p));
           print_string(")x");
-          print_rule_dimen(mem[p + 1].cint);
+          print_rule_dimen(width(p));
         }
         break;
-      case 3:
+
+      case ins_node:
         {
           print_esc("insert");
-          print_int(mem[p].hh.b1);
+          print_int(subtype(p));
           print_string(", natural size ");
-          print_scaled(mem[p + 3].cint);
+          print_scaled(height(p));
           print_string("; split(");
-          print_spec(mem[p + 4].hh.v.RH, "");
+          print_spec(split_top_ptr(p), "");
           print_char(',');
-          print_scaled(mem[p + 2].cint);
+          print_scaled(depth(p));
           print_string("); float cost ");
-          print_int(mem[p + 1].cint);
+          print_int(float_cost(p));
           {
             {
-              str_pool[pool_ptr]= 46;
+              str_pool[pool_ptr] = 46;
               incr(pool_ptr);
             }
             show_node_list(mem[p + 4].hh.v.LH);
@@ -2589,144 +2646,179 @@ void show_node_list_(integer p)
         }
         break;
       case 8:
-        switch (mem[p].hh.b1)
+        switch (subtype(p))
         {
-          case 0:
+          case open_node:
             {
               print_write_whatsit(1279, p);   /* debug # (-1 to exit): */
               print_char('=');
-              print_file_name(mem[p + 1].hh.v.RH, mem[p + 2].hh.v.LH, mem[p + 2].hh.v.RH);
+              print_file_name(open_name(p), open_area(p), open_ext(p));
             }
             break;
-          case 1:
+
+          case write_node:
             {
               print_write_whatsit(591, p);  /* write */
-              print_mark(mem[p + 1].hh.v.RH);
+              print_mark(write_tokens(p));
             }
             break;
-          case 2:
+
+          case close_node:
             print_write_whatsit(1280, p); /* closeout */
             break;
-          case 3:
+
+          case special_node:
             {
               print_esc("special");
-              print_mark(mem[p + 1].hh.v.RH);
+              print_mark(write_tokens(p));
             }
             break;
-          case 4:
+
+          case language_node:
             {
               print_esc("setlanguage");
-              print_int(mem[p + 1].hh.v.RH);
+              print_int(what_lang(p));
               print_string(" (hyphenmin ");
-              print_int(mem[p + 1].hh.b0);
+              print_int(what_lhm(p));
               print_char(',');
-              print_int(mem[p + 1].hh.b1);
+              print_int(what_rhm(p));
               print_char(')');
             }
             break;
+
           default:
             print_string("whatsit?");
             break;
         }
         break;
-      case 10:
-        if (mem[p].hh.b1 >= 100)
+
+      case glue_node:
+        if (subtype(p) >= a_leaders)
         {
           print_esc("");
-          if (mem[p].hh.b1 == 101)
+
+          if (subtype(p) == c_leaders)
             print_char('c');
-          else if (mem[p].hh.b1 == 102)
+          else if (subtype(p) == x_leaders)
             print_char('x');
+
           print_string("leaders ");
-          print_spec(mem[p + 1].hh.v.LH, "");
+
+          print_spec(glue_ptr(p), "");
           {
             {
-              str_pool[pool_ptr]= 46;
+              str_pool[pool_ptr] = 46;
               incr(pool_ptr);
             }
             show_node_list(mem[p + 1].hh.v.RH);
             decr(pool_ptr);
           }
-        } else {
+        }
+        else
+        {
           print_esc("glue");
-          if (mem[p].hh.b1 != 0)
+
+          if (subtype(p) != normal)
           {
             print_char('(');
-            if (mem[p].hh.b1 < 98)
-              print_skip_param(mem[p].hh.b1 - 1);
-            else if (mem[p].hh.b1 == 98)
+
+            if (subtype(p) < cond_math_glue)
+              print_skip_param(subtype(p) - 1);
+            else if (subtype(p) == cond_math_glue)
               print_esc("nonscript");
             else print_esc("mskip");
+
             print_char(')');
           }
-          if (mem[p].hh.b1 != 98)
+
+          if (subtype(p) != cond_math_glue)
           {
             print_char(' ');
-            if (mem[p].hh.b1 < 98)
-              print_spec(mem[p + 1].hh.v.LH, "");
+
+            if (subtype(p) < cond_math_glue)
+              print_spec(glue_ptr(p), "");
             else
-              print_spec(mem[p + 1].hh.v.LH, "mu");
+              print_spec(glue_ptr(p), "mu");
           }
         }
         break;
-      case 11:
-        if (mem[p].hh.b1 != 99)
+
+      case kern_node:
+        if (subtype(p) != mu_glue)
         {
           print_esc("kern");
-          if (mem[p].hh.b1 != 0)
+
+          if (subtype(p) != normal)
             print_char(' ');
-          print_scaled(mem[p + 1].cint);
-          if (mem[p].hh.b1 == 2)
+
+          print_scaled(width(p));
+
+          if (subtype(p) == acc_kern)
             print_string(" (for accent)");
-        } else {
+        }
+        else
+        {
           print_esc("mkern");
-          print_scaled(mem[p + 1].cint);
+          print_scaled(width(p));
           print_string("mu");
         }
         break;
-      case 9:
+
+      case math_node:
         {
           print_esc("math");
-          if (mem[p].hh.b1 == 0)
+
+          if (subtype(p) == before)
             print_string("on");
-          else print_string("off");
-          if (mem[p + 1].cint != 0)
+          else
+            print_string("off");
+
+          if (width(p) != 0)
           {
             print_string(", surrounded ");
-            print_scaled(mem[p + 1].cint);
+            print_scaled(width(p));
           }
         }
         break;
-      case 6:
+
+      case ligature_node:
         {
-          print_font_and_char(p + 1);
+          print_font_and_char(lig_char(p));
           print_string("(ligature ");
-          if (mem[p].hh.b1 > 1)
+
+          if (subtype(p) > 1)
             print_char('|');
-          font_in_short_display = mem[p + 1].hh.b0; 
-          short_display(mem[p + 1].hh.v.RH);
-          if (odd(mem[p].hh.b1))
+
+          font_in_short_display = font(lig_char(p)); 
+          short_display(lig_ptr(p));
+
+          if (odd(subtype(p)))
             print_char('|');
+
           print_char(')');
         }
         break;
-      case 12:
+
+      case penalty_node:
         {
           print_esc("penalty ");
-          print_int(mem[p + 1].cint);
+          print_int(penalty(p));
         }
         break;
-      case 7:
+
+      case disc_node:
         {
           print_esc("discretionary");
-          if (mem[p].hh.b1 > 0)
+
+          if (replace_count(p) > 0)
           {
             print_string(" replacing ");
-            print_int(mem[p].hh.b1);
+            print_int(replace_count(p));
           }
+
           {
             {
-              str_pool[pool_ptr]= 46;
+              str_pool[pool_ptr] = 46;
               incr(pool_ptr);
             }
             show_node_list(mem[p + 1].hh.v.LH);
@@ -2740,18 +2832,20 @@ void show_node_list_(integer p)
           decr(pool_ptr);
         }
         break;
-      case 4:
+
+      case mark_node:
         {
           print_esc("mark");
-          print_mark(mem[p + 1].cint);
+          print_mark(mark_ptr(p));
         }
         break;
-      case 5:
+
+      case adjust_node:
         {
           print_esc("vadjust");
           {
             {
-              str_pool[pool_ptr]= 46;
+              str_pool[pool_ptr] = 46;
               incr(pool_ptr);
             }
             show_node_list(mem[p + 1].cint);
@@ -2759,151 +2853,166 @@ void show_node_list_(integer p)
           }
         }
         break;
-      case 14:
-        print_style(mem[p].hh.b1);
+
+      case style_node:
+        print_style(subtype(p));
         break;
-      case 15:
+
+      case choice_node:
         {
           print_esc("mathchoice");
-          {
-            str_pool[pool_ptr]= 68;
-            incr(pool_ptr);
-          }
-          show_node_list(mem[p + 1].hh.v.LH);
+          append_char('D');
+          show_node_list(display_mlist(p));
           decr(pool_ptr);
-          {
-            str_pool[pool_ptr]= 84;
-            incr(pool_ptr);
-          }
-          show_node_list(mem[p + 1].hh.v.RH);
+          append_char('T');
+          show_node_list(text_mlist(p));
           decr(pool_ptr);
-          {
-            str_pool[pool_ptr]= 83;
-            incr(pool_ptr);
-          }
-          show_node_list(mem[p + 2].hh.v.LH);
+          append_char('S');
+          show_node_list(script_mlist(p));
           decr(pool_ptr);
-          {
-            str_pool[pool_ptr]= 115;
-            incr(pool_ptr);
-          } 
-          show_node_list(mem[p + 2].hh.v.RH); 
+          append_char('s');
+          show_node_list(script_script_mlist(p)); 
           decr(pool_ptr); 
         } 
         break;
-      case 16:
-      case 17:
-      case 18:
-      case 19:
-      case 20:
-      case 21:
-      case 22:
-      case 23:
-      case 24:
-      case 27:
-      case 26:
-      case 29:
-      case 28:
-      case 30:
-      case 31:
+
+      case ord_noad:
+      case op_noad:
+      case bin_noad:
+      case rel_noad:
+      case open_noad:
+      case close_noad:
+      case punct_noad:
+      case inner_noad:
+      case radical_noad:
+      case over_noad:
+      case under_noad:
+      case vcenter_noad:
+      case accent_noad:
+      case left_noad:
+      case right_noad:
         {
-          switch (mem[p].hh.b0)
+          switch (type(p))
           {
-            case 16:
+            case ord_noad:
               print_esc("mathord");
               break;
-            case 17:
+
+            case op_noad:
               print_esc("mathop");
               break;
-            case 18:
+
+            case bin_noad:
               print_esc("mathbin");
               break;
-            case 19:
+
+            case rel_noad:
               print_esc("mathrel");
               break;
-            case 20:
+
+            case open_noad:
               print_esc("mathopen");
               break;
-            case 21:
+
+            case close_noad:
               print_esc("mathclose");
               break;
-            case 22:
+
+            case punct_noad:
               print_esc("mathpunct");
               break;
-            case 23:
+
+            case inner_noad:
               print_esc("mathinner");
               break;
-            case 27:
+
+            case over_noad:
               print_esc("overline");
               break;
-            case 26:
+
+            case under_noad:
               print_esc("underline");
               break;
-            case 29:
+
+            case vcenter_noad:
               print_esc("vcenter");
               break;
-            case 24:
+
+            case radical_noad:
               {
                 print_esc("radical");
-                print_delimiter(p + 4);
+                print_delimiter(left_delimiter(p));
               }
               break;
-            case 28:
+
+            case accent_noad:
               {
                 print_esc("accent");
-                print_fam_and_char(p + 4);
+                print_fam_and_char(accent_chr(p));
               }
               break;
-            case 30:
+
+            case left_noad:
               {
                 print_esc("left");
-                print_delimiter(p + 1);
+                print_delimiter(delimiter(p));
               }
               break;
-            case 31:
+
+            case right_noad:
               {
                 print_esc("right");
-                print_delimiter(p + 1);
+                print_delimiter(delimiter(p));
               }
               break;
-          } 
-          if (mem[p].hh.b1 != 0)
-            if (mem[p].hh.b1 == 1)
+          }
+
+          if (subtype(p) != normal)
+            if (subtype(p) == limits)
               print_esc("limits");
-            else print_esc("nolimits");
-          if (mem[p].hh.b0 < 30)
-            print_subsidiary_data(p + 1, 46);
-          print_subsidiary_data(p + 2, 94);
-          print_subsidiary_data(p + 3, 95);
+            else
+              print_esc("nolimits");
+
+          if (type(p) < left_noad)
+            print_subsidiary_data(nucleus(p), '.');
+
+          print_subsidiary_data(supscr(p), '^');
+          print_subsidiary_data(subscr(p), '_');
         }
         break;
-      case 25:
+
+      case fraction_noad:
         {
           print_esc("fraction, thickness ");
-          if (mem[p + 1].cint == 1073741824L)  /* 2^30 */
+
+          if (thickness(p) == 1073741824L)  /* 2^30 */
             print_string("= default");
-          else print_scaled(mem[p + 1].cint); 
-          if ((mem[p + 4].qqqq.b0 != 0) || (mem[p + 4].qqqq.b1 != 0) ||
-              (mem[p + 4].qqqq.b2 != 0) || (mem[p + 4].qqqq.b3 != 0))
+          else
+            print_scaled(thickness(p));
+
+          if ((small_fam(left_delimiter(p)) != 0) || (small_char(left_delimiter(p)) != 0) ||
+              (large_fam(left_delimiter(p)) != 0) || (large_char(left_delimiter(p)) != 0))
           {
             print_string(", left-delimiter ");
-            print_delimiter(p + 4);
+            print_delimiter(left_delimiter(p));
           }
-          if ((mem[p + 5].qqqq.b0 != 0) || (mem[p + 5].qqqq.b1 != 0) ||
-              (mem[p + 5].qqqq.b2 != 0)||(mem[p + 5].qqqq.b3 != 0))
+
+          if ((small_fam(right_delimiter(p)) != 0) || (small_char(right_delimiter(p)) != 0) ||
+              (large_fam(right_delimiter(p)) != 0)||(large_char(right_delimiter(p)) != 0))
           {
             print_string(", right-delimiter ");
-            print_delimiter(p + 5);
+            print_delimiter(right_delimiter(p));
           }
-          print_subsidiary_data(p + 2, 92);
-          print_subsidiary_data(p + 3, 47);
+
+          print_subsidiary_data(numerator(p), '\\');
+          print_subsidiary_data(denominator(p), '/');
         }
         break;
+
       default:
         print_string("Unknown node type!");
         break;
     }
-    p = mem[p].hh.v.RH;
-  } 
-} 
-/* NOTE: 262143L should be empty_flag */
+    p = link(p);
+  }
+}
\ No newline at end of file
index a97dfa2..1068d98 100644 (file)
@@ -247,62 +247,67 @@ halfword copy_node_list_(halfword p)
 
   h = get_avail();
   q = h;
+
   while (p != 0) {      /* while p<>null do l.3969 */
     words = 1;
+
     if ((p >= hi_mem_min)) 
       r = get_avail();
-    else switch (mem[p].hh.b0)
+    else switch (type(p))
     {
       case hlist_node:
       case vlist_node:
       case unset_node:
         {
           r = get_node(box_node_size);
-          mem[r + 6]= mem[p + 6];
-          mem[r + 5]= mem[p + 5];
-          mem[r + 5].hh.v.RH = copy_node_list(mem[p + 5].hh.v.RH);
+          mem[r + 6] = mem[p + 6];
+          mem[r + 5] = mem[p + 5];
+          list_ptr(r) = copy_node_list(list_ptr(p));
           words = 5;
         }
         break;
       case rule_node:
         {
-          r = get_node(4);
-          words = 4;
+          r = get_node(rule_node_size);
+          words = rule_node_size;
         }
         break;
-      case 3:
+      case ins_node:
         {
-          r = get_node(5);
-          mem[r + 4]= mem[p + 4];
-          incr(mem[mem[p + 4].hh.v.RH].hh.v.RH);
-          mem[r + 4].hh.v.LH = copy_node_list(mem[p + 4].hh.v.LH);
-          words = 4;
+          r = get_node(ins_node_size);
+          mem[r + 4] = mem[p + 4];
+          add_glue_ref(split_top_ptr(p));
+          ins_ptr(r) = copy_node_list(ins_ptr(p));
+          words = ins_node_size - 1;
         }
         break;
-      case 8:
-        switch (mem[p].hh.b1)
+      case whatsit_node:
+        switch (subtype(p))
         {
-          case 0:
+          case open_node:
             {
-              r = get_node(3);
-              words = 3;
+              r = get_node(open_node_size);
+              words = open_node_size;
             }
             break;
-          case 1:
-          case 3:
+
+          case write_node:
+          case special_node:
             {
-              r = get_node(2);
-              incr(mem[mem[p + 1].hh.v.RH].hh.v.LH);
-              words = 2;
+              r = get_node(write_node_size);
+              add_token_ref(write_tokens(p));
+              words = write_node_size;
             }
             break;
-          case 2:
-          case 4:
+
+          case close_node:
+          case language_node:
             {
-              r = get_node(2);
-              words = 2;
+              r = get_node(small_node_size);
+              words = small_node_size;
             }
             break;
+
           default:
             {
               confusion("ext2");
@@ -311,49 +316,56 @@ halfword copy_node_list_(halfword p)
             break;
         }
         break;
-      case 10:
+
+      case glue_node:
         {
-          r = get_node(2);
-          incr(mem[mem[p + 1].hh.v.LH].hh.v.RH);
-          mem[r + 1].hh.v.LH = mem[p + 1].hh.v.LH;
-          mem[r + 1].hh.v.RH = copy_node_list(mem[p + 1].hh.v.RH);
+          r = get_node(small_node_size);
+          add_glue_ref(glue_ptr(p));
+          glue_ptr(r) = glue_ptr(p);
+          leader_ptr(r) = copy_node_list(leader_ptr(p));
         }
         break;
-      case 11:
-      case 9:
-      case 12:
+
+      case kern_node:
+      case math_node:
+      case penalty_node:
         {
-          r = get_node(2);
-          words = 2;
+          r = get_node(small_node_size);
+          words = small_node_size;
         }
         break;
-      case 6:
+
+      case ligature_node:
         {
-          r = get_node(2);
-          mem[r + 1]= mem[p + 1];
-          mem[r + 1].hh.v.RH = copy_node_list(mem[p + 1].hh.v.RH);
+          r = get_node(small_node_size);
+          mem[lig_char(r)] = mem[lig_char(p)];
+          lig_ptr(r) = copy_node_list(lig_ptr(p));
         }
         break;
-      case 7:
+
+      case disc_node:
         {
-          r = get_node(2);
-          mem[r + 1].hh.v.LH = copy_node_list(mem[p + 1].hh.v.LH);
-          mem[r + 1].hh.v.RH = copy_node_list(mem[p + 1].hh.v.RH);
+          r = get_node(small_node_size);
+          pre_break(r) = copy_node_list(pre_break(p));
+          post_break(r) = copy_node_list(pre_break(p));
         }
         break;
-      case 4:
+
+      case mark_node:
         {
-          r = get_node(2);
-          incr(mem[mem[p + 1].cint].hh.v.LH);
-          words = 2;
+          r = get_node(small_node_size);
+          add_token_ref(mark_ptr(p));
+          words = small_node_size;
         }
         break;
-      case 5:
+
+      case adjust_node:
         {
-          r = get_node(2);
-          mem[r + 1].cint = copy_node_list(mem[p + 1].cint);
+          r = get_node(small_node_size);
+          adjust_ptr(r) = copy_node_list(adjust_ptr(p));
         }
         break;
+
       default:
         {
           confusion("copying");
@@ -362,17 +374,21 @@ halfword copy_node_list_(halfword p)
         break;
     }
 
-    while (words > 0) {
+    while (words > 0)
+    {
       decr(words);
       mem[r + words] = mem[p + words]; /* r may be used without having ... */
     }
-    mem[q].hh.v.RH = r;
+
+    link(q) = r;
     q = r;
-    p = mem[p].hh.v.RH;
+    p = link(p);
   }
-  mem[q].hh.v.RH = 0;
+
+  link(q) = 0;
   q = link(h);
   free_avail(h);
+
   Result = q;
   return Result;
 }
@@ -381,7 +397,7 @@ void print_mode_(integer m)
 { 
   if (m > 0)
   {
-    switch (m / (101))
+    switch (m / (max_command + 1))
     {
       case 0:
         print_string("vertical");
@@ -402,7 +418,7 @@ void print_mode_(integer m)
     }
     else
     {
-      switch ((- (integer) m) / (101))
+      switch ((- (integer) m) / (max_command + 1))
       {
         case 0:
           print_string("internal vertical");
@@ -465,8 +481,8 @@ void show_activities (void)
   halfword q, r;
   integer t;
 
-  nest[nest_ptr]= cur_list;
-  print_nl("  ");
+  nest[nest_ptr] = cur_list;
+  print_nl("");
   print_ln();
 
   for (p = nest_ptr; p >= 0; p--)
@@ -478,16 +494,16 @@ void show_activities (void)
     print_string(" entered at line ");
     print_int(abs(nest[p].ml_field));
 
-    if (m == 102)
+    if (m == hmode)
     {
-      if (nest[p].pg_field != 8585216L)  /* 830000 hex ??? */
+      if (nest[p].pg_field != 040600000)
       {
         print_string(" (language");
         print_int(nest[p].pg_field % 65536L);
         print_string(":hyphenmin");
         print_int(nest[p].pg_field / 4194304L);
         print_char(',');
-        print_int((nest[p].pg_field / 65536L)% 64);
+        print_int((nest[p].pg_field / 65536L) % 64);
         print_char(')');
       }
     }
@@ -518,7 +534,8 @@ void show_activities (void)
           print_scaled(page_so_far[0]);
           r = link(page_ins_head);
           
-          while (r != mem_top) {
+          while (r != mem_top)
+          {
             print_ln();
             print_esc("insert");
             t = subtype(r);
@@ -532,7 +549,7 @@ void show_activities (void)
 
             print_scaled(t);
 
-            if (type(r) == 1)
+            if (type(r) == split_up)
             {
               q = page_head;
               t = 0;
@@ -540,10 +557,12 @@ void show_activities (void)
               do
                 {
                   q = link(q);
+
                   if ((type(q) == ins_node) && (subtype(q) == subtype(r)))
                     incr(t);
                 }
-              while (!(q == mem[r + 1].hh.v.LH));
+              while (!(q == broken_ins(r)));
+
               print_string(", #");
               print_int(t);
               print_string(" might split");
@@ -559,7 +578,7 @@ void show_activities (void)
 
     show_box(link(nest[p].head_field));
 
-    switch (abs(m) / (101))
+    switch (abs(m) / (max_command + 1))
     {
       case 0:
         {
@@ -581,6 +600,7 @@ void show_activities (void)
           }
         }
         break;
+
       case 1:
         {
           print_nl("spacefactor ");
@@ -596,6 +616,7 @@ void show_activities (void)
           }
         }
         break;
+
       case 2:
         if (a.cint != 0)
         {
@@ -614,168 +635,223 @@ void print_param_(integer n)
     case pretolerance_code:
       print_esc("pretolerance");
       break;
+
     case tolerance_code:
       print_esc("tolerance");
       break;
+
     case line_penalty_code:
       print_esc("linepenalty");
       break;
+
     case hyphen_penalty_code:
       print_esc("hyphenpenalty");
       break;
+
     case ex_hyphen_penalty_code:
       print_esc("exhyphenpenalty");
       break;
+
     case club_penalty_code:
       print_esc("clubpenalty");
       break;
+
     case widow_penalty_code:
       print_esc("widowpenalty");
       break;
+
     case display_widow_penalty_code:
       print_esc("displaywidowpenalty");
       break;
+
     case broken_penalty_code:
       print_esc("brokenpenalty");
       break;
+
     case bin_op_penalty_code:
       print_esc("binoppenalty");
       break;
+
     case rel_penalty_code:
       print_esc("relpenalty");
       break;
+
     case pre_display_penalty_code:
       print_esc("predisplaypenalty");
       break;
+
     case post_display_penalty_code:
       print_esc("postdisplaypenalty");
       break;
+
     case inter_line_penalty_code:
       print_esc("interlinepenalty");
       break;
+
     case double_hyphen_demerits_code:
       print_esc("doublehyphendemerits");
       break;
+
     case final_hyphen_demerits_code:
       print_esc("finalhyphendemerits");
       break;
+
     case adj_demerits_code:
       print_esc("adjdemerits");
       break;
+
     case mag_code:
       print_esc("mag");
       break;
+
     case delimiter_factor_code:
       print_esc("delimiterfactor");
       break;
+
     case looseness_code:
       print_esc("looseness");
       break;
+
     case time_code:
       print_esc("time");
       break;
+
     case day_code:
       print_esc("day");
       break;
+
     case month_code:
       print_esc("month");
       break;
+
     case year_code:
       print_esc("year");
       break;
+
     case show_box_breadth_code:
       print_esc("showboxbreadth");
       break;
+
     case show_box_depth_code:
       print_esc("showboxdepth");
       break;
+
     case hbadness_code:
       print_esc("hbadness");
       break;
+
     case vbadness_code:
       print_esc("vbadness");
       break;
+
     case pausing_code:
       print_esc("pausing");
       break;
+
     case tracing_online_code:
       print_esc("tracingonline");
       break;
+
     case tracing_macros_code:
       print_esc("tracingmacros");
       break;
+
     case tracing_stats_code:
       print_esc("tracingstats");
       break;
+
     case tracing_paragraphs_code:
       print_esc("tracingparagraphs");
       break;
+
     case tracing_pages_code:
       print_esc("tracingpages");
       break;
+
     case tracing_output_code:
       print_esc("tracingoutput");
       break;
+
     case tracing_lost_chars_code:
       print_esc("tracinglostchars");
       break;
+
     case tracing_commands_code:
       print_esc("tracingcommands");
       break;
+
     case tracing_restores_code:
       print_esc("tracingrestores");
       break;
+
     case uc_hyph_code:
       print_esc("uchyph");
       break;
+
     case output_penalty_code:
       print_esc("outputpenalty");
       break;
+
     case max_dead_cycles_code:
       print_esc("maxdeadcycles");
       break;
+
     case hang_after_code:
       print_esc("hangafter");
       break;
+
     case floating_penalty_code:
       print_esc("floatingpenalty");
       break;
+
     case global_defs_code:
       print_esc("globaldefs");
       break;
+
     case cur_fam_code:
       print_esc("fam");
       break;
+
     case escape_char_code:
       print_esc("escapechar");
       break;
+
     case default_hyphen_char_code:
       print_esc("defaulthyphenchar");
       break;
+
     case default_skew_char_code:
       print_esc("defaultskewchar");
       break;
+
     case end_line_char_code:
       print_esc("endlinechar");
       break;
+
     case new_line_char_code:
       print_esc("newlinechar");
       break;
+
     case language_code:
       print_esc("language");
       break;
+
     case left_hyphen_min_code:
       print_esc("lefthyphenmin");
       break;
+
     case right_hyphen_min_code:
       print_esc("righthyphenmin");
       break;
+
     case holding_inserts_code:
       print_esc("holdinginserts");
       break;
+
     case error_context_lines_code:
       print_esc("errorcontextlines");
       break;
+
     default:
       print_string("[unknown integer parameter!]");
       break;
@@ -789,10 +865,9 @@ void begin_diagnostic (void)
   if ((tracing_online <= 0) && (selector == term_and_log))
   {
     decr(selector);
+
     if (history == spotless)
-    {
       history = warning_issued;
-    }
   }
 }
 /* sec 0245 */
@@ -801,9 +876,7 @@ void end_diagnostic_(bool blankline)
   print_nl("");
 
   if (blankline)
-  {
     print_ln();
-  }
 
   selector = old_setting;
 }
@@ -815,946 +888,1173 @@ void print_length_param_ (integer n)
     case par_indent_code:
       print_esc("parindent");
       break;
+
     case math_surround_code:
       print_esc("mathsurround");
       break;
+
     case line_skip_limit_code:
       print_esc("lineskiplimit");
       break;
+
     case hsize_code:
       print_esc("hsize");
       break;
+
     case vsize_code:
       print_esc("vsize");
       break;
+
     case max_depth_code:
       print_esc("maxdepth");
       break;
+
     case split_max_depth_code:
       print_esc("splitmaxdepth");
       break;
+
     case box_max_depth_code:
       print_esc("boxmaxdepth");
       break;
+
     case hfuzz_code:
       print_esc("hfuzz");
       break;
+
     case vfuzz_code:
       print_esc("vfuzz");
       break;
+
     case delimiter_shortfall_code:
       print_esc("delimitershortfall");
       break;
+
     case null_delimiter_space_code:
       print_esc("nulldelimiterspace");
       break;
+
     case script_space_code:
       print_esc("scriptspace");
       break;
+
     case pre_display_size_code:
       print_esc("predisplaysize");
       break;
+
     case display_width_code:
       print_esc("displaywidth");
       break;
+
     case display_indent_code:
       print_esc("displayindent");
       break;
+
     case overfull_rule_code:
       print_esc("overfullrule");
       break;
+
     case hang_indent_code:
       print_esc("hangindent");
       break;
+
     case h_offset_code:
       print_esc("hoffset");
       break;
+
     case v_offset_code:
       print_esc("voffset");
       break;
+
     case emergency_stretch_code:
       print_esc("emergencystretch");
       break;
+
     default:
       print_string("[unknown dimen parameter!]");
       break;
   }
 }
 /* sec 0298 */
-void print_cmd_chr_ (quarterword cmd, halfword chrcode)
+void print_cmd_chr_ (quarterword cmd, halfword chr_code)
 {
   switch (cmd)
   {
     case left_brace:
       print_string("begin-group character ");
-      print(chrcode);
+      print(chr_code);
       break;
+
     case right_brace:
       print_string("end-group character ");
-      print(chrcode);
+      print(chr_code);
       break;
+
     case math_shift:
       print_string("math shift character ");
-      print(chrcode);
+      print(chr_code);
       break;
+
     case mac_param:
       print_string("macro parameter character ");
-      print(chrcode);
+      print(chr_code);
       break;
+
     case sup_mark:
       print_string("superscript character ");
-      print(chrcode);
+      print(chr_code);
       break;
+
     case sub_mark:
       print_string("subscript character ");
-      print(chrcode);
+      print(chr_code);
       break;
+
     case endv:
       print_string("end of alignment template");
       break;
+
     case spacer:
       print_string("blank space ");
-      print(chrcode);
+      print(chr_code);
       break;
+
     case letter:
       print_string("the letter ");
-      print(chrcode);
+      print(chr_code);
       break;
+
     case other_char:
       print_string("the character ");
-      print(chrcode);
+      print(chr_code);
       break;
+
     case assign_glue:
     case assign_mu_glue:
-      if (chrcode < skip_base)
+      if (chr_code < skip_base)
       {
-        print_skip_param(chrcode - glue_base);
+        print_skip_param(chr_code - glue_base);
       }
       else
       {
-        if (chrcode < mu_skip_base)
+        if (chr_code < mu_skip_base)
         {
           print_esc("skip");
-          print_int(chrcode - skip_base);
+          print_int(chr_code - skip_base);
         }
         else
         {
           print_esc("muskip");
-          print_int(chrcode - mu_skip_base);
+          print_int(chr_code - mu_skip_base);
         }
       }
       break;
+
     case assign_toks:
-      if (chrcode >= toks_base)
+      if (chr_code >= toks_base)
       {
         print_esc("toks");
-        print_int(chrcode - toks_base);
+        print_int(chr_code - toks_base);
       }
       else
       {
-        switch (chrcode)
+        switch (chr_code)
         {
           case output_routine_loc:
             print_esc("output");
             break;
+
           case every_par_loc:
             print_esc("everypar");
             break;
+
           case every_math_loc:
             print_esc("everymath");
             break;
+
           case every_display_loc:
             print_esc("everydisplay");
             break;
+
           case every_hbox_loc:
             print_esc("everyhbox");
             break;
+
           case every_vbox_loc:
             print_esc("everyvbox");
             break;
+
           case every_job_loc:
             print_esc("everyjob");
             break;
+
           case every_cr_loc:
             print_esc("everycr");
             break;
+
           default:
             print_esc("errhelp");
             break;
         }
       }
       break;
+
     case assign_int:
-      if (chrcode < count_base)
+      if (chr_code < count_base)
       {
-        print_param(chrcode - int_base);
+        print_param(chr_code - int_base);
       }
       else
       {
         print_esc("count");
-        print_int(chrcode - count_base);
+        print_int(chr_code - count_base);
       }
       break;
+
     case assign_dimen:
-      if (chrcode < scaled_base)
+      if (chr_code < scaled_base)
       {
-        print_length_param(chrcode - dimen_base);
+        print_length_param(chr_code - dimen_base);
       }
       else
       {
         print_esc("dimen");
-        print_int(chrcode - scaled_base);
+        print_int(chr_code - scaled_base);
       }
       break;
+
     case accent:
       print_esc("accent");
       break;
+
     case advance:
       print_esc("advance");
       break;
+
     case after_assignment:
       print_esc("afterassignment");
       break;
+
     case after_group:
       print_esc("aftergroup");
       break;
+
     case assign_font_dimen:
       print_esc("fontdimen");
       break;
+
     case begin_group:
       print_esc("begingroup");
       break;
+
     case break_penalty:
       print_esc("penalty");
       break;
+
     case char_num:
       print_esc("char");
       break;
+
     case cs_name:
       print_esc("csname");
       break;
+
     case def_font:
       print_esc("font");
       break;
+
     case delim_num:
       print_esc("delimiter");
       break;
+
     case divide:
       print_esc("divide");
       break;
+
     case end_cs_name:
       print_esc("endcsname");
       break;
+
     case end_group:
       print_esc("endgroup");
       break;
+
     case ex_space:
       print_esc(" ");
       break;
+
     case expand_after:
       print_esc("expandafter");
       break;
+
     case halign:
       print_esc("halign");
       break;
+
     case hrule:
       print_esc("hrule");
       break;
+
     case ignore_spaces:
       print_esc("ignorespaces");
       break;
+
     case insert:
       print_esc("insert");
       break;
+
     case ital_corr:
       print_esc("/");
       break;
+
     case mark:
       print_esc("mark");
       break;
+
     case math_accent:
       print_esc("mathaccent");
       break;
+
     case math_char_num:
       print_esc("mathchar");
       break;
+
     case math_choice:
       print_esc("mathchoice");
       break;
+
     case multiply:
       print_esc("multiply");
       break;
+
     case no_align:
       print_esc("noalign");
       break;
+
     case no_boundary:
       print_esc("noboundary");
       break;
+
     case no_expand:
       print_esc("noexpand");
       break;
+
     case non_script:
       print_esc("nonscript");
       break;
+
     case omit:
       print_esc("omit");
       break;
+
     case radical:
       print_esc("radical");
       break;
+
     case read_to_cs:
       print_esc("read");
       break;
+
     case relax:
       print_esc("relax");
       break;
+
     case set_box:
       print_esc("setbox");
       break;
+
     case set_prev_graf:
       print_esc("prevgraf");
       break;
+
     case set_shape:
       print_esc("parshape");
       break;
+
     case the:
       print_esc("the");
       break;
+
     case toks_register:
       print_esc("toks");
       break;
+
     case vadjust:
       print_esc("vadjust");
       break;
+
     case valign:
       print_esc("valign");
       break;
+
     case vcenter:
       print_esc("vcenter");
       break;
+
     case vrule:
       print_esc("vrule");
       break;
+
     case par_end:
       print_esc("par");
       break;
+
     case input:
-      if (chrcode == 0)
+      if (chr_code == 0)
         print_esc("input");
       else
         print_esc("endinput");
       break;
+
     case top_bot_mark:
-      switch (chrcode)
+      switch (chr_code)
       {
         case first_mark_code:
           print_esc("firstmark");
           break;
+
         case bot_mark_code:
           print_esc("botmark");
           break;
+
         case split_first_mark_code:
           print_esc("splitfirstmark");
           break;
+
         case split_bot_mark_code:
           print_esc("splitbotmark");
           break;
+
         default:
           print_esc("topmark");
           break;
       }
       break;
+
     case tex_register:
-      if (chrcode == int_val)
+      if (chr_code == int_val)
         print_esc("count");
-      else if (chrcode == dimen_val)
+      else if (chr_code == dimen_val)
         print_esc("dimen");
-      else if (chrcode == glue_val)
+      else if (chr_code == glue_val)
         print_esc("skip");
       else
         print_esc("muskip");
       break;
+
     case set_aux:
-      if (chrcode == 1)
+      if (chr_code == vmode)
         print_esc("prevdepth");
       else
         print_esc("spacefactor");
       break;
+
     case set_page_int:
-      if (chrcode == 0)
+      if (chr_code == 0)
         print_esc("deadcycles");
       else
         print_esc("insertpenalties");
       break;
+
     case set_box_dimen:
-      if (chrcode == width_offset)
+      if (chr_code == width_offset)
         print_esc("wd");
-      else if (chrcode == height_offset)
+      else if (chr_code == height_offset)
         print_esc("ht");
       else
         print_esc("dp");
       break;
+
     case last_item:
-      switch (chrcode)
+      switch (chr_code)
       {
         case int_val:
           print_esc("lastpenalty");
           break;
+
         case dimen_val:
           print_esc("lastkern");
           break;
+
         case glue_val:
           print_esc("lastskip");
           break;
+
         case input_line_no_code:
           print_esc("inputlineno");
           break;
+
         default:
           print_esc("badness");
           break;
       }
       break;
+
     case convert:
-      switch (chrcode)
+      switch (chr_code)
       {
         case number_code:
           print_esc("number");
           break;
+
         case roman_numeral_code:
           print_esc("romannumeral");
           break;
+
         case string_code:
           print_esc("string");
           break;
+
         case meaning_code:
           print_esc("meaning");
           break;
+
         case font_name_code:
           print_esc("fontname");
           break;
+
         default:
           print_esc("jobname");
           break;
       }
       break;
+
     case if_test:
-      switch (chrcode)
+      switch (chr_code)
       {
         case if_cat_code:
           print_esc("ifcat");
           break;
+
         case if_int_code:
           print_esc("ifnum");
           break;
+
         case if_dim_code:
           print_esc("ifdim");
           break;
+
         case if_odd_code:
           print_esc("ifodd");
           break;
+
         case if_vmode_code:
           print_esc("ifvmode");
           break;
+
         case if_hmode_code:
           print_esc("ifhmode");
           break;
+
         case if_mmode_code:
           print_esc("ifmmode");
           break;
+
         case if_inner_code:
           print_esc("ifinner");
           break;
+
         case if_void_code:
           print_esc("ifvoid");
           break;
+
         case if_hbox_code:
           print_esc("ifhbox");
           break;
+
         case if_vbox_code:
           print_esc("ifvbox");
           break;
+
         case ifx_code:
           print_esc("ifx");
           break;
+
         case if_eof_code:
           print_esc("ifeof");
           break;
+
         case if_true_code:
           print_esc("iftrue");
           break;
+
         case if_false_code:
           print_esc("iffalse");
           break;
+
         case if_case_code:
           print_esc("ifcase");
           break;
+
         default:
           print_esc("if");
           break;
       }
       break;
+
     case fi_or_else:
-      if (chrcode == fi_code)
+      if (chr_code == fi_code)
         print_esc("fi");
-      else if (chrcode == or_code)
+      else if (chr_code == or_code)
         print_esc("or");
       else
         print_esc("else");
       break;
+
     case tab_mark:
-      if (chrcode == span_code)  /* pool size */ /* max_quarterword + 1 ? */
+      if (chr_code == span_code)
         print_esc("span");
       else
       {
         print_string("alignment tab character ");
-        print(chrcode);
+        print(chr_code);
       }
       break;
+
     case car_ret:
-      if (chrcode == cr_code)
+      if (chr_code == cr_code)
         print_esc("cr");
       else
         print_esc("crcr");
       break;
+
     case set_page_dimen:
-      switch (chrcode)
+      switch (chr_code)
       {
         case 0:
           print_esc("pagegoal");
           break;
+
         case 1:
           print_esc("pagetotal");
           break;
+
         case 2:
           print_esc("pagestretch");
           break;
+
         case 3:
           print_esc("pagefilstretch");
           break;
+
         case 4:
           print_esc("pagefillstretch");
           break;
+
         case 5:
           print_esc("pagefilllstretch");
           break;
+
         case 6:
           print_esc("pageshrink");
           break;
+
         default:
           print_esc("pagedepth");
           break;
       }
       break;
+
     case stop:
-      if (chrcode == 1)
+      if (chr_code == 1)
         print_esc("dump");
       else
         print_esc("end");
       break;
+
     case hskip:
-      switch (chrcode)
+      switch (chr_code)
       {
         case skip_code:
           print_esc("hskip");
           break;
+
         case fil_code:
           print_esc("hfil");
           break;
+
         case fill_code:
           print_esc("hfill");
           break;
+
         case ss_code:
           print_esc("hss");
           break;
+
         default:
           print_esc("hfilneg");
           break;
       }
       break;
+
     case vskip:
-      switch (chrcode)
+      switch (chr_code)
       {
         case skip_code:
           print_esc("vskip");
           break;
+
         case fil_code:
           print_esc("vfil");
           break;
+
         case fill_code:
           print_esc("vfill");
           break;
+
         case ss_code:
           print_esc("vss");
           break;
+
         default:
           print_esc("vfilneg");
           break;
       }
       break;
+
     case mskip:
       print_esc("mskip");
       break;
+
     case kern:
       print_esc("kern");
       break;
+
     case mkern:
       print_esc("mkern");
       break;
+
     case hmove:
-      if (chrcode == 1)
+      if (chr_code == 1)
         print_esc("moveleft");
       else
         print_esc("moveright");
       break;
+
     case vmove:
-      if (chrcode == 1)
+      if (chr_code == 1)
         print_esc("raise");
       else
         print_esc("lower");
       break;
+
     case make_box:
-      switch (chrcode)
+      switch (chr_code)
       {
         case box_code:
           print_esc("box");
           break;
+
         case copy_code:
           print_esc("copy");
           break;
+
         case last_box_code:
           print_esc("lastbox");
           break;
+
         case vsplit_code:
           print_esc("vsplit");
           break;
+
         case vtop_code:
           print_esc("vtop");
           break;
+
         case vtop_code + vmode:
           print_esc("vbox");
           break;
+
         default:
           print_esc("hbox");
           break;
       }
       break;
+
     case leader_ship:
-      if (chrcode == a_leaders)
+      if (chr_code == a_leaders)
         print_esc("leaders");
-      else if (chrcode == c_leaders)
+      else if (chr_code == c_leaders)
         print_esc("cleaders");
-      else if (chrcode == x_leaders)
+      else if (chr_code == x_leaders)
         print_esc("xleaders");
       else
         print_esc("shipout");
       break;
+
     case start_par:
-      if (chrcode == 0)
+      if (chr_code == 0)
         print_esc("noindent");
       else
         print_esc("indent");
       break;
+
     case remove_item:
-      if (chrcode == glue_node)
+      if (chr_code == glue_node)
         print_esc("unskip");
-      else if (chrcode == kern_node)
+      else if (chr_code == kern_node)
         print_esc("unkern");
       else
         print_esc("unpenalty");
       break;
+
     case un_hbox:
-      if (chrcode == copy_code)
+      if (chr_code == copy_code)
         print_esc("unhcopy");
       else
         print_esc("unhbox");
       break;
+
     case un_vbox:
-      if (chrcode == copy_code)
+      if (chr_code == copy_code)
         print_esc("unvcopy");
       else
         print_esc("unvbox");
       break;
+
     case discretionary:
-      if (chrcode == 1)
+      if (chr_code == 1)
         print_esc("-");
       else
         print_esc("discretionary");
       break;
+
     case eq_no:
-      if (chrcode == 1)
+      if (chr_code == 1)
         print_esc("leqno");
       else
         print_esc("eqno");
       break;
+
     case math_comp:
-      switch (chrcode)
+      switch (chr_code)
       {
         case ord_noad:
           print_esc("mathord");
           break;
+
         case op_noad:
           print_esc("mathop");
           break;
+
         case bin_noad:
           print_esc("mathbin");
           break;
+
         case rel_noad:
           print_esc("mathrel");
           break;
+
         case open_noad:
           print_esc("mathopen");
           break;
+
         case close_noad:
           print_esc("mathclose");
           break;
+
         case punct_noad:
           print_esc("mathpunct");
           break;
+
         case inner_noad:
           print_esc("mathinner");
           break;
+
         case under_noad:
           print_esc("underline");
           break;
+
         default:
           print_esc("overline");
           break;
       }
       break;
+
     case limit_switch:
-      if (chrcode == limits)
+      if (chr_code == limits)
         print_esc("limits");
-      else if (chrcode == no_limits)
+      else if (chr_code == no_limits)
         print_esc("nolimits");
       else
         print_esc("displaylimits");
       break;
+
     case math_style:
-      print_style(chrcode);
+      print_style(chr_code);
       break;
+
     case above:
-      switch (chrcode)
+      switch (chr_code)
       {
         case over_code:
           print_esc("over");
           break;
+
         case atop_code:
           print_esc("atop");
           break;
+
         case delimited_code + above_code:
           print_esc("abovewithdelims");
           break;
+
         case delimited_code + over_code:
           print_esc("overwithdelims");
           break;
+
         case delimited_code + atop_code:
           print_esc("atopwithdelims");
           break;
+
         default:
           print_esc("above");
           break;
       }
       break;
+
     case left_right:
-      if (chrcode == left_noad)
+      if (chr_code == left_noad)
         print_esc("left");
       else
         print_esc("right");
       break;
+
     case prefix:
-      if (chrcode == 1)
+      if (chr_code == 1)
         print_esc("long");
-      else if (chrcode == 2)
+      else if (chr_code == 2)
         print_esc("outer");
       else
         print_esc("global");
       break;
+
     case def:
-      if (chrcode == 0)
+      if (chr_code == 0)
         print_esc("def");
-      else if (chrcode == 1)
+      else if (chr_code == 1)
         print_esc("gdef");
-      else if (chrcode == 2)
+      else if (chr_code == 2)
         print_esc("edef");
       else
         print_esc("xdef");
       break;
+
     case let:
-      if (chrcode != normal)
+      if (chr_code != normal)
         print_esc("futurelet");
       else
         print_esc("let");
       break;
+
     case shorthand_def:
-      switch (chrcode)
+      switch (chr_code)
       {
         case char_def_code:
           print_esc("chardef");
           break;
+
         case math_char_def_code:
           print_esc("mathchardef");
           break;
+
         case count_def_code:
           print_esc("countdef");
           break;
+
         case dimen_def_code:
           print_esc("dimendef");
           break;
+
         case skip_def_code:
           print_esc("skipdef");
           break;
+
         case mu_skip_def_code:
           print_esc("muskipdef");
           break;
+
         default:
           print_esc("toksdef");
           break;
       }
       break;
+
     case char_given:
       print_esc("char");
-      print_hex(chrcode);
+      print_hex(chr_code);
       break;
+
     case math_given:
       print_esc("mathchar");
-      print_hex(chrcode);
+      print_hex(chr_code);
       break;
+
     case def_code:
-      if (chrcode == cat_code_base)
+      if (chr_code == cat_code_base)
         print_esc("catcode");
-      else if (chrcode == math_code_base)
+      else if (chr_code == math_code_base)
         print_esc("mathcode");
-      else if (chrcode == lc_code_base)
+      else if (chr_code == lc_code_base)
         print_esc("lccode");
-      else if (chrcode == uc_code_base)
+      else if (chr_code == uc_code_base)
         print_esc("uccode");
-      else if (chrcode == sf_code_base)
+      else if (chr_code == sf_code_base)
         print_esc("sfcode");
       else
         print_esc("delcode");
       break;
+
     case def_family:
-      print_size(chrcode - math_font_base);
+      print_size(chr_code - math_font_base);
       break; 
+
     case hyph_data:
-      if (chrcode == 1)
+      if (chr_code == 1)
         print_esc("patterns");
       else
         print_esc("hyphenation");
       break;
+
     case assign_font_int:
-      if (chrcode == 0)
+      if (chr_code == 0)
         print_esc("hyphenchar");
       else
         print_esc("skewchar");
       break;
+
     case set_font:
       print_string("select font ");
-      slow_print(font_name[chrcode]);
-      if (font_size[chrcode] != font_dsize[chrcode])
+      slow_print(font_name[chr_code]);
+
+      if (font_size[chr_code] != font_dsize[chr_code])
       {
         print_string(" at ");
-        print_scaled(font_size[chrcode]);
+        print_scaled(font_size[chr_code]);
         print_string("pt");
       }
       break;
+
     case set_interaction:
-      switch (chrcode)
+      switch (chr_code)
       {
         case batch_mode:
           print_esc("batchmode");
           break;
+
         case nonstop_mode:
           print_esc("nonstopmode");
           break;
+
         case scroll_mode:
           print_esc("scrollmode");
           break;
+
         default:
           print_esc("errorstopmode");
           break;
       }
       break;
+
     case in_stream:
-      if (chrcode == 0)
+      if (chr_code == 0)
         print_esc("closein");
       else
         print_esc("openin");
       break;
+
     case message:
-      if (chrcode == 0)
+      if (chr_code == 0)
         print_esc("message");
       else
         print_esc("errmessage");
       break;
+
     case case_shift:
-      if (chrcode == lc_code_base)
+      if (chr_code == lc_code_base)
         print_esc("lowercase");
       else
         print_esc("uppercase");
       break;
+
     case xray:
-      switch (chrcode)
+      switch (chr_code)
       {
         case show_box_code:
           print_esc("showbox");
           break;
+
         case show_the_code:
           print_esc("showthe");
           break;
+
         case show_lists:
           print_esc("showlists");
           break;
+
         default:
           print_esc("show");
           break;
       }
       break;
+
     case undefined_cs:
       print_string("undefined");
       break;
+
     case call:
       print_string("macro");
       break;
+
     case long_call:
       print_esc("long macro");
       break;
+
     case outer_call:
       print_esc("outer macro");
       break;
+
     case long_outer_call:
       print_esc("long");
       print_esc("outer macro");
       break;
+
     case end_template:
       print_esc("outer endtemplate");
       break;
+
     case extension:
-      switch (chrcode)
+      switch (chr_code)
       {
         case open_node:
           print_esc("openout");
           break;
+
         case write_node:
           print_esc("write");
           break;
+
         case close_node:
           print_esc("closeout");
           break;
+
         case special_node:
           print_esc("special");
           break;
+
         case immediate_code:
           print_esc("immediate");
           break;
+
         case set_language_code:
           print_esc("setlanguage");
           break;
+
         default:
           print_string("[unknown extension!]");
           break;
       }
       break;
+
     default:
       print_string("[unknown command code!]");
       break;
@@ -1772,7 +2072,8 @@ void show_eqtb_(halfword n)
       sprint_cs(n);
       print_char('=');
       print_cmd_chr(eq_type(n), equiv(n));
-      if (eqtb[n].hh.b0 >= call)
+
+      if (eq_type(n) >= call)
       {
         print_char(':');
         show_token_list(link(equiv(n)), 0, 32);
@@ -1784,6 +2085,7 @@ void show_eqtb_(halfword n)
         {
           print_skip_param(n - glue_base);
           print_char('=');
+
           if (n < glue_base + thin_mu_skip_code)
             print_spec(equiv(n), "pt");
           else
@@ -1810,6 +2112,7 @@ void show_eqtb_(halfword n)
           {
             print_esc("parshape");
             print_char('=');
+
             if (par_shape_ptr == 0)
               print_char('0');
             else
@@ -1820,6 +2123,7 @@ void show_eqtb_(halfword n)
             {
               print_cmd_chr(assign_toks, n);
               print_char('=');
+
               if (equiv(n) != 0)
                 show_token_list(link(equiv(n)), 0, 32);
             }
@@ -1829,6 +2133,7 @@ void show_eqtb_(halfword n)
                 print_esc("toks");
                 print_int(n - toks_base);
                 print_char('=');
+
                 if (equiv(n) != 0)
                   show_token_list(link(equiv(n)), 0, 32);
               }
@@ -1838,6 +2143,7 @@ void show_eqtb_(halfword n)
                   print_esc("box");
                   print_int(n - box_base);
                   print_char('=');
+
                   if (equiv(n) == 0)
                     print_string("void");
                   else
@@ -1869,9 +2175,10 @@ void show_eqtb_(halfword n)
                           print_esc("scriptscriptfont");
                           print_int(n - math_font_base - 32);
                         }
-                        print_char('=');
-                        print_esc("");
-                        print(hash[(hash_size + hash_extra + 524) + equiv(n)].v.RH);
+
+                    print_char('=');
+                    print_esc("");
+                    print(hash[font_id_base + equiv(n)].v.RH);
                   }
                   else
                     if (n < math_code_base)
@@ -1898,8 +2205,9 @@ void show_eqtb_(halfword n)
                             print_esc("sfcode");
                             print_int(n - sf_code_base);
                           }
-                          print_char('=');
-                          print_int(equiv(n));
+
+                      print_char('=');
+                      print_int(equiv(n));
                     }
                     else
                     {
@@ -1924,8 +2232,9 @@ void show_eqtb_(halfword n)
           print_esc("delcode");
           print_int(n - del_code_base);
         }
-        print_char('=');
-        print_int(eqtb[n].cint);
+
+      print_char('=');
+      print_int(eqtb[n].cint);
     }
     else
       if (n <= eqtb_size)
@@ -1937,6 +2246,7 @@ void show_eqtb_(halfword n)
           print_esc("dimen");
           print_int(n - scaled_base);
         }
+
         print_char('=');
         print_scaled(eqtb[n].cint);
         print_string("pt");
@@ -1945,32 +2255,34 @@ void show_eqtb_(halfword n)
         print_char('?');
 }
 #endif /* STAT */
-
+/* sec 0259 */
 halfword id_lookup_(integer j, integer l)
 {
-  register halfword Result;
   integer h;
   integer d;
   halfword p;
   halfword k;
 
   h = buffer[j];
+
   for (k = j + 1; k <= j + l - 1; k++)
   {
     h = h + h + buffer[k];
+
     while (h >= hash_prime)
       h = h - hash_prime;
   }
 
   p = h + hash_base;
 
-  while (true) {
+  while (true)
+  {
     if (text(p) > 0)
       if (length(text(p)) == l)
         if (str_eq_buf(text(p), j))
           goto lab40;
 
-    if (hash[p].v.LH == 0)
+    if (next(p) == 0)
     {
       if (no_new_control_sequence)
       {
@@ -1980,16 +2292,18 @@ halfword id_lookup_(integer j, integer l)
       {
         if (text(p) > 0)
         {
-          do {
-            if (hash_is_full)
+          do
             {
-/*        we can't expand the hash table ... */
-/*        overflow("hash size", hash_size); */ /* hash size - NOT DYNAMIC */
-              overflow("hash size", hash_size + hash_extra); /* 96/Jan/10 */
-              return 0;     // abort_flag set
+              if (hash_is_full)
+              {
+                overflow("hash size", hash_size + hash_extra); /* 96/Jan/10 */
+                return 0;     // abort_flag set
+              }
+
+              decr(hash_used);
             }
-            decr(hash_used);
-          } while (!(text(hash_used) == 0));
+          while (!(text(hash_used) == 0));
+
 #ifdef SHORTHASH
           if (hash_used > 65535L) /* debugging only 1996/Jan/20 */
           {
@@ -1997,13 +2311,10 @@ halfword id_lookup_(integer j, integer l)
             show_line(log_line, 1);
           }
 #endif
-          hash[p].v.LH = hash_used;
+
+          next(p) = hash_used;
           p = hash_used;
-        } 
-#ifdef CHECKPOOL
-        if (checkpool(NULL))
-          show_line("after hash_used\n", 0); 
-#endif
+        }
 
         str_room(l);
         d = cur_length;
@@ -2013,14 +2324,14 @@ halfword id_lookup_(integer j, integer l)
           decr(pool_ptr);
           str_pool[pool_ptr + l] = str_pool[pool_ptr];
         }
-#ifdef CHECKPOOL
-        if (checkpool(NULL)) show_line("after pool_ptr\n", 0);
-#endif
+
         for (k = j; k <= j + l - 1; k++)
           append_char(buffer[k]);
+
 #ifdef SHORTHASH
         {
           pool_pointer tempstring = make_string();
+
           if (tempstring > 65535L) /* cannot happen */
           {
             sprintf(log_line, "ERROR: %s too large %d\n", "string ptr", tempstring);
@@ -2031,13 +2342,12 @@ halfword id_lookup_(integer j, integer l)
 #else
         text(p) = make_string();
 #endif
-#ifdef CHECKPOOL
-        if (checkpool(NULL))
-          show_line("after make_string\n", 0); 
-#endif
+
         pool_ptr = pool_ptr + d;
+
 #ifdef STAT
         incr(cs_count);
+
         if (trace_flag)
         {
           str_pool[pool_ptr] = '\0';
@@ -2046,21 +2356,14 @@ halfword id_lookup_(integer j, integer l)
         }
 #endif /* STAT */
       } 
-#ifdef CHECKPOOL
-      if (checkpool(NULL))
-        show_line("after cs_count++\n", 0); 
-#endif
+
       goto lab40; 
     } 
-    p = hash[p].v.LH; 
+    p = next(p);
   } 
-#ifdef CHECKPOOL
-  if (checkpool(NULL))
-    show_line("before return\n", 0); 
-#endif
+
 lab40:
-  Result = p;
-  return Result;
+  return p;
 }
 /* sec 0274 */
 void new_save_level_(group_code c)
@@ -2068,9 +2371,11 @@ void new_save_level_(group_code c)
    if (save_ptr > max_save_stack)
    {
      max_save_stack = save_ptr;
+
 #ifdef ALLOCATESAVESTACK
      if (max_save_stack > current_save_size - 6)
        save_stack = realloc_save_stack(increment_save_size);
+
      if (max_save_stack > current_save_size - 6) /* check again after allocation */
      {
        overflow("save size", current_save_size);
@@ -2084,19 +2389,12 @@ void new_save_level_(group_code c)
      }
 #endif
   }
-/* save_type(save_ptr) <- level_boundary; */
-  save_stack[save_ptr].hh.b0 = 3; 
-/*  save_stack[save_ptr].hh.b1 = cur_group;  *//* keep compiler happy */
-  save_stack[save_ptr].hh.b1 = (quarterword) cur_group; 
-/* save_index(save_ptr):=cur_boundary; */
-  save_stack[save_ptr].hh.v.RH = cur_boundary; 
-/* if cur_level = max_quarterword then ... p.274 */
-/*  if (cur_level == 255)*/      /* 94/Apr/4 */
+  save_type(save_ptr) = level_boundary;
+  save_level(save_ptr) = (quarterword) cur_group; 
+  save_index(save_ptr) = cur_boundary;
+
   if (cur_level == max_quarterword)
   {
-/* { quit if (cur_level + 1) is too large to store in eqtb } */
-/*  overflow("grouping levels", max_quarterword - min_quarterword); */
-/*  overflow("grouping levels", 255); */      /* grouping levels - not dynamic */
     overflow("grouping levels", max_quarterword - min_quarterword); /* 96/Oct/12 ??? */
     return;     // abort_flag set
   }
@@ -2110,6 +2408,7 @@ void new_save_level_(group_code c)
 void eq_destroy_(memory_word w)
 {
   halfword q;
+
   switch (eq_type_field(w))
   {
     case call:
@@ -2118,17 +2417,22 @@ void eq_destroy_(memory_word w)
     case long_outer_call:
       delete_token_ref(equiv_field(w));
       break;
+
     case glue_ref:
       delete_glue_ref(equiv_field(w));
       break;
+
     case shape_ref:
       q = equiv_field(w);
+
       if (q != 0)
         free_node(q, info(q) + info(q) + 1);
       break;
+
     case box_ref:
       flush_node_list(equiv_field(w));
       break;
+
     default:
       break;
   }
@@ -2139,9 +2443,11 @@ void eq_save_(halfword p, quarterword l)
   if (save_ptr > max_save_stack)
   {
     max_save_stack = save_ptr;
+
 #ifdef ALLOCATESAVESTACK
     if (max_save_stack > current_save_size - 6)
       save_stack = realloc_save_stack (increment_save_size);
+
     if (max_save_stack > current_save_size - 6) /* check again after allocation */
     {
       overflow("save size", current_save_size);
@@ -2155,6 +2461,7 @@ void eq_save_(halfword p, quarterword l)
     }
 #endif
   }
+
   if (l == level_zero)
     save_type(save_ptr) = restore_zero;
   else
@@ -2163,6 +2470,7 @@ void eq_save_(halfword p, quarterword l)
     incr(save_ptr);
     save_type(save_ptr) = restore_old_value;
   }
+
   save_level(save_ptr) = l;
   save_index(save_ptr) = p;
   incr(save_ptr);
@@ -2174,6 +2482,7 @@ void eq_define_(halfword p, quarterword t, halfword e)
     eq_destroy(eqtb[p]);
   else if (cur_level > level_one)
     eq_save(p, eq_level(p));
+
   eq_level(p) = (quarterword) cur_level; /* because cur_level padded out */
   eq_type(p) = t;
   equiv(p) = e;
@@ -2186,6 +2495,7 @@ void eq_word_define_(halfword p, integer w)
     eq_save(p, xeq_level[p]);
     xeq_level[p] = (quarterword) cur_level; /* because cur_level padded out */
   }
+
   eqtb[p].cint = w;
 }
 /* sec 0279 */
@@ -2210,9 +2520,11 @@ void save_for_after_(halfword t)
     if (save_ptr > max_save_stack)
     {
       max_save_stack = save_ptr;
+
 #ifdef ALLOCATESAVESTACK
       if (max_save_stack > current_save_size - 6)
         save_stack = realloc_save_stack (increment_save_size);
+
       if (max_save_stack > current_save_size - 6) /* check again after allocation */
       {
         overflow("save size", current_save_size);
@@ -2226,10 +2538,11 @@ void save_for_after_(halfword t)
       }
 #endif
     }
+
     save_type(save_ptr) = insert_token;
     save_level(save_ptr) = level_zero;
     save_index(save_ptr) = t;
     incr(save_ptr);
   }
 }
-/* restore_trace_, unsave followed in the old tex1.c */
+/* restore_trace_, unsave followed in the old tex1.c */
\ No newline at end of file
index febf2c2..2daf0b4 100644 (file)
@@ -133,7 +133,8 @@ void prepare_mag (void)
         "reverted to the magnification you used earlier on this run.");
     int_error(mag_set);
     geq_word_define(int_base + mag_code, mag_set);
-  } 
+  }
+
   if ((mag <= 0) || (mag > 32768L))
   {
     print_err("Illegal magnification has been changed to 1000");
@@ -159,7 +160,7 @@ void print_meaning (void)
     print_char(':');
     print_ln();
     token_show(cur_chr);
-  } 
+  }
   else if (cur_cmd == top_bot_mark)
   {
     print_char(':');
@@ -172,12 +173,14 @@ void show_cur_cmd_chr (void)
 { 
   begin_diagnostic();
   print_nl("{");
+
   if (mode != shown_mode)
   {
     print_mode(mode);
     print_string(": ");
     shown_mode = mode;
   }
+
   print_cmd_chr(cur_cmd, cur_chr);
   print_char('}');
   end_diagnostic(false);
@@ -200,11 +203,15 @@ void show_context (void)
   input_stack[base_ptr] = cur_input;
   nn = -1;
   bottomline = false;
-  while (true) {
+
+  while (true)
+  {
     cur_input = input_stack[base_ptr];
+
     if ((cur_input.state_field != 0))
       if ((cur_input.name_field > 17) || (base_ptr == 0))
         bottomline = true;
+
     if ((base_ptr == input_ptr) || bottomline || (nn < error_context_lines))
     {
       if ((base_ptr == input_ptr) || (cur_input.state_field != token_list) ||
@@ -212,6 +219,7 @@ void show_context (void)
       {
         tally = 0;
         old_setting = selector;
+
         if (cur_input.state_field != 0)
         {
           if (cur_input.name_field <= 17)
@@ -229,13 +237,15 @@ void show_context (void)
                 print_int(cur_input.name_field - 1);
               print_char('>');
             }
-          else {
+          else
+          {
             if (c_style_flag)
             {
               print_ln();
               /* show current input file name - ignore if from terminal */
               if (cur_input.name_field > 17)  /* redundant ? */
                 print(cur_input.name_field);
+
               print_char('(');
               print_int(line); /* line number */
               print_char(')');
@@ -248,17 +258,21 @@ void show_context (void)
               print_int(line);      /* line number */
             }
           }
+
           print_char(' ');
+
           {
             l = tally;
             tally = 0;
             selector = pseudo;
             trick_count = 1000000L;
           }
+
           if (buffer[cur_input.limit_field] == end_line_char)
             j = cur_input.limit_field;
           else
             j = cur_input.limit_field + 1;
+
           if (j > 0)
             for (i = cur_input.start_field; i <= j - 1; i++)
             {
@@ -266,6 +280,7 @@ void show_context (void)
               {
                 first_count = tally;
                 trick_count = tally + 1 + error_line - half_error_line;
+
                 if (trick_count < error_line)
                   trick_count = error_line;
               }
@@ -279,73 +294,93 @@ void show_context (void)
             case parameter:
               print_nl("<argument> ");
               break;
+
             case u_template:
             case v_template:
               print_nl("<template> ");
               break;
+
             case backed_up:
               if (cur_input.loc_field == 0)
                 print_nl("<recently read> ");
               else
                 print_nl("<to be read again> ");
               break;
+
             case inserted:
               print_nl("<inserted text> ");
               break;
+
             case macro:
               print_ln();
               print_cs(cur_input.name_field);
               break;
+
             case output_text:
               print_nl("<output> ");
               break;
+
             case every_par_text:
               print_nl("<everypar> ");
               break;
+
             case every_math_text:
               print_nl("<everymath> ");
               break;
+
             case every_display_text:
               print_nl("<everydisplay> ");
               break;
+
             case every_hbox_text:
               print_nl("<everyhbox> ");
               break;
+
             case every_vbox_text:
               print_nl("<everyvbox> ");
               break;
+
             case every_job_text:
               print_nl("<everyjob> ");
               break;
+
             case every_cr_text:
               print_nl("<everycr> ");
               break;
+
             case mark_text:
               print_nl("<mark> ");
               break;
+
             case write_text:
               print_nl("<write> ");
               break;
+
             default:
               print_nl("?");
               break;
           }
+
           {
             l = tally;
             tally = 0;
             selector = pseudo;
             trick_count = 1000000L;
           }
+
           if (cur_input.index_field < macro)
             show_token_list(cur_input.start_field, cur_input.loc_field, 100000L);
           else
             show_token_list(link(cur_input.start_field), cur_input.loc_field, 100000L);
         }
+
         selector = old_setting;
+
         if (trick_count == 1000000L)
         {
           first_count = tally;
           trick_count = tally + 1 + error_line - half_error_line;
+
           if (trick_count < error_line)
             trick_count = error_line;
         }
@@ -393,8 +428,10 @@ void show_context (void)
       print_nl("...");
       incr(nn); 
     }
+
     if (bottomline)
       goto lab30;
+
     decr(base_ptr);
   }
 lab30:
@@ -408,52 +445,63 @@ void begin_token_list_ (halfword p, quarterword t)
     if (input_ptr > max_in_stack)
     {
       max_in_stack = input_ptr;
+
 #ifdef ALLOCATEINPUTSTACK
       if (input_ptr == current_stack_size)
         input_stack = realloc_input_stack(increment_stack_size);
-      if (input_ptr == current_stack_size)
-      {    /* check again after allocation */
+
+      if (input_ptr == current_stack_size) /* check again after allocation */
+      {
         overflow("input stack size", current_stack_size);
         return;     // abort_flag set
       }
 #else
-      if (input_ptr == stack_size)
-      { /* input stack - not dynamic */
+      if (input_ptr == stack_size) /* input stack - not dynamic */
+      {
         overflow("input stack size", stack_size);
         return;     // abort_flag set
       }
 #endif
     }
+
     input_stack[input_ptr] = cur_input;
     incr(input_ptr);
   }
+
   cur_input.state_field = token_list;
   cur_input.start_field = p;
   cur_input.index_field = t;
+
   if (t >= macro)
   {
     add_token_ref(p);
+
     if (t == macro)
       cur_input.limit_field = param_ptr;
     else
     {
       cur_input.loc_field = link(p);
+
       if (tracing_macros > 1)
       {
         begin_diagnostic(); 
         print_nl("");
+
         switch (t)
         {
           case mark_text:
             print_esc("mark");
             break;
+
           case write_text:
             print_esc("write");
             break;
+
           default:
             print_cmd_chr(assign_toks, t + (hash_size + 1307));
             break;
         }
+
         print_string("->");
         token_show(p);
         end_diagnostic(false);
@@ -475,7 +523,8 @@ void end_token_list (void)
     {
       delete_token_ref(cur_input.start_field);
       if (cur_input.index_field == macro)
-        while (param_ptr > cur_input.limit_field) {
+        while (param_ptr > cur_input.limit_field)
+        {
           decr(param_ptr);
           flush_list(param_stack[param_ptr]);
         }
@@ -484,14 +533,17 @@ void end_token_list (void)
   else if (cur_input.index_field == u_template)
     if (align_state > 500000L)
       align_state = 0;
-    else {
+    else
+    {
       fatal_error("(interwoven alignment preambles are not allowed)");
       return;     // abort_flag set
     }
+
   {
     decr(input_ptr);
     cur_input = input_stack[input_ptr];
   }
+
   {
     if (interrupt != 0)
     {
@@ -503,17 +555,22 @@ void end_token_list (void)
 void back_input (void)
 {
   halfword p;
+
   while ((cur_input.state_field == 0) && (cur_input.loc_field == 0) &&
-      (cur_input.index_field != v_template)) {
+      (cur_input.index_field != v_template))
+  {
     end_token_list();
   }
+
   p = get_avail();
   info(p) = cur_tok;
-  if (cur_tok < 768)
-    if (cur_tok < 512)
+
+  if (cur_tok < right_brace_limit)
+    if (cur_tok < left_brace_limit)
       decr(align_state);
     else
       incr(align_state);
+
   {
     if (input_ptr > max_in_stack)
     {
@@ -521,14 +578,15 @@ void back_input (void)
 #ifdef ALLOCATEINPUTSTACK
       if (input_ptr == current_stack_size)
         input_stack = realloc_input_stack(increment_stack_size);
-      if (input_ptr == current_stack_size)
-      {  /* check again after allocation */
+
+      if (input_ptr == current_stack_size) /* check again after allocation */
+      {
         overflow("input stack size", current_stack_size);
         return;     // abort_flag set
       }
 #else
-      if (input_ptr == stack_size)
-      { /* stack size - not dynamic */
+      if (input_ptr == stack_size) /* stack size - not dynamic */
+      {
         overflow("input stack size", stack_size);
         return;     // abort_flag set
       }
@@ -537,6 +595,7 @@ void back_input (void)
     input_stack[input_ptr] = cur_input;
     incr(input_ptr);
   }
+
   cur_input.state_field = token_list;
   cur_input.start_field = p;
   cur_input.index_field = backed_up;
@@ -570,8 +629,9 @@ void begin_file_reading (void)
 #ifdef ALLOCATEBUFFER
   if (first == current_buf_size)
     buffer = realloc_buffer(increment_buf_size);
-  if (first == current_buf_size)
-  {   /* check again after allocation */
+
+  if (first == current_buf_size) /* check again after allocation */
+  {
     overflow("buffer size", current_buf_size);
     return;     // abort_flag set
   }
@@ -619,8 +679,10 @@ void end_file_reading (void)
 {
   first = cur_input.start_field;
   line = line_stack[cur_input.index_field];
+
   if (cur_input.name_field > 17)
     (void) a_close(input_file[cur_input.index_field]);
+
   {
     decr(input_ptr);
     cur_input = input_stack[input_ptr];
@@ -632,10 +694,10 @@ void end_file_reading (void)
 void clear_for_error_prompt (void) 
 {
   while ((cur_input.state_field != 0) &&
-      (cur_input.name_field == 0) &&
-      (input_ptr > 0) &&
+      (cur_input.name_field == 0) && (input_ptr > 0) &&
       (cur_input.loc_field > cur_input.limit_field))
     end_file_reading();
+
   print_ln();
 }
 /* sec 0336 */
@@ -647,16 +709,16 @@ void check_outer_validity (void)
   if (scanner_status != 0)
   {
     deletions_allowed = false;
+
     if (cur_cs != 0)
     {
-      if ((cur_input.state_field == 0) ||
-          (cur_input.name_field < 1) ||
-          (cur_input.name_field > 17))
+      if ((cur_input.state_field == 0) || (cur_input.name_field < 1) || (cur_input.name_field > 17))
       {
         p = get_avail();
-        info(p) = 4095 + cur_cs;
-        begin_token_list(p, 3);
+        info(p) = cs_token_flag + cur_cs;
+        back_list(p);
       }
+
       cur_cmd = spacer;
       cur_chr = ' ';
     }
@@ -664,6 +726,7 @@ void check_outer_validity (void)
     if (scanner_status > skipping)
     {
       runaway();
+
       if (cur_cs == 0)
         print_err("File ended");
       else
@@ -671,36 +734,39 @@ void check_outer_validity (void)
         cur_cs = 0;
         print_err("Forbidden control sequence found");
       }
+
       print_string(" while scanning ");
       p = get_avail();
+
       switch (scanner_status)
       {
         case defining:
           print_string("definition");
-          info(p) = 637;
+          info(p) = right_brace_token + '}';
           break;
+
         case matching:
           print_string("use");
           info(p) = par_token;
           long_state = outer_call;
           break;
+
         case aligning:
           print_string("preamble");
-          info(p) = 637;
+          info(p) = right_brace_token + '}';
           q = p;
           p = get_avail();
           link(p) = q;
-/*    mem[p].hh.v.LH = (hash_size + 4610);  */
-/*    mem[p].hh.v.LH = (hash_size + 4095 + 515);  */
-          info(p) = (hash_size + hash_extra + 4095 + 515); /*96/Jan/10*/
+          info(p) = cs_token_flag + frozen_cr; /*96/Jan/10*/
           align_state = -1000000L;
           break;
+
         case absorbing:
           print_string("text");
-          info(p) = 637;
+          info(p) = right_brace_token + '}';
           break;
       }
-      begin_token_list(p, 4);
+      ins_list(p);
       print_string(" of ");
       sprint_cs(warning_index);
       help4("I suspect you have forgotten a `}', causing me",
@@ -718,13 +784,13 @@ void check_outer_validity (void)
       help3("A forbidden control sequence occurred in skipped text.",
           "This kind of error happens when you say `\\if...' and forget",
           "the matching `\\fi'. I've inserted a `\\fi'; this might work.");
+
       if (cur_cs != 0)
         cur_cs = 0; 
       else
         help_line[2] = "The file ended while I was skipping conditional text.";
-/*      cur_tok = (hash_size + 4613);  */
-/*      cur_tok = (hash_size + 4095 + 518);  */
-      cur_tok = (hash_size + hash_extra + 4095 + 518); /* 96/Jan/10 */
+
+      cur_tok = cs_token_flag + frozen_fi; /* 96/Jan/10 */
       ins_error();
   }
     deletions_allowed = true;
@@ -740,24 +806,30 @@ void firm_up_the_line (void)
   integer k;
 
   cur_input.limit_field = last;
+
   if (pausing > 0)
-    if (interaction > 1)
+    if (interaction > nonstop_mode)
     {
       ;
       print_ln();
+
       if (cur_input.start_field < cur_input.limit_field)
         for (k = cur_input.start_field; k <= cur_input.limit_field - 1; k++)
           print(buffer[k]);
+
       first = cur_input.limit_field;
+
       {
         ;
         print_string("=>");
         term_input("=>", 0);
       }
+
       if (last > first)
       {
         for (k = first; k <= last - 1; k++)
           buffer[k + cur_input.start_field - first] = buffer[k];
+
         cur_input.limit_field = cur_input.start_field + last - first;
       }
     }
@@ -768,10 +840,11 @@ void get_token (void)
   no_new_control_sequence = false;
   get_next();
   no_new_control_sequence = true;
+
   if (cur_cs == 0)
     cur_tok = (cur_cmd * 256) + cur_chr;
   else
-    cur_tok = 4095 + cur_cs;
+    cur_tok = cs_token_flag + cur_cs;
 }
 /* sec 0389 */
 void macro_call (void)
@@ -806,247 +879,291 @@ void macro_call (void)
     token_show(refcount);
     end_diagnostic(false);
   }
-  if (info(r) != 3584)
+
+  if (info(r) != end_match_token)
   {
     scanner_status = matching;
     unbalance = 0;
     long_state = eq_type(cur_cs);
+
     if (long_state >= outer_call)
       long_state = long_state - 2;
-    do {
-      link(temp_head) = 0;
-      if ((info(r) > 3583) || (info(r) < 3328))
-        s = 0;
-      else
-      {
-        match_chr = info(r) - 3328;
-        s = link(r);
-        r = s;
-        p = temp_head;
-        m = 0;
-      }
-lab22:
-      get_token();
-      if (cur_tok == info(r))
+
+    do
       {
-        r = link(r);
-        if ((info(r) >= 3328) && (info(r) <= 3584))
+        link(temp_head) = 0;
+
+        if ((info(r) > match_token + 255) || (info(r) < match_token))
+          s = 0;
+        else
         {
-          if (cur_tok < 512)
-            decr(align_state);
-          goto lab40;
+          match_chr = info(r) - match_token;
+          s = link(r);
+          r = s;
+          p = temp_head;
+          m = 0;
         }
-        else
-          goto lab22;
-      }
-      if (s != r)
-        if (s == 0)
+lab22:
+        get_token();
+
+        if (cur_tok == info(r))
         {
-          print_err("Use of ");
-          sprint_cs(warning_index);
-          print_string(" doesn't match its definition");
-          help4("If you say, e.g., `\\def\\a1{...}', then you must always",
+          r = link(r);
+
+          if ((info(r) >= match_token) && (info(r) <= end_match_token))
+          {
+            if (cur_tok < left_brace_limit)
+              decr(align_state);
+
+            goto lab40;
+          }
+          else
+            goto lab22;
+        }
+
+        if (s != r)
+          if (s == 0)
+          {
+            print_err("Use of ");
+            sprint_cs(warning_index);
+            print_string(" doesn't match its definition");
+            help4("If you say, e.g., `\\def\\a1{...}', then you must always",
               "put `1' after `\\a', since control sequence names are",
               "made up of letters only. The macro here has not been",
               "followed by the required stuff, so I'm ignoring it.");
-          error();
-          goto lab10;
-        }
-        else
-        {
-          t = s;
-          do {
-            {
-              q = get_avail();
-              mem[p].hh.v.RH = q;
-              mem[q].hh.v.LH = mem[t].hh.v.LH;
-              p = q;
-            }
-            incr(m);
-            u = link(t);
-            v = s;
-            while (true) {
-              if (u == r)
-                if (cur_tok != info(v))
-                  goto lab30;
-                else
+            error();
+            goto lab10;
+          }
+          else
+          {
+            t = s;
+            do
+              {
                 {
-                  r = link(v);
-                  goto lab22;
+                  q = get_avail();
+                  mem[p].hh.v.RH = q;
+                  mem[q].hh.v.LH = mem[t].hh.v.LH;
+                  p = q;
+                }
+
+                incr(m);
+                u = link(t);
+                v = s;
+
+                while (true)
+                {
+                  if (u == r)
+                    if (cur_tok != info(v))
+                      goto lab30;
+                    else
+                    {
+                      r = link(v);
+                      goto lab22;
+                    }
+
+                    if (info(u) != info(v))
+                      goto lab30;
+
+                    u = link(u);
+                    v = link(v);
                 }
-              if (info(u) != info(v))
-                goto lab30;
-              u = link(u);
-              v = link(v);
-            }
 lab30:
-            t = link(t);
-          } while(!(t == r));
-          r = s;
-        }
-      if (cur_tok == par_token)
-        if (long_state != long_call)
-        {
-          if (long_state == call)
+                t = link(t);
+              }
+            while(!(t == r));
+
+            r = s;
+          }
+
+        if (cur_tok == par_token)
+          if (long_state != long_call)
           {
-            runaway();
-            print_err("Paragraph ended before ");
-            sprint_cs(warning_index);
-            print_string("was complete");
-            help3("I suspect you've forgotten a `}', causing me to apply this",
-                "control sequence to too much text. How can we recover?",
-                "My plan is to forget the whole thing and hope for the best.");
-            back_error();
+            if (long_state == call)
+            {
+              runaway();
+              print_err("Paragraph ended before ");
+              sprint_cs(warning_index);
+              print_string("was complete");
+              help3("I suspect you've forgotten a `}', causing me to apply this",
+                  "control sequence to too much text. How can we recover?",
+                  "My plan is to forget the whole thing and hope for the best.");
+              back_error();
+            }
+
+            pstack[n] = link(temp_head);
+            align_state = align_state - unbalance;
+
+            for (m = 0; m <= n; m++)
+              flush_list(pstack[m]);
+
+            goto lab10;
           }
-          pstack[n] = link(temp_head);
-          align_state = align_state - unbalance;
-          for (m = 0; m <= n; m++)
-            flush_list(pstack[m]);
-          goto lab10;
-        }
-      if (cur_tok < 768)
-        if (cur_tok < 512)
-        {
-          unbalance = 1;
-          while (true) {
+
+        if (cur_tok < right_brace_limit)
+          if (cur_tok < left_brace_limit)
+          {
+            unbalance = 1;
+
+            while (true)
             {
               {
-                q = avail;
-                if (q == 0)
-                  q = get_avail();
-                else
                 {
-                  avail = mem[q].hh.v.RH;
-                  mem[q].hh.v.RH = 0;
+                  q = avail;
+
+                  if (q == 0)
+                    q = get_avail();
+                  else
+                  {
+                    avail = mem[q].hh.v.RH;
+                    mem[q].hh.v.RH = 0;
 #ifdef STAT
-                  incr(dyn_used);
+                    incr(dyn_used);
 #endif /* STAT */
+                  }
                 }
+
+                mem[p].hh.v.RH = q;
+                mem[q].hh.v.LH = cur_tok;
+                p = q;
               }
+
+              get_token();
+
+              if (cur_tok == par_token)
+                if (long_state != long_call)
+                {
+                  if (long_state == call)
+                  {
+                    runaway();
+                    print_err("Paragraph ended before ");
+                    sprint_cs(warning_index);
+                    print_string(" was complete");
+                    help3("I suspect you've forgotten a `}', causing me to apply this",
+                        "control sequence to too much text. How can we recover?",
+                        "My plan is to forget the whole thing and hope for the best.");
+                    back_error();
+                  }
+
+                  pstack[n] = link(temp_head);
+                  align_state = align_state - unbalance;
+
+                  for (m = 0; m <= n; m++)
+                    flush_list(pstack[m]);
+                  goto lab10;
+                }
+
+              if (cur_tok < right_brace_limit)
+                if (cur_tok < left_brace_limit)
+                  incr(unbalance);
+                else
+                {
+                  decr(unbalance);
+
+                  if (unbalance == 0)
+                    goto lab31;
+                }
+            }
+lab31:
+            rbraceptr = p;
+
+            {
+              q = get_avail();
               mem[p].hh.v.RH = q;
               mem[q].hh.v.LH = cur_tok;
               p = q;
             }
-            get_token();
-            if (cur_tok == par_token)
-              if (long_state != long_call)
-              {
-                if (long_state == call)
-                {
-                  runaway();
-                  print_err("Paragraph ended before ");
-                  sprint_cs(warning_index);
-                  print_string(" was complete");
-                  help3("I suspect you've forgotten a `}', causing me to apply this",
-                      "control sequence to too much text. How can we recover?",
-                      "My plan is to forget the whole thing and hope for the best.");
-                  back_error();
-                }
-                pstack[n] = link(temp_head);
-                align_state = align_state - unbalance;
-                for (m = 0; m <= n; m++)
-                  flush_list(pstack[m]);
-                goto lab10;
-              }
-            if (cur_tok < 768)
-              if (cur_tok < 512)
-                incr(unbalance); 
-              else
-              {
-                decr(unbalance);
-                if (unbalance == 0)
-                  goto lab31;
-              }
           }
-lab31:
-          rbraceptr = p;
+          else
+          {
+            back_input();
+            print_err("Argument of ");
+            sprint_cs(warning_index);
+            print_string(" has an extra }");
+            help6("I've run across a `}' that doesn't seem to match anything.",
+                "For example, `\\def\\a#1{...}' and `\\a}' would produce",
+                "this error. If you simply proceed now, the `\\par' that",
+                "I've just inserted will cause me to report a runaway",
+                "argument that might be the root of the problem. But if",
+                "your `}' was spurious, just type `2' and it will go away.");
+            incr(align_state);
+            long_state = call;
+            cur_tok = par_token;
+            ins_error();
+            goto lab22;
+          }
+        else
+        {
+          if (cur_tok == space_token)
+            if (info(r) <= end_match_token)
+              if (info(r) >= match_token)
+                goto lab22;
+
           {
             q = get_avail();
-            mem[p].hh.v.RH = q;
+            mem[p].hh.v.RH = q;   /* p may be used without having ... */
             mem[q].hh.v.LH = cur_tok;
             p = q;
           }
         }
-        else
-        {
-          back_input();
-          print_err("Argument of ");
-          sprint_cs(warning_index);
-          print_string(" has an extra }");
-          help6("I've run across a `}' that doesn't seem to match anything.",
-              "For example, `\\def\\a#1{...}' and `\\a}' would produce",
-              "this error. If you simply proceed now, the `\\par' that",
-              "I've just inserted will cause me to report a runaway",
-              "argument that might be the root of the problem. But if",
-              "your `}' was spurious, just type `2' and it will go away.");
-          incr(align_state);
-          long_state = call;
-          cur_tok = par_token;
-          ins_error();
+
+        incr(m);          /* m may be used without having been ... */
+
+        if (info(r) > end_match_token)
+          goto lab22;
+
+        if (info(r) < match_token)
           goto lab22;
-        }
-      else
-      {
-        if (cur_tok == 2592)
-          if (info(r) <= 3584)
-            if (info(r) >= 3328)
-              goto lab22;
-        {
-          q = get_avail();
-          mem[p].hh.v.RH = q;   /* p may be used without having ... */
-          mem[q].hh.v.LH = cur_tok;
-          p = q;
-        }
-      }
-      incr(m);          /* m may be used without having been ... */
-      if (info(r) > 3584)
-        goto lab22;
-      if (info(r) < 3328)
-        goto lab22;
 lab40:
-      if (s != 0)
-      {
-        if ((m == 1) && (info(p) < 768) && (p != temp_head))
-        {
-          link(rbraceptr) = 0; /* rbraceptr may be used without ... */
-          free_avail(p);
-          p = link(temp_head);
-          pstack[n]= link(p);
-          free_avail(p);
-        }
-        else
-          pstack[n] = link(temp_head);
-        incr(n);
-        if (tracing_macros > 0)
+        if (s != 0)
         {
-          begin_diagnostic();
-          //print_nl(match_chr); /* matchchar may be used without ... */
-          print_nl(""); print(match_chr);
-          print_int(n);
-          print_string("<-");
-          show_token_list(pstack[n - 1], 0, 1000);
-          end_diagnostic(false);
+          if ((m == 1) && (info(p) < right_brace_limit) && (p != temp_head))
+          {
+            link(rbraceptr) = 0; /* rbraceptr may be used without ... */
+            free_avail(p);
+            p = link(temp_head);
+            pstack[n] = link(p);
+            free_avail(p);
+          }
+          else
+            pstack[n] = link(temp_head);
+
+          incr(n);
+
+          if (tracing_macros > 0)
+          {
+            begin_diagnostic();
+            //print_nl(match_chr); /* matchchar may be used without ... */
+            print_nl(""); print(match_chr);
+            print_int(n);
+            print_string("<-");
+            show_token_list(pstack[n - 1], 0, 1000);
+            end_diagnostic(false);
+          }
         }
       }
-    } while(!(info(r) == 3584));
+    while(!(info(r) == end_match_token));
   }
 
   while((cur_input.state_field == token_list) && (cur_input.loc_field == 0) &&
       (cur_input.index_field != v_template))
     end_token_list();
+
   begin_token_list(refcount, macro);
   cur_input.name_field = warning_index;
   cur_input.loc_field = link(r);
+
   if (n > 0)
   {
     if (param_ptr + n > max_param_stack)
     {
       max_param_stack = param_ptr + n;
+
 #ifdef ALLOCATEPARAMSTACK
       if (max_param_stack > current_param_size)
         param_stack = realloc_param_stack(increment_param_size);
-      if (max_param_stack > current_param_size)
-      { /* check again after allocation */
+
+      if (max_param_stack > current_param_size) /* check again after allocation */
+      {
         overflow("parameter stack size", current_param_size);
         return;     // abort_flag set
       }
@@ -1058,8 +1175,10 @@ lab40:
       }
 #endif
     }
+
     for (m = 0; m <= n - 1; m++)
       param_stack[param_ptr + m] = pstack[m];
+
     param_ptr = param_ptr + n;
   }
 lab10:
@@ -1067,13 +1186,11 @@ lab10:
   warning_index = savewarningindex;
 }
 /* sec 0379 */
-void insert_relax (void) 
+void insert_relax (void)
 {
-  cur_tok = 4095 + cur_cs;
+  cur_tok = cs_token_flag + cur_cs;
   back_input();
-/*  cur_tok = (hash_size + 4616);  */
-/*  cur_tok = (hash_size + 4095 + 521);  */
-  cur_tok = (hash_size + hash_extra + 4095 + 521);  /* 96/Jan/10 */
+  cur_tok = cs_token_flag + frozen_relax;  /* 96/Jan/10 */
   back_input();
   cur_input.index_field = inserted;
 }
@@ -1093,27 +1210,33 @@ void expand (void)
   radixbackup = radix;
   cobackup = cur_order;
   backupbackup = link(backup_head);
+
   if (cur_cmd < call)
   {
     if (tracing_commands > 1)
       show_cur_cmd_chr();
+
     switch (cur_cmd)
     {
       case top_bot_mark:
         if (cur_mark[cur_chr] != 0)
           begin_token_list(cur_mark[cur_chr], mark_text);
         break;
+
       case expand_after:
         get_token();
         t = cur_tok;
         get_token();
+
         if (cur_cmd > max_command)
           expand();
         else
           back_input();
+
         cur_tok = t;
         back_input();
         break;
+
       case no_expand:
         savescannerstatus = scanner_status;
         scanner_status = normal;
@@ -1121,31 +1244,34 @@ void expand (void)
         scanner_status = savescannerstatus;
         t = cur_tok;
         back_input();
-        if (t >= 4095)   /* if t>=cs_token_flag then */
+
+        if (t >= cs_token_flag)
         {
-/*   begin p:=get_avail; info(p):=cs_token_flag+frozen_dont_expand; */
           p = get_avail();
-/*    mem[p].hh.v.LH = (hash_size + 4618);  */
-/*    mem[p].hh.v.LH = (hash_size + 4095 + 523); */
-          mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 523); /*96/Jan/10*/
-          mem[p].hh.v.RH = cur_input.loc_field;
+          info(p) = cs_token_flag + frozen_dont_expand; /*96/Jan/10*/
+          link(p) = cur_input.loc_field;
           cur_input.start_field = p;
           cur_input.loc_field = p;
         }
         break;
+
       case cs_name:
         r = get_avail();
         p = r;
-        do {
-          get_x_token();
-          if (cur_cs == 0)
+        do
           {
-            q = get_avail();
-            mem[p].hh.v.RH = q;
-            mem[q].hh.v.LH = cur_tok;
-            p = q;
+            get_x_token();
+  
+            if (cur_cs == 0)
+            {
+              q = get_avail();
+              mem[p].hh.v.RH = q;
+              mem[q].hh.v.LH = cur_tok;
+              p = q;
+            }
           }
-        } while(!(cur_cs != 0));
+        while(!(cur_cs != 0));
+
         if (cur_cmd != end_cs_name)
         {
           print_err("Missing ");
@@ -1155,17 +1281,22 @@ void expand (void)
               "not appear between \\csname and \\endcsname.");
           back_error();
         }
+
         j = first;
         p = link(r);
-        while (p != 0) {  /* while p<>null do l.7742 */
+
+        while (p != 0)
+        {
           if (j >= max_buf_stack)
           {
             max_buf_stack = j + 1;
+
 #ifdef ALLOCATEBUFFER
             if (max_buf_stack == current_buf_size)
               buffer = realloc_buffer (increment_buf_size);
-            if (max_buf_stack == current_buf_size)
-            {  /* check again after allocation */
+
+            if (max_buf_stack == current_buf_size) /* check again after allocation */
+            {
               overflow("buffer size", current_buf_size);
               return;     // abort_flag set
             }
@@ -1177,10 +1308,12 @@ void expand (void)
             }
 #endif
           }
+
           buffer[j] = info(p) % 256;
           incr(j);
           p = link(p);
         }
+
         if (j > first + 1)
         {
           no_new_control_sequence = false;
@@ -1191,23 +1324,30 @@ void expand (void)
           cur_cs = null_cs;
         else
           cur_cs = single_base + buffer[first];
+
         flush_list(r);
+
         if (eq_type(cur_cs) == undefined_cs)
         {
           eq_define(cur_cs, relax, 256);
         }
-        cur_tok = cur_cs + 4095;
+
+        cur_tok = cur_cs + cs_token_flag;
         back_input();
         break;
+
       case convert:
         conv_toks();
         break;
+
       case the:
         ins_the_toks();
         break;
+
       case if_test:
         conditional();
         break;
+
       case fi_or_else:
         if (cur_chr > if_limit)
           if (if_limit == 1)
@@ -1221,25 +1361,29 @@ void expand (void)
           }
         else
         {
-          while(cur_chr != 2)
+          while(cur_chr != fi_code)
             pass_text();
+
           {
             p = cond_ptr;
-            if_line = mem[p + 1].cint;
-            cur_if = mem[p].hh.b1;
-            if_limit = mem[p].hh.b0;
-            cond_ptr = mem[p].hh.v.RH;
-            free_node(p, 2);
+            if_line = if_line_field(p);
+            cur_if = subtype(p);
+            if_limit = type(p);
+            cond_ptr = link(p);
+            free_node(p, if_node_size);
           }
         }
         break;
+
       case input:
         if (cur_chr > 0)
           force_eof = true;
         else if (name_in_progress)
           insert_relax();
-        else start_input();
+        else
+          start_input();
         break;
+
       default:
         print_err("Undefined control sequence");
         help5("The control sequence at the end of the top line",
@@ -1257,11 +1401,10 @@ void expand (void)
   }
   else
   {
-/*    cur_tok = (hash_size + 4615);  */
-/*    cur_tok = (hash_size + 4095 + 520);  */
-    cur_tok = (hash_size + hash_extra + 4095 + 520); /* 96/Jan/10 */
+    cur_tok = cs_token_flag + frozen_endv; /* 96/Jan/10 */
     back_input();
   }
+
   cur_val = cvbackup;
   cur_val_level = cvlbackup;
   radix = radixbackup;
@@ -1273,44 +1416,50 @@ void get_x_token (void)
 {
 lab20:
   get_next();
+
   if (cur_cmd <= max_command)
     goto lab30;
   if (cur_cmd >= call)
     if (cur_cmd < end_template)
       macro_call();
-    else {
-/*      cur_cs = (hash_size + 520);  */
-      cur_cs = (hash_size + hash_extra + 520);  /* 96/Jan/10 */
+    else
+    {
+      cur_cs = frozen_endv;  /* 96/Jan/10 */
       cur_cmd = endv;
       goto lab30;
     }
   else
     expand();
+
   goto lab20;
 lab30:
   if (cur_cs == 0)
     cur_tok = (cur_cmd * 256) + cur_chr;
   else
-    cur_tok = 4095 + cur_cs;
+    cur_tok = cs_token_flag + cur_cs;
 }
 /* sec 0381 */
 void x_token (void)
 {
-  while (cur_cmd > max_command) {
+  while (cur_cmd > max_command)
+  {
     expand();
     get_next();
   }
+
   if (cur_cs == 0)
     cur_tok = (cur_cmd * 256) + cur_chr;
   else
-    cur_tok = 4095 + cur_cs;
+    cur_tok = cs_token_flag + cur_cs;
 }
 /* sec 0403 */
 void scan_left_brace (void)
 {
-  do {
+  do
+    {
       get_x_token();
-  } while(!((cur_cmd != spacer) && (cur_cmd != relax)));
+    }
+  while(!((cur_cmd != spacer) && (cur_cmd != relax)));
 
   if (cur_cmd != left_brace)
   {
@@ -1320,7 +1469,7 @@ void scan_left_brace (void)
         "so that I will find a matching right brace soon.",
         "(If you're confused by all this, try typing `I}' now.)");
     back_error();
-    cur_tok = 379;
+    cur_tok = left_brace_token + '{';
     cur_cmd = left_brace;
     cur_chr = '{';
     incr(align_state);
@@ -1329,17 +1478,18 @@ void scan_left_brace (void)
 /* sec 0405 */
 void scan_optional_equals (void)
 {
-  do {
+  do
+    {
       get_x_token();
-  } while(!(cur_cmd != spacer));
+    }
+  while(!(cur_cmd != spacer));
 
-  if (cur_tok != 3133)
+  if (cur_tok != other_token + '=')
     back_input();
 }
 /* sec 0407 */
 bool scan_keyword_(char * s)
 {
-  register bool Result;
   halfword p;
   halfword q;
   char * k;
@@ -1348,9 +1498,11 @@ bool scan_keyword_(char * s)
   link(p) = 0;
   k = s;
 
-  while (*k) {
+  while (*k)
+  {
     get_x_token(); 
-    if ((cur_cs == 0) && ((cur_chr == (*k)) || (cur_chr == (*k) - 32)))
+
+    if ((cur_cs == 0) && ((cur_chr == (*k)) || (cur_chr == (*k) - 'a' + 'A')))
     {
       {
         q = get_avail();
@@ -1358,20 +1510,23 @@ bool scan_keyword_(char * s)
         mem[q].hh.v.LH = cur_tok;
         p = q;
       }
+
       incr(k);
     }
     else if ((cur_cmd != spacer) || (p != backup_head))
     {
       back_input();
+
       if (p != backup_head)
-        begin_token_list(link(backup_head), 3);
-      Result = false;
-      return(Result);
+        back_list(link(backup_head));
+
+      return false;
     }
   }
+
   flush_list(link(backup_head));
-  Result = true;
-  return Result;
+
+  return true;
 }
 /* sec 0408 */
 void mu_error (void)
@@ -1384,6 +1539,7 @@ void mu_error (void)
 void scan_eight_bit_int (void)
 {
   scan_int();
+
   if ((cur_val < 0) || (cur_val > 255))
   {
     print_err("Bad register code");
@@ -1397,6 +1553,7 @@ void scan_eight_bit_int (void)
 void scan_char_num (void)
 {
   scan_int();
+
   if ((cur_val < 0) || (cur_val > 255))
   {
     print_err("Bad character code");
@@ -1410,6 +1567,7 @@ void scan_char_num (void)
 void scan_four_bit_int (void)
 {
   scan_int();
+
   if ((cur_val < 0) || (cur_val > 15))
   {
     print_err("Bad number");
@@ -1436,6 +1594,7 @@ void scan_fifteen_bit_int (void)
 void scan_twenty_seven_bit_int (void)
 {
   scan_int();
+
   if ((cur_val < 0) || (cur_val > 134217727L)) /* 2^27 - 1 */
   {
     print_err("Bad delimiter code");
@@ -1451,9 +1610,11 @@ void scan_font_ident (void)
   internal_font_number f;
   halfword m;
 
-  do {
+  do
+    {
       get_x_token();
-  } while (!(cur_cmd != spacer));
+    }
+  while (!(cur_cmd != spacer));
 
   if (cur_cmd == def_font)
     f = cur_font;
@@ -1471,8 +1632,9 @@ void scan_font_ident (void)
     help2("I was looking for a control sequence whose",
         "current meaning has been defined by \\font.");
     back_error();
-    f = 0;
+    f = null_font;
   }
+
   cur_val = f;
 }
 /* sec 0578 */
@@ -1485,64 +1647,63 @@ void find_font_dimen_(bool writing)
   n = cur_val;
   scan_font_ident();
   f = cur_val;
-/*  if (n <= 0)*/            /* change 98/Oct/5 */
-  if (n < 0 || (n == 0 && font_dimen_zero == 0))
+
+  if (n < 0 || (n == 0 && font_dimen_zero == 0)) /* change 98/Oct/5 */
     cur_val = fmem_ptr;
   else
   {
-/* else  begin if writing and(n<=space_shrink_code)and@|
-    (n>=space_code)and(font_glue[f]<>null) then
-    begin delete_glue_ref(font_glue[f]); l.11225 */
-    if (writing && (n <= 4) && (n >= 2) && (font_glue[f]!= 0)) 
+    if (writing && (n <= space_shrink_code) && (n >= space_code) && (font_glue[f] != 0)) 
     {
       delete_glue_ref(font_glue[f]);
-      font_glue[f]= 0;  /* font_glue[f]:=null */
+      font_glue[f] = 0;
     }
+
     if (n > font_params[f])
       if (f < font_ptr)
         cur_val = fmem_ptr;
     else
     {
-      do {
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+      do
+        {
  #ifdef ALLOCATEFONT
-        if (fmem_ptr == current_font_mem_size)
-        { /* 93/Nov/28 ??? */
-          font_info = realloc_font_info(increment_font_mem_size);
-        }
-        if (fmem_ptr == current_font_mem_size)
-        {    /* 94/Jan/24 */
-          overflow("font memory", current_font_mem_size); /* font memory */
-          return;     // abort_flag set
-        }
+          if (fmem_ptr == current_font_mem_size) /* 93/Nov/28 ??? */
+          {
+            font_info = realloc_font_info(increment_font_mem_size);
+          }
+
+          if (fmem_ptr == current_font_mem_size) /* 94/Jan/24 */
+          {
+            overflow("font memory", current_font_mem_size); /* font memory */
+            return;     // abort_flag set
+          }
 #else
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-        if (fmem_ptr == font_mem_size)
-        {
-          overflow("font memory", font_mem_size); /* font memory */
-          return;     // abort_flag set
-        }
+          if (fmem_ptr == font_mem_size)
+          {
+            overflow("font memory", font_mem_size); /* font memory */
+            return;     // abort_flag set
+          }
 #endif
-        font_info[fmem_ptr].cint = 0;
-        incr(fmem_ptr);
-        incr(font_params[f]);
-      } while(!(n == font_params[f]));
+          font_info[fmem_ptr].cint = 0;
+          incr(fmem_ptr);
+          incr(font_params[f]);
+        }
+      while(!(n == font_params[f]));
+
       cur_val = fmem_ptr - 1;
     }
-/*  else cur_val = n + param_base[f];   */      /* 98/Oct/5 */
   else if (n > 0)
     cur_val = n + param_base[f];    /* 98/Oct/5 */
-  else cur_val = &font_check[f] - &font_info[0]; /* 98/Oct/5 */
+  else
+    cur_val = (&font_check[f] - &font_info[0]); /* 98/Oct/5 */
 /*  checksum =  (((font_check[f].b0) << 8 | font_check[f].b1) << 8 |
         font_check[f].b2) << 8 | font_check[f].b3; */
-  } 
+  }
 /* compiler error: '-' : incompatible types - from 'union fmemoryword *' to 'struct fourunsignedchars *' */
   if (cur_val == fmem_ptr)
   {
     print_err("Font ");
 /*    print_esc(hash[(hash_size + 524) + f].v.RH); */
-    //print_esc(hash[(hash_size + hash_extra + 524) + f].v.RH); /*96/Jan/10*/
-    print_esc(""); print(hash[(hash_size + hash_extra + 524) + f].v.RH);
+    print_esc(""); print(font_id_text(f));
     print_string(" has only ");
     print_int(font_params[f]);
     print_string(" fontdimen parameters");
@@ -1560,339 +1721,381 @@ void scan_something_internal_(small_number level, bool negative)
 {
   halfword m;
   integer p;
+
   m = cur_chr;
 
   switch (cur_cmd)
   {
     case def_code:
-      scan_char_num();
-      if (m == math_code_base)
       {
-        cur_val = math_code(cur_val);
-        cur_val_level = 0;
+        scan_char_num();
+
+        if (m == math_code_base)
+        {
+          cur_val = math_code(cur_val);
+          cur_val_level = int_val;
+        }
+        else if (m < math_code_base)
+        {
+          cur_val = equiv(m + cur_val);
+          cur_val_level = int_val;
+        }
+        else
+        {
+          cur_val = eqtb[m + cur_val].cint;
+          cur_val_level = int_val;
+        }
       }
-      else if (m < math_code_base)
+      break;
+
+    case toks_register:
+    case assign_toks:
+    case def_family:
+    case set_font:
+    case def_font:
+      if (level != tok_val)
       {
-        cur_val = equiv(m + cur_val);
-        cur_val_level = 0;
+        print_err("Missing number, treated as zero");
+        help3("A number should have been here; I inserted `0'.",
+            "(If you can't figure out why I needed to see a number,",
+            "look up `weird error' in the index to The TeXbook.)");
+        back_error();
+        {
+          cur_val = 0;
+          cur_val_level = dimen_val;
+        }
+      }
+      else if (cur_cmd <= assign_toks)
+      {
+        if (cur_cmd < assign_toks)
+        {
+          scan_eight_bit_int();
+          m = toks_base + cur_val;
+        }
+
+        {
+          cur_val = eqtb[m].hh.v.RH;
+          cur_val_level = tok_val;
+        }
       }
       else
       {
-        cur_val = eqtb[m + cur_val].cint;
-        cur_val_level = 0;
+        back_input();
+        scan_font_ident();
+
+        {
+          cur_val = font_id_base + cur_val; /* 96/Jan/10 */
+          cur_val_level = ident_val;
+        }
       }
       break;
-  case toks_register:
-  case assign_toks:
-  case def_family:
-  case set_font:
-  case def_font:
-    if (level != 5)
-    {
-      print_err("Missing number, treated as zero");
-      help3("A number should have been here; I inserted `0'.",
-          "(If you can't figure out why I needed to see a number,",
-          "look up `weird error' in the index to The TeXbook.)");
-      back_error();
+
+    case assign_int:
       {
-        cur_val = 0;
-        cur_val_level = 1;
+        cur_val = eqtb[m].cint;
+        cur_val_level = int_val;
       }
-    }
-    else if (cur_cmd <= assign_toks)
-    {
-      if (cur_cmd < assign_toks)
+      break;
+
+    case assign_dimen:
       {
-        scan_eight_bit_int();
-        m = toks_base + cur_val;
+        cur_val = eqtb[m].cint;
+        cur_val_level = dimen_val;
       }
+      break; 
+
+    case assign_glue:
       {
         cur_val = eqtb[m].hh.v.RH;
-        cur_val_level = 5;
+        cur_val_level = glue_val;
       }
-    } 
-    else
-    {
-      back_input();
-      scan_font_ident();
+      break;
+
+    case assign_mu_glue:
       {
-/*  cur_val = (hash_size + 524) + cur_val;  */
-        cur_val = (hash_size + hash_extra + 524) + cur_val; /* 96/Jan/10 */
-        cur_val_level = 4;
+        cur_val = eqtb[m].hh.v.RH;
+        cur_val_level = mu_val;
       }
-    }
-    break;
-  case assign_int:
-    {
-      cur_val = eqtb[m].cint;
-      cur_val_level = 0;
-    }
-    break;
-  case assign_dimen:
-    {
-      cur_val = eqtb[m].cint;
-      cur_val_level = 1;
-    }
-    break; 
-  case assign_glue:
-    {
-      cur_val = eqtb[m].hh.v.RH;
-      cur_val_level = 2;
-    }
-    break;
-  case assign_mu_glue:
-    {
-      cur_val = eqtb[m].hh.v.RH;
-      cur_val_level = 3;
-    }
-    break;
-  case set_aux:
-    if (abs(mode)!= m)
-    {
-      print_err("Improper ");
-      print_cmd_chr(set_aux, m);
-      help4("You can refer to \\spacefactor only in horizontal mode;",
-          "you can refer to \\prevdepth only in vertical mode; and",
-          "neither of these is meaningful inside \\write. So",
-          "I'm forgetting what you said and using zero instead.");
-      error();
-      if (level != 5)
+      break;
+
+    case set_aux:
+      if (abs(mode)!= m)
       {
-        cur_val = 0;
-        cur_val_level = 1;
+        print_err("Improper ");
+        print_cmd_chr(set_aux, m);
+        help4("You can refer to \\spacefactor only in horizontal mode;",
+            "you can refer to \\prevdepth only in vertical mode; and",
+            "neither of these is meaningful inside \\write. So",
+            "I'm forgetting what you said and using zero instead.");
+        error();
+
+        if (level != tok_val)
+        {
+          cur_val = 0;
+          cur_val_level = dimen_val;
+        }
+        else
+        {
+          cur_val = 0;
+          cur_val_level = int_val;
+        }
+      }
+      else if (m == vmode)
+      {
+        cur_val = cur_list.aux_field.cint;
+        cur_val_level = dimen_val;
       }
       else
       {
-        cur_val = 0;
-        cur_val_level = 0;
+        cur_val = space_factor;
+        cur_val_level = int_val;
       }
-    }
-    else if (m == 1)
-    {
-      cur_val = cur_list.aux_field.cint;
-      cur_val_level = 1;
-    } 
-    else
-    {
-      cur_val = space_factor;
-      cur_val_level = 0;
-    }
-    break;
-  case set_prev_graf:
-    if (mode == 0)
-    {
-      cur_val = 0;
-      cur_val_level = 0;
-    }
-    else
-    {
-      nest[nest_ptr] = cur_list;
-      p = nest_ptr;
-      while (abs(nest[p].mode_field)!= 1)
-        decr(p);
+      break;
+
+    case set_prev_graf:
+      if (mode == 0)
       {
-        cur_val = nest[p].pg_field;
-        cur_val_level = 0;
+        cur_val = 0;
+        cur_val_level = int_val;
       }
-    }
-    break;
-  case set_page_int:
-    {
-      if (m == 0)
-        cur_val = dead_cycles; 
       else
-        cur_val = insert_penalties;
-      cur_val_level = 0;
-    }
-    break;
-  case set_page_dimen:
-    {
-      if ((page_contents == 0) && (! output_active))
+      {
+        nest[nest_ptr] = cur_list;
+        p = nest_ptr;
+
+        while (abs(nest[p].mode_field)!= vmode)
+          decr(p);
+
+        {
+          cur_val = nest[p].pg_field;
+          cur_val_level = int_val;
+        }
+      }
+      break;
+
+    case set_page_int:
+      {
         if (m == 0)
-          cur_val = 1073741823L;  /* 2^30 - 1 */
+          cur_val = dead_cycles; 
         else
-          cur_val = 0;
-      else
-        cur_val = page_so_far[m];
-      cur_val_level = 1;
-    }
-    break;
-  case set_shape:
-    {
-      if (par_shape_ptr == 0)
-        cur_val = 0; 
-      else
-        cur_val = mem[par_shape_ptr].hh.v.LH;
-      cur_val_level = 0;
-    }
-    break;
-  case set_box_dimen:
-    {
-      scan_eight_bit_int();
+          cur_val = insert_penalties;
 
-      if (box(cur_val) == 0)
-        cur_val = 0;
-      else
-        cur_val = mem[box(cur_val) + m].cint;
+        cur_val_level = 0;
+      }
+      break;
 
-      cur_val_level = dimen_val;
-    }
-    break;
-  case char_given:
-  case math_given:
-    {
-      cur_val = cur_chr;
-      cur_val_level = 0;
-    }
-    break;
-  case assign_font_dimen:
-    {
-      find_font_dimen(false);
-      font_info[fmem_ptr].cint = 0;
+    case set_page_dimen:
       {
-        cur_val = font_info[cur_val].cint;
-        cur_val_level = 1;
+        if ((page_contents == 0) && (! output_active))
+          if (m == 0)
+            cur_val = 1073741823L;  /* 2^30 - 1 */
+          else
+            cur_val = 0;
+        else
+          cur_val = page_so_far[m];
+
+        cur_val_level = dimen_val;
       }
-    }
-    break;
-  case assign_font_int:
-    {
-      scan_font_ident();
-      if (m == 0)
+      break;
+
+    case set_shape:
       {
-        cur_val = hyphen_char[cur_val];
-        cur_val_level = 0;
+        if (par_shape_ptr == 0)
+          cur_val = 0; 
+        else
+          cur_val = info(par_shape_ptr);
+
+        cur_val_level = int_val;
       }
-      else
+      break;
+
+    case set_box_dimen:
       {
-        cur_val = skew_char[cur_val];
-        cur_val_level = 0;
+        scan_eight_bit_int();
+
+        if (box(cur_val) == 0)
+          cur_val = 0;
+        else
+          cur_val = mem[box(cur_val) + m].cint;
+
+        cur_val_level = dimen_val;
       }
-    }
-    break;
-  case tex_register:
-    {
-      scan_eight_bit_int();
+      break;
 
-      switch(m)
+    case char_given:
+    case math_given:
       {
-        case int_val:
-          cur_val = count(cur_val);
-          break;
-        case dimen_val:
-          cur_val = dimen(cur_val);
-          break;
-        case glue_val:
-          cur_val = skip(cur_val);
-          break;
-        case mu_val:
-          cur_val = mu_skip(cur_val);
-          break;
+        cur_val = cur_chr;
+        cur_val_level = int_val;
       }
+      break;
 
-      cur_val_level = m;
-    }
-    break;
-  case last_item:
-    if (cur_chr > 2)
-    {
-      if (cur_chr == 3)
-        cur_val = line;
-      else
-        cur_val = last_badness;
-      cur_val_level = 0;
-    }
-    else
-    {
-      if (cur_chr == 2)
-        cur_val = 0;
-      else
-        cur_val = 0;
-      cur_val_level = cur_chr;
-      if (!(tail >= hi_mem_min) && (mode != 0))
-        switch(cur_chr)
+    case assign_font_dimen:
+      {
+        find_font_dimen(false);
+        font_info[fmem_ptr].cint = 0;
         {
-          case 0:
-            if (mem[tail].hh.b0 == 12)
-              cur_val = mem[tail + 1].cint;
-            break;
-          case 1:
-            if (mem[tail].hh.b0 == 11)
-              cur_val = mem[tail + 1].cint;
-            break;
-          case 2:
-            if (mem[tail].hh.b0 == 10)
-            {
-              cur_val = mem[tail + 1].hh.v.LH;
-              if (mem[tail].hh.b1 == 99)
-                cur_val_level = 3;
-            }
-            break;
+          cur_val = font_info[cur_val].cint;
+          cur_val_level = dimen_val;
         }
-      else if ((mode == 1) && (tail == cur_list.head_field))
-        switch (cur_chr)
+      }
+      break;
+
+    case assign_font_int:
+      {
+        scan_font_ident();
+
+        if (m == 0)
         {
-          case 0:
-            cur_val = last_penalty;
+          cur_val = hyphen_char[cur_val];
+          cur_val_level = int_val;
+        }
+        else
+        {
+          cur_val = skew_char[cur_val];
+          cur_val_level = int_val;
+        }
+      }
+      break;
+
+    case tex_register:
+      {
+        scan_eight_bit_int();
+
+        switch(m)
+        {
+          case int_val:
+            cur_val = count(cur_val);
+            break;
+
+          case dimen_val:
+            cur_val = dimen(cur_val);
             break;
-          case 1:
-            cur_val = last_kern;
+
+          case glue_val:
+            cur_val = skip(cur_val);
             break;
-          case 2:
-/*  if (last_glue != 262143L) */ /* NO! */
-            if (last_glue != empty_flag)
-              cur_val = last_glue;
+
+          case mu_val:
+            cur_val = mu_skip(cur_val);
             break;
         }
-    }
-    break;
-  default:
-    {
-      print_err("You can't use `");
-      print_cmd_chr(cur_cmd, cur_chr);
-      print_string("' after ");
-      print_esc("the");
-      help1("I'm forgetting what you said and using zero instead.");
-      error();
-      if (level != 5)
+        
+        cur_val_level = m;
+      }
+      break;
+
+    case last_item:
+      if (cur_chr > glue_val)
       {
-        cur_val = 0;
-        cur_val_level = 1;
+        if (cur_chr == input_line_no_code)
+          cur_val = line;
+        else
+          cur_val = last_badness;
+
+        cur_val_level = int_val;
       }
       else
       {
-        cur_val = 0;
-        cur_val_level = 0;
+        if (cur_chr == glue_val)
+          cur_val = zero_glue;
+        else
+          cur_val = 0;
+
+        cur_val_level = cur_chr;
+
+        if (!(tail >= hi_mem_min) && (mode != 0))
+          switch(cur_chr)
+          {
+            case int_val:
+              if (type(tail) == penalty_node)
+                cur_val = penalty(tail);
+              break;
+
+            case dimen_val:
+              if (type(tail) == kern_node)
+                cur_val = width(tail);
+              break;
+
+            case glue_val:
+              if (type(tail) == glue_node)
+              {
+                cur_val = glue_ptr(tail);
+
+                if (subtype(tail) == mu_glue)
+                  cur_val_level = mu_val;
+              }
+              break;
+          }
+        else if ((mode == 1) && (tail == cur_list.head_field))
+          switch (cur_chr)
+          {
+            case int_val:
+              cur_val = last_penalty;
+              break;
+
+            case dimen_val:
+              cur_val = last_kern;
+              break;
+
+            case glue_val:
+              if (last_glue != empty_flag)
+                cur_val = last_glue;
+              break;
+          }
       }
-    }
-    break;
+      break;
+
+    default:
+      {
+        print_err("You can't use `");
+        print_cmd_chr(cur_cmd, cur_chr);
+        print_string("' after ");
+        print_esc("the");
+        help1("I'm forgetting what you said and using zero instead.");
+        error();
+
+        if (level != tok_val)
+        {
+          cur_val = 0;
+          cur_val_level = dimen_val;
+        }
+        else
+        {
+          cur_val = 0;
+          cur_val_level = int_val;
+        }
+      }
+      break;
   }
-  while (cur_val_level > level) {
-    if (cur_val_level == 2)
-      cur_val = mem[cur_val + 1].cint;
-    else if (cur_val_level == 3)
-    {
+
+  while (cur_val_level > level)
+  {
+    if (cur_val_level == glue_val)
+      cur_val = width(cur_val);
+    else if (cur_val_level == mu_val)
       mu_error();
-    }
+
     decr(cur_val_level);
   }
+
   if (negative)
     if (cur_val_level >= 2)
     {
       cur_val = new_spec(cur_val);
+
       {
-        mem[cur_val + 1].cint = - (integer) mem[cur_val + 1].cint;
-        mem[cur_val + 2].cint = - (integer) mem[cur_val + 2].cint;
-        mem[cur_val + 3].cint = - (integer) mem[cur_val + 3].cint;
+        width(cur_val) = - (integer) width(cur_val);
+        stretch(cur_val) = - (integer) stretch(cur_val);
+        shrink(cur_val) = - (integer) shrink(cur_val);
       }
     }
-    else cur_val = - (integer) cur_val;
-  else if ((cur_val_level >= 2) && (cur_val_level <= 3))
-    incr(mem[cur_val].hh.v.RH);
+    else
+      cur_val = - (integer) cur_val;
+  else if ((cur_val_level >= glue_val) && (cur_val_level <= mu_val))
+    add_glue_ref(cur_val);
 }
-
 /*****************************************************************************/
-
 /* Moved here to avoid question about pragma optimize 96/Sep/12 */
 /* sec 0341 */
 void get_next (void)
@@ -1905,7 +2108,8 @@ void get_next (void)
   char d;
 
 lab20:
-  cur_cs = 0; 
+  cur_cs = 0;
+
   if (cur_input.state_field != token_list)
   {
 lab25:
@@ -1915,6 +2119,7 @@ lab25:
       incr(cur_input.loc_field);
 lab21:
       cur_cmd = cat_code(cur_chr);
+
       switch (cur_input.state_field + cur_cmd)
       {
         case any_state_plus(ignore):
@@ -1922,6 +2127,7 @@ lab21:
         case new_line + spacer:
           goto lab25;
           break;
+
         case any_state_plus(escape):
           {
             if (cur_input.loc_field > cur_input.limit_field)
@@ -1933,6 +2139,7 @@ lab26:
               cur_chr = buffer[k];
               cat = cat_code(cur_chr);
               incr(k);
+
               if (cat == letter)
                 cur_input.state_field = skip_blanks;
               else if (cat == spacer)
@@ -1942,57 +2149,69 @@ lab26:
 
               if ((cat == letter) && (k <= cur_input.limit_field))
               {
-                do {
-                  cur_chr = buffer[k];
-                  cat = cat_code(cur_chr);
-                  incr(k);
-                } while(!((cat != letter) || (k > cur_input.limit_field)));
+                do
+                  {
+                    cur_chr = buffer[k];
+                    cat = cat_code(cur_chr);
+                    incr(k);
+                  }
+                while(!((cat != letter) || (k > cur_input.limit_field)));
+
                 {
                   if (buffer[k]== cur_chr)
                     if (cat == sup_mark)
                       if (k < cur_input.limit_field)
                       {
                         c = buffer[k + 1];
+
                         if (c < 128)
                         {
                           d = 2;
-                          if ((((c >= 48) && (c <= 57)) ||
-                                ((c >= 97) && (c <= 102))))
+                          if ((((c >= 48) && (c <= 57)) || ((c >= 97) && (c <= 102))))
                             if (k + 2 <= cur_input.limit_field)
                             {
                               cc = buffer[k + 2];
-                              if ((((cc >= 48) && (cc <= 57)) ||
-                                    ((cc >= 97) && (cc <= 102))))
+
+                              if ((((cc >= 48) && (cc <= 57)) || ((cc >= 97) && (cc <= 102))))
                                 incr(d);
                             }
+
                           if (d > 2)
                           {
                             if (c <= 57)
                               cur_chr = c - 48;
                             else
                               cur_chr = c - 87;
+
                             if (cc <= 57)
                               cur_chr = 16 * cur_chr + cc - 48;
                             else
                               cur_chr = 16 * cur_chr + cc - 87;
+
                             buffer[k - 1] = cur_chr;
                           }
                           else if (c < 64)
                             buffer[k - 1] = c + 64;
                           else
                             buffer[k - 1] = c - 64;
+
                           cur_input.limit_field = cur_input.limit_field - d;
                           first = first - d;
-                          while (k <= cur_input.limit_field) {
+
+                          while (k <= cur_input.limit_field)
+                          {
                             buffer[k] = buffer[k + d];
                             incr(k);
                           }
+
                           goto lab26;
                         }
                       }
                 }
+
                 if (cat != letter)
                   decr(k);
+
                 if (k > cur_input.loc_field + 1)
                 {
                   cur_cs = id_lookup(cur_input.loc_field, k - cur_input.loc_field);
@@ -2007,37 +2226,43 @@ lab26:
                     if (k < cur_input.limit_field)
                     {
                       c = buffer[k + 1];
+
                       if (c < 128)             /* ? */
                       {
                         d = 2;
-                        if ((((c >= 48) && (c <= 57)) ||
-                              ((c >= 97) && (c <= 102))))
+                        if ((((c >= 48) && (c <= 57)) || ((c >= 97) && (c <= 102))))
                           if (k + 2 <= cur_input.limit_field)
                           {
                             cc = buffer[k + 2];
-                            if ((((cc >= 48) && (cc <= 57)) ||
-                                  ((cc >= 97) && (cc <= 102))))
+
+                            if ((((cc >= 48) && (cc <= 57)) || ((cc >= 97) && (cc <= 102))))
                               incr(d);
                           }
+
                         if (d > 2)
                         {
                           if (c <= 57)
                             cur_chr = c - 48;
                           else
                             cur_chr = c - 87;
+
                           if (cc <= 57)          /* cc may be used without ... */
                             cur_chr = 16 * cur_chr + cc - 48;
                           else
                             cur_chr = 16 * cur_chr + cc - 87;
+
                           buffer[k - 1] = cur_chr;
                         }
                         else if (c < 64)
                           buffer[k - 1] = c + 64;
                         else
                           buffer[k - 1] = c - 64;
+
                         cur_input.limit_field = cur_input.limit_field - d;
                         first = first - d;
-                        while (k <= cur_input.limit_field) {
+
+                        while (k <= cur_input.limit_field)
+                        {
                           buffer[k] = buffer[k + d];
                           incr(k);
                         }
@@ -2053,11 +2278,10 @@ lab40:
             cur_chr = equiv(cur_cs);
             
             if (cur_cmd >= outer_call)
-            {
               check_outer_validity();
-            }
           }
           break;
+
         case any_state_plus(active_char):
           {
             cur_cs = cur_chr + active_base;
@@ -2066,50 +2290,57 @@ lab40:
             cur_input.state_field = mid_line;
             
             if (cur_cmd >= outer_call)
-            {
               check_outer_validity();
-            }
           }
           break;
+
         case any_state_plus(sup_mark):
           {
             if (cur_chr == buffer[cur_input.loc_field])
               if (cur_input.loc_field < cur_input.limit_field)
               {
                 c = buffer[cur_input.loc_field + 1];
+
                 if (c < 128)
                 {
                   cur_input.loc_field = cur_input.loc_field + 2;
-                  if ((((c >= 48) && (c <= 57)) ||
-                        ((c >= 97) && (c <= 102))))
+
+                  if ((((c >= 48) && (c <= 57)) || ((c >= 97) && (c <= 102))))
                     if (cur_input.loc_field <= cur_input.limit_field)
                     {
                       cc = buffer[cur_input.loc_field];
-                      if ((((cc >= 48) && (cc <= 57)) ||
-                            ((cc >= 97) && (cc <= 102))))
+
+                      if ((((cc >= 48) && (cc <= 57)) || ((cc >= 97) && (cc <= 102))))
                       {
                         incr(cur_input.loc_field);
+
                         if (c <= 57)
                           cur_chr = c - 48;
                         else
                           cur_chr = c - 87;
+
                         if (cc <= 57)
                           cur_chr = 16 * cur_chr + cc - 48;
                         else
                           cur_chr = 16 * cur_chr + cc - 87;
+
                         goto lab21;
                       }
                     }
+
                   if (c < 64)
                     cur_chr = c + 64;
                   else
                     cur_chr = c - 64;
+
                   goto lab21;
                 }
               }
-            cur_input.state_field = mid_line;
+
+              cur_input.state_field = mid_line;
           }
           break;
+
         case any_state_plus(invalid_char):
           {
             print_err("Text line contains an invalid character");
@@ -2121,12 +2352,14 @@ lab40:
             goto lab20;
           }
           break;
+
         case mid_line + spacer:
           {
             cur_input.state_field = skip_blanks;
             cur_chr = ' ';
           }
           break;
+
         case mid_line + car_ret:
           {
             cur_input.loc_field = cur_input.limit_field + 1;
@@ -2134,6 +2367,7 @@ lab40:
             cur_chr = ' ';
           }
           break;
+
         case skip_blanks + car_ret:
         case any_state_plus(comment):
           {
@@ -2141,6 +2375,7 @@ lab40:
             goto lab25;
           }
           break;
+
         case new_line + car_ret:
           {
             cur_input.loc_field = cur_input.limit_field + 1;
@@ -2149,14 +2384,14 @@ lab40:
             cur_chr = equiv(cur_cs);
             
             if (cur_cmd >= outer_call)
-            {
               check_outer_validity();
-            }
           }
           break;
+
         case mid_line + left_brace:
           incr(align_state);
           break;
+
         case skip_blanks + left_brace:
         case new_line + left_brace:
           {
@@ -2164,9 +2399,11 @@ lab40:
             incr(align_state);
           }
           break;
+
         case mid_line + right_brace:
           decr(align_state);
           break;
+
         case skip_blanks + right_brace:
         case new_line + right_brace:
           {
@@ -2174,10 +2411,12 @@ lab40:
             decr(align_state);
           }
           break;
+
         case add_delims_to(skip_blanks):
         case add_delims_to(new_line):
           cur_input.state_field = 1;
           break;
+
         default:
           break;
       }
@@ -2190,12 +2429,11 @@ lab40:
       {
         incr(line);
         first = cur_input.start_field;
+
         if (!force_eof)
         {
           if (input_ln(input_file[cur_input.index_field], true))
-          {
             firm_up_the_line();
-          }
           else
             force_eof = true;
         }
@@ -2212,10 +2450,12 @@ lab40:
           check_outer_validity();
           goto lab20;
         }
+
         if ((end_line_char < 0) || (end_line_char > 255))
           decr(cur_input.limit_field);
         else
           buffer[cur_input.limit_field] = end_line_char;
+
         first = cur_input.limit_field + 1;
         cur_input.loc_field = cur_input.start_field;
       }
@@ -2227,31 +2467,40 @@ lab40:
           cur_chr = 0;
           return;
         }
+
         if (input_ptr > 0)
         {
           end_file_reading();
           goto lab20;
         }
+
         if (selector < log_only)
           open_log_file();
+
         if (interaction > nonstop_mode)
         {
           if ((end_line_char < 0) || (end_line_char > 255))
             incr(cur_input.limit_field);
+
           if (cur_input.limit_field == cur_input.start_field)
             print_nl("(Please type a command or say `\\end')");
+
           print_ln();
           first = cur_input.start_field;
+
           {
             ;
             print_string("*");
             term_input("*", 0);
           }
+
           cur_input.limit_field = last;
+
           if ((end_line_char < 0) || (end_line_char > 255))
             decr(cur_input.limit_field);
           else
             buffer[cur_input.limit_field]= end_line_char;
+
           first = cur_input.limit_field + 1;
           cur_input.loc_field = cur_input.start_field;
         }
@@ -2261,12 +2510,14 @@ lab40:
           return;     // abort_flag set
         }
       }
+
       {
         if (interrupt != 0)
         {
           pause_for_instructions();
         }
       }
+
       goto lab25;
     }
   }
@@ -2274,15 +2525,17 @@ lab40:
   {
     t = info(cur_input.loc_field);
     cur_input.loc_field = link(cur_input.loc_field);
-    if (t >= 4095)
+
+    if (t >= cs_token_flag)
     {
-      cur_cs = t - 4095;
+      cur_cs = t - cs_token_flag;
       cur_cmd = eq_type(cur_cs);
       cur_chr = equiv(cur_cs);
+
       if (cur_cmd >= outer_call)
         if (cur_cmd == dont_expand)
         {
-          cur_cs = info(cur_input.loc_field) - 4095;
+          cur_cs = info(cur_input.loc_field) - cs_token_flag;
           cur_input.loc_field = 0;
           cur_cmd = eq_type(cur_cs);
           cur_chr = equiv(cur_cs);
@@ -2290,7 +2543,7 @@ lab40:
           if (cur_cmd > max_command)
           {
             cur_cmd = relax;
-            cur_chr = 257;
+            cur_chr = no_expand_flag;
           }
         }
         else
@@ -2302,20 +2555,24 @@ lab40:
     {
       cur_cmd = t / 256;
       cur_chr = t % 256;
+
       switch (cur_cmd)
       {
         case left_brace:
           incr(align_state);
           break;
+
         case right_brace:
           decr(align_state);
           break;
+
         case out_param:
           {
             begin_token_list(param_stack[cur_input.limit_field + cur_chr - 1], parameter);
             goto lab20;
           }
           break;
+
         default:
           break;
       }
@@ -2326,6 +2583,7 @@ lab40:
     end_token_list();
     goto lab20;
   }
+
   if (cur_cmd <= car_ret)
     if (cur_cmd >= tab_mark)
       if (align_state == 0)
@@ -2335,14 +2593,17 @@ lab40:
           fatal_error("(interwoven alignment preambles are not allowed)");
           return;     // abort_flag set
         }
+
         cur_cmd = extra_info(cur_align);
         extra_info(cur_align) = cur_chr;
+
         if (cur_cmd == omit)
           begin_token_list(omit_template, v_template);
         else
           begin_token_list(v_part(cur_align), v_template);
+
         align_state = 1000000L;
         goto lab20;
       }
 }
-#pragma optimize ("", on)             /* 96/Sep/12 */
+#pragma optimize ("", on)             /* 96/Sep/12 */
\ No newline at end of file
index c8c5f45..1922811 100644 (file)
@@ -1415,26 +1415,26 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 #define span_count      subtype
 /* sec 0162 */
 #define zero_glue         mem_bot // 0
-#define fil_glue          zero_glue + glue_spec_size // 4
-#define fill_glue         fil_glue + glue_spec_size // 8
-#define ss_glue           fill_glue + glue_spec_size // 12
-#define fil_neg_glue      ss_glue + glue_spec_size // 16
-#define lo_mem_stat_max   fil_neg_glue + glue_spec_size - 1 // 19
+#define fil_glue          (zero_glue + glue_spec_size) // 4
+#define fill_glue         (fil_glue + glue_spec_size) // 8
+#define ss_glue           (fill_glue + glue_spec_size) // 12
+#define fil_neg_glue      (ss_glue + glue_spec_size) // 16
+#define lo_mem_stat_max   (fil_neg_glue + glue_spec_size - 1) // 19
 #define page_ins_head     mem_top
-#define contrib_head      mem_top - 1
-#define page_head         mem_top - 2
-#define temp_head         mem_top - 3
-#define hold_head         mem_top - 4
-#define adjust_head       mem_top - 5
-#define active            mem_top - 7
-#define align_head        mem_top - 8
-#define end_span          mem_top - 9
-#define omit_template     mem_top - 10
-#define null_list         mem_top - 11
-#define lig_trick         mem_top - 12
-#define garbage           mem_top - 12
-#define backup_head       mem_top - 13
-#define hi_mem_stat_min   mem_top - 13
+#define contrib_head      (mem_top - 1)
+#define page_head         (mem_top - 2)
+#define temp_head         (mem_top - 3)
+#define hold_head         (mem_top - 4)
+#define adjust_head       (mem_top - 5)
+#define active            (mem_top - 7)
+#define align_head        (mem_top - 8)
+#define end_span          (mem_top - 9)
+#define omit_template     (mem_top - 10)
+#define null_list         (mem_top - 11)
+#define lig_trick         (mem_top - 12)
+#define garbage           (mem_top - 12)
+#define backup_head       (mem_top - 13)
+#define hi_mem_stat_min   (mem_top - 13)
 #define hi_mem_stat_usage 14
 /* sec 0200 */
 #define token_ref_count(a) info(a)
@@ -1559,30 +1559,30 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 #define set_interaction 100
 #define max_command 100
 /* sec 0210 */
-#define undefined_cs    max_command + 1
-#define expand_after    max_command + 2
-#define no_expand       max_command + 3
-#define input           max_command + 4
-#define if_test         max_command + 5
-#define fi_or_else      max_command + 6
-#define cs_name         max_command + 7
-#define convert         max_command + 8
-#define the             max_command + 9
-#define top_bot_mark    max_command + 10
-#define call            max_command + 11
-#define long_call       max_command + 12
-#define outer_call      max_command + 13
-#define long_outer_call max_command + 14
-#define end_template    max_command + 15
-#define dont_expand     max_command + 16
-#define glue_ref        max_command + 17
-#define shape_ref       max_command + 18
-#define box_ref         max_command + 19 
-#define data            max_command + 20
+#define undefined_cs    (max_command + 1)
+#define expand_after    (max_command + 2)
+#define no_expand       (max_command + 3)
+#define input           (max_command + 4)
+#define if_test         (max_command + 5)
+#define fi_or_else      (max_command + 6)
+#define cs_name         (max_command + 7)
+#define convert         (max_command + 8)
+#define the             (max_command + 9)
+#define top_bot_mark    (max_command + 10)
+#define call            (max_command + 11)
+#define long_call       (max_command + 12)
+#define outer_call      (max_command + 13)
+#define long_outer_call (max_command + 14)
+#define end_template    (max_command + 15)
+#define dont_expand     (max_command + 16)
+#define glue_ref        (max_command + 17)
+#define shape_ref       (max_command + 18)
+#define box_ref         (max_command + 19) 
+#define data            (max_command + 20)
 /* sec 0211 */
 #define vmode 1
-#define hmode vmode + max_command + 1
-#define mmode hmode + max_command + 1
+#define hmode (vmode + max_command + 1)
+#define mmode (hmode + max_command + 1)
 /* sec 0212 */
 #define ignore_depth -65536000L
 /* sec 0213 */
@@ -1887,6 +1887,7 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 /* sec 0256 */
 //#define next
 #define text(a)         hash[a].v.RH
+#define next(a)         hash[a].v.LH
 #define hash_is_full    (hash_used == hash_base)
 #define font_id_text(a) text(font_id_base + a)
 /* sec 0268 */
@@ -1919,7 +1920,7 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 /* sec 0289 */
 #define cs_token_flag     07777 // 4095
 #define left_brace_token  0400  // 256  = 2^8 * left_brace
-#define left_brace_limit  0400  // 512  = 2^8 * (left_brace + 1)
+#define left_brace_limit  01000 // 512  = 2^8 * (left_brace + 1)
 #define right_brace_token 01000 // 512  = 2^8 * right_brace
 #define right_brace_limit 01400 // 768  = 2^8 * (right_brace + 1)
 #define math_shift_token  01400 // 768  = 2^8 * math_shift
@@ -1960,6 +1961,9 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 #define every_cr_text      13
 #define mark_text          14
 #define write_text         15
+/* sec 0323 */
+#define back_list(a) begin_token_list(a, backed_up)
+#define ins_list(a)  begin_token_list(a, inserted)
 /* sec 0344 */
 #define any_state_plus(a) mid_line + (a): case skip_blanks + (a): case new_line + (a)
 /* sec 0347 */
@@ -1970,6 +1974,8 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
   case (a) + sub_mark:   \
   case (a) + letter:     \
   case (a) + other_char
+/* sec 0358 */
+#define no_expand_flag 257
 /* sec 0382 */
 #define top_mark_code         0
 #define first_mark_code       1
@@ -2066,7 +2072,7 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 #define char_tag(a)       (a.b2 % 4)
 /* sec 0557 */
 #define char_kern(a, b)        font_info[kern_base[a] + 256 * op_byte(b) + rem_byte(b)].cint
-#define kern_base_offset       256 * (128 + min_quarterword)
+#define kern_base_offset       (256 * (128 + min_quarterword))
 #define lig_kern_start(a, b)   lig_kern_base[a] + rem_byte(b)
 #define lig_kern_restart(a, b) lig_kern_base[a] + 256 * op_byte(b) + rem_byte(b) + 32768 - kern_base_offset
 /* sec 0558 */
@@ -2096,9 +2102,9 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 #define extra_info(a) info((a) + list_offset)
 /* sec 0681 */
 #define noad_size      4
-#define nucleus(a)     (a) + 1
-#define supscr(a)      (a) + 2
-#define subscr(a)      (a) + 3
+#define nucleus(a)     ((a) + 1)
+#define supscr(a)      ((a) + 2)
+#define subscr(a)      ((a) + 3)
 #define math_type      link
 #define fam            font
 #define math_char      1
@@ -2117,11 +2123,11 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 #define limits    1
 #define no_limits 2
 /* sec 0683 */
-#define left_delimiter(a)  (a) + 4
-#define right_delimiter(a) (a) + 5
-#define radical_noad       inner_noad + 1 // 24
+#define left_delimiter(a)  ((a) + 4)
+#define right_delimiter(a) ((a) + 5)
+#define radical_noad       (inner_noad + 1) // 24
 #define radical_noad_size  5
-#define fraction_noad      radical_noad + 1 // 25
+#define fraction_noad      (radical_noad + 1) // 25
 #define fraction_noad_size 6
 #define small_fam(a)       mem[(a)].qqqq.b0
 #define small_char(a)      mem[(a)].qqqq.b1
@@ -2132,18 +2138,18 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 #define numerator          supscr
 #define denominator        subscr
 /* sec 0687 */
-#define under_noad        fraction_noad + 1 // 26
-#define over_noad         under_noad + 1    // 27
-#define accent_noad       over_noad + 1     // 28
+#define under_noad        (fraction_noad + 1) // 26
+#define over_noad         (under_noad + 1   ) // 27
+#define accent_noad       (over_noad + 1    ) // 28
 #define accent_noad_size  5
 #define accent_chr(a)     (a) + 4
-#define vcenter_noad      accent_noad + 1   // 29
-#define left_noad         vcenter_noad + 1  // 30
-#define right_noad        left_noad + 1     // 31
+#define vcenter_noad      (accent_noad + 1  ) // 29
+#define left_noad         (vcenter_noad + 1 ) // 30
+#define right_noad        (left_noad + 1    ) // 31
 #define delimiter         nucleus
 #define script_allowed(a) ((type(a) >= ord_noad) && (type(a) < left_noad))
 /* sec 0688 */
-#define style_node          unset_node + 1
+#define style_node          (unset_node + 1)
 #define style_node_size     3
 #define display_style       0
 #define text_style          2
@@ -2151,7 +2157,7 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 #define script_script_style 6
 #define cramped             1
 /* sec 0689 */
-#define choice_node            unset_node + 2
+#define choice_node            (unset_node + 2)
 #define display_mlist(a)       info(a + 1)
 #define text_mlist(a)          link(a + 1)
 #define script_mlist(a)        info(a + 2)
@@ -2181,16 +2187,16 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 #define axis_height(a)      mathsy(22, a)
 #define total_mathsy_params 22
 /* sec 0702 */
-#define cramped_style(a) 2 * ((a) / 2) + cramped
-#define sub_style(a)     2 * ((a) / 4) + script_style + cramped
-#define sup_stype(a)     2 * ((a) / 4) + script_style + ((a) % 2)
-#define num_style(a)     (a) + 2 - 2 * ((a) / 6)
-#define denom_style(a)   2 * ((a) / 2) + cramped + 2 - 2 * ((a) / 6)
+#define cramped_style(a) (2 * ((a) / 2) + cramped)
+#define sub_style(a)     (2 * ((a) / 4) + script_style + cramped)
+#define sup_stype(a)     (2 * ((a) / 4) + script_style + ((a) % 2))
+#define num_style(a)     ((a) + 2 - 2 * ((a) / 6))
+#define denom_style(a)   (2 * ((a) / 2) + cramped + 2 - 2 * ((a) / 6))
 /* sec 0780 */
 #define span_code          256
 #define cr_code            257
-#define cr_cr_code         cr_code + 1
-#define end_template_token cs_token_flag + frozen_end_template
+#define cr_cr_code         (cr_code + 1)
+#define end_template_token (cs_token_flag + frozen_end_template)
 /* sec 0817 */
 #define tight_fit      3
 #define loose_fit      1
index 5261e42..e3a498d 100644 (file)
@@ -359,7 +359,7 @@ static const char *pool_file_arr[] =
 /* 0588 */  "", //"<mark> ",
 /* 0589 */  "", //"<write> ",
 /* 0590 */  "", //"input stack size",
-/* 0591 */  "", //"write",
+/* 0591 */  "write",
 /* 0592 */  "", //"(interwoven alignment preambles are not allowed)",
 /* 0593 */  "", //"text input levels",
 /* 0594 */  "", //"par",
@@ -1047,8 +1047,8 @@ static const char *pool_file_arr[] =
 /* 1276 */  "", //"(see the transcript file for additional information)",
 /* 1277 */  "", //"(\\dump is performed only by INITEX)",
 /* 1278 */  "debug # (-1 to exit):",
-/* 1279 */  "", //"openout",
-/* 1280 */  "", //"closeout",
+/* 1279 */  "openout",
+/* 1280 */  "closeout",
 /* 1281 */  "", //"special",
 /* 1282 */  "", //"immediate",
 /* 1283 */  "", //"setlanguage",