OSDN Git Service

pre-pTeX: tex3.c, tex4.c.
authormaqiyuan <maqiyuan@users.sourceforge.jp>
Thu, 24 Apr 2014 15:21:01 +0000 (23:21 +0800)
committermaqiyuan <maqiyuan@users.sourceforge.jp>
Thu, 24 Apr 2014 15:21:01 +0000 (23:21 +0800)
src/texsourc/tex3.c
src/texsourc/tex4.c
src/texsourc/tex5.c
src/texsourc/tex9.c
src/texsourc/texd.h
src/texsourc/texmf.h

index 3645368..49fff01 100644 (file)
@@ -36,19 +36,21 @@ void scan_int (void)
   OKsofar = true;
   negative = false;
 
-  do {
-    do 
+  do
+    {
+      do 
+        {
+          get_x_token();
+        }
+      while (!(cur_cmd != spacer));
+
+      if (cur_tok == other_token + '-')
       {
-        get_x_token();
+        negative = !negative;
+        cur_tok = other_token + '+';
       }
-    while (!(cur_cmd != spacer));
-
-    if (cur_tok == other_token + '-')
-    {
-      negative = !negative;
-      cur_tok = other_token + '+';
     }
-  while (!(cur_tok != other_token + '+'));
+  while (!(cur_tok != other_token + '+'));
 
   if (cur_tok == alpha_token)
   {
@@ -178,19 +180,22 @@ void scan_dimen_(bool mu, bool inf, bool shortcut)
   if (!shortcut)
   {
     negative = false;
-    do {
-      do
-        {
-          get_x_token();
-        }
-      while (!(cur_cmd != spacer));
 
-      if (cur_tok == other_token + '-')
+    do
       {
-        negative = ! negative;
-        cur_tok = other_token + '+';
+        do
+          {
+            get_x_token();
+          }
+        while (!(cur_cmd != spacer));
+
+        if (cur_tok == other_token + '-')
+        {
+          negative = ! negative;
+          cur_tok = other_token + '+';
+        }
       }
-    while (!(cur_tok != other_token + '+'));
+    while (!(cur_tok != other_token + '+'));
 
     if ((cur_cmd >= min_internal) && (cur_cmd <= max_internal))
     {
@@ -338,6 +343,7 @@ lab31:
     {
       scan_something_internal(dimen_val, false);
     }
+
     v = cur_val;
     goto lab40;
   }
@@ -499,9 +505,10 @@ void scan_glue_(small_number level)
 
   do
     {
-      do {
+      do
+        {
           get_x_token();
-      }
+        }
       while (!(cur_cmd != spacer));
 
       if (cur_tok == other_token + '-')
@@ -567,6 +574,7 @@ halfword scan_rule_spec (void)
   halfword q;
 
   q = new_rule();
+
   if (cur_cmd == vrule)
     width(q) = default_rule;
   else
@@ -624,9 +632,11 @@ halfword str_toks_(pool_pointer b)
     {
       {
         q = avail;
+
         if (q == 0)
           q = get_avail();
-        else {
+        else
+        {
           avail = mem[q].hh.v.RH;
           mem[q].hh.v.RH = 0;
 #ifdef STAT
@@ -746,12 +756,14 @@ void conv_toks (void)
   pool_pointer b;
 
   c = cur_chr;
+
   switch (c)
   {
     case number_code:
     case roman_numeral_code:
       scan_int();
       break;
+
     case string_code:
     case meaning_code:
       savescannerstatus = scanner_status;
@@ -759,14 +771,17 @@ void conv_toks (void)
       get_token();
       scanner_status = savescannerstatus;
       break;
+
     case font_name_code:
       scan_font_ident();
       break;
+
     case job_name_code:
       if (job_name == 0)
         open_log_file();
       break;
   }
+
   old_setting = selector;
   selector = new_string;
   b = pool_ptr;
@@ -776,18 +791,22 @@ void conv_toks (void)
     case number_code:
       print_int(cur_val);
       break;
+
     case roman_numeral_code:
       print_roman_int(cur_val);
       break;
+
     case string_code:
       if (cur_cs != 0)
         sprint_cs(cur_cs);
       else
         print_char(cur_chr);
       break;
+
     case meaning_code:
       print_meaning();
       break;
+
     case font_name_code:
       print(font_name[cur_val]);
 
@@ -798,10 +817,12 @@ void conv_toks (void)
         print_string("pt");
       }
       break;
+
     case job_name_code:
       print(job_name);
       break;
   }
+
   selector = old_setting;
   link(garbage) = str_toks(b);
   begin_token_list(link(temp_head), 4);
@@ -892,7 +913,7 @@ lab31:
     {
       q = get_avail();
       mem[p].hh.v.RH = q;
-      mem[q].hh.v.LH = 3584;
+      mem[q].hh.v.LH = end_match_token;
       p = q;
     }
 
@@ -1015,6 +1036,7 @@ void read_toks_(integer n, halfword r)
   def_ref = get_avail();
   token_ref_count(def_ref) = 0;
   p = def_ref;
+
   {
     q = get_avail();
     mem[p].hh.v.RH = q;
@@ -1030,87 +1052,102 @@ void read_toks_(integer n, halfword r)
   s = align_state;
   align_state = 1000000L;
 
-  do {
-    begin_file_reading();
-    cur_input.name_field = m + 1;
+  do
+    {
+      begin_file_reading();
+      cur_input.name_field = m + 1;
 
-    if (read_open[m] == closed)
-      if (interaction > nonstop_mode)
-        if (n < 0)
+      if (read_open[m] == closed)
+        if (interaction > nonstop_mode)
+          if (n < 0)
+          {
+            print_string("");
+            term_input("", 0);
+          }
+          else
+          {
+            print_ln();
+            sprint_cs(r);
+            {
+              print_string("=");
+              term_input("=", 0);
+            }
+            n = -1;
+          }
+        else
         {
-          print_string("");
-          term_input("", 0);
+          fatal_error("*** (cannot \\read from terminal in nonstop modes)");
+          return;     // abort_flag set
         }
+      else if (read_open[m] == 1)
+        if (input_ln(read_file[m], false))
+          read_open[m] = 0;
         else
         {
-          print_ln();
-          sprint_cs(r);
-          {
-            print_string("=");
-            term_input("=", 0);
-          }
-          n = -1;
+          (void) a_close(read_file[m]);
+          read_open[m] = 2;
         }
       else
       {
-        fatal_error("*** (cannot \\read from terminal in nonstop modes)");
-        return;     // abort_flag set
+        if (!input_ln(read_file[m], true))
+        {
+          (void) a_close(read_file[m]);
+          read_open[m] = 2;
+
+          if (align_state != 1000000L)
+          {
+            runaway();
+            print_err("File ended within ");
+            print_esc("read");
+            help1("This \\read has unbalanced braces.");
+            align_state = 1000000L;
+            error();
+          }
+        }
       }
-    else if (read_open[m] == 1)
-      if (input_ln(read_file[m], false))
-        read_open[m] = 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;
+      cur_input.state_field = new_line;
+
+      while (true)
       {
-        (void) a_close(read_file[m]);
-        read_open[m] = 2;
-      }
-    else
-    {
-      if (!input_ln(read_file[m], true))
-      {
-        (void) a_close(read_file[m]);
-        read_open[m] = 2;
-        if (align_state != 1000000L)
+        get_token();
+
+        if (cur_tok == 0)
+          goto lab30;
+
+        if (align_state < 1000000L)
         {
-          runaway();
-          print_err("File ended within ");
-          print_esc("read");
-          help1("This \\read has unbalanced braces.");
+          do
+            {
+              get_token();
+            }
+          while(!(cur_tok == 0));
+
           align_state = 1000000L;
-          error();
+          goto lab30;
+        }
+
+        {
+          q = get_avail();
+          mem[p].hh.v.RH = q;
+          mem[q].hh.v.LH = cur_tok;
+          p = q;
         }
       }
-    }
-    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;
-    cur_input.state_field = new_line;
-    while (true) {
-      get_token();
-      if (cur_tok == 0)
-        goto lab30;
-      if (align_state < 1000000L)
-      {
-        do {
-          get_token();
-        } while(!(cur_tok == 0));
-        align_state = 1000000L;
-        goto lab30;
-      }
-      {
-        q = get_avail();
-        mem[p].hh.v.RH = q;
-        mem[q].hh.v.LH = cur_tok;
-        p = q;
-      }
-    }
 lab30:
-    end_file_reading();
-  } while(!(align_state == 1000000L));
+      end_file_reading();
+    }
+  while(!(align_state == 1000000L));
+
   cur_val = def_ref;
   scanner_status = normal;
   align_state = s;
@@ -1125,12 +1162,16 @@ void pass_text (void)
   scanner_status = skipping;
   l = 0;
   skip_line = line;
-  while (true) {
+
+  while (true)
+  {
     get_next();
+
     if (cur_cmd == fi_or_else)
     {
       if (l == 0)
         goto lab30;
+
       if (cur_chr == 2)
         decr(l);
     }
@@ -1144,23 +1185,28 @@ lab30:
 void change_if_limit_(small_number l, halfword p)
 {
   halfword q;
+
   if (p == cond_ptr)
     if_limit = l;
   else
   {
     q = cond_ptr;
-    while (true) {
+
+    while (true)
+    {
       if (q == 0)
       {
         confusion("if");
         return;       // abort_flag set
       }
+
       if (link(q) == p)
       {
         type(p) = l;
         return;
       }
-      q = mem[q].hh.v.RH;
+
+      q = link(q);
     }
   }
 }
@@ -1175,6 +1221,7 @@ void conditional (void)
   small_number savescannerstatus;
   halfword savecondptr;
   small_number thisif;
+
   {
     p = get_node(if_node_size);
     link(p) = cond_ptr;
@@ -1186,8 +1233,10 @@ void conditional (void)
     if_limit = if_code;
     if_line = line;
   }
+
   savecondptr = cond_ptr;
   thisif = cur_chr;
+
   switch (thisif)
   {
     case if_char_code:
@@ -1195,13 +1244,15 @@ void conditional (void)
       {
         {
           get_x_token();
+
           if (cur_cmd == relax)
-            if (cur_chr == 257)  /* if cur_chr = no_expand_flag then ... p.506 */
+            if (cur_chr == no_expand_flag)
             {
               cur_cmd = active_char;
-              cur_chr = cur_tok - 4096;
+              cur_chr = cur_tok - cs_token_flag - active_base;
             }
         }
+
         if ((cur_cmd > active_char) || (cur_chr > 255))
         {
           m = relax;
@@ -1214,24 +1265,28 @@ void conditional (void)
         }
         {
           get_x_token();
+
           if (cur_cmd == relax)
-            if (cur_chr == 257)  /* if cur_chr = no_expand_flag then ... p.506 */
+            if (cur_chr == no_expand_flag)
             {
               cur_cmd = active_char;
-              cur_chr = cur_tok - 4096;
+              cur_chr = cur_tok - cs_token_flag - active_base;
             }
         }
+
         if ((cur_cmd > active_char) || (cur_chr > 255))
         {
           cur_cmd = relax;
           cur_chr = 256;
         }
+
         if (thisif == if_char_code)
           b = (n == cur_chr); 
         else
           b = (m == cur_cmd);
       }
       break;
+
     case if_int_code:
     case if_dim_code:
       {
@@ -1239,14 +1294,17 @@ void conditional (void)
           scan_int();
         else
           scan_dimen(false, false, false);
+
         n = cur_val;
         
-        do {
-          get_x_token();
-        } while(!(cur_cmd != spacer));
+        do
+          {
+            get_x_token();
+          }
+        while(!(cur_cmd != spacer));
 
-        if ((cur_tok >= 3132) && (cur_tok <= 3134))
-          r = cur_tok - 3072;
+        if ((cur_tok >= other_token + '<') && (cur_tok <= other_token + '>'))
+          r = cur_tok - other_token;
         else
         {
           print_err("Missing = inserted for ");
@@ -1255,46 +1313,57 @@ void conditional (void)
           back_error();
           r = '=';
         }
+
         if (thisif == if_int_code)
           scan_int();
         else 
           scan_dimen(false, false, false);
+
         switch (r)
         {
           case '<':
             b = (n < cur_val);
             break;
+
           case '=':
             b = (n == cur_val);
             break;
+
           case '>':
             b = (n > cur_val);
             break;
         }
       }
       break;
+
     case if_odd_code:
       scan_int();
       b = odd(cur_val);
       break;
+
     case if_vmode_code:
       b = (abs(mode) == 1);
       break;
+
     case if_hmode_code:
       b = (abs(mode) == 102);
       break;
+
     case if_mmode_code:
       b = (abs(mode) == 203);
       break;
+
     case if_inner_code:
       b = (mode < 0);
       break;
+
     case if_void_code:
     case if_hbox_code:
     case if_vbox_code:
       {
         scan_eight_bit_int();
         p = box(cur_val);
+
         if (thisif == if_void_code)
           b = (p == 0);
         else if (p == 0)
@@ -1305,6 +1374,7 @@ void conditional (void)
           b = (type(p) == vlist_node);
       }
       break;
+
     case ifx_code:
       {
         savescannerstatus = scanner_status;
@@ -1314,6 +1384,7 @@ void conditional (void)
         p = cur_cmd;
         q = cur_chr;
         get_next();
+
         if (cur_cmd != p)
           b = false;
         else if (cur_cmd < call)
@@ -1322,6 +1393,7 @@ void conditional (void)
         {
           p = link(cur_chr);
           q = link(equiv(n));
+
           if (p == q)
             b = true;
           else
@@ -1334,28 +1406,35 @@ void conditional (void)
                 p = link(p);
                 q = link(q);
               }
+
             b = ((p == 0) && (q == 0));
           }
         }
+
         scanner_status = savescannerstatus;
       }
       break;
+
     case if_eof_code:
       {
         scan_four_bit_int();
-        b = (read_open[cur_val] == 2);
+        b = (read_open[cur_val] == closed);
       }
       break;
+
     case if_true_code:
       b = true;
       break;
+
     case if_false_code:
       b = false;
       break;
+
     case if_case_code:
       {
         scan_int();
         n = cur_val;
+
         if (tracing_commands > 1)
         {
           begin_diagnostic();
@@ -1364,8 +1443,11 @@ void conditional (void)
           print_char('}');
           end_diagnostic(false);
         }
-        while (n != 0) {
+
+        while (n != 0)
+        {
           pass_text();
+
           if (cond_ptr == savecondptr)
             if (cur_chr == or_code)
               decr(n);
@@ -1381,31 +1463,40 @@ void conditional (void)
             free_node(p, if_node_size);
           }
         }
+
         change_if_limit(or_code, savecondptr);
         return;
       }
       break;
   }
+
   if (tracing_commands > 1)
   {
     begin_diagnostic();
+
     if (b)
       print_string("{true}");
     else
       print_string("{false}");
+
     end_diagnostic(false);
   }
+
   if (b)     /* b may be used without ... */
   {
     change_if_limit(else_code, savecondptr);
     return;
   }
-  while (true) {
+
+  while (true)
+  {
     pass_text();
+
     if (cond_ptr == savecondptr)
     {
       if (cur_chr != or_code)
         goto lab50;
+
       print_err("Extra ");
       print_esc("or");
       help1("I'm ignoring this; it doesn't match any \\if.");
@@ -1421,6 +1512,7 @@ void conditional (void)
       free_node(p, if_node_size);
     }
   }
+
 lab50:
   if (cur_chr == fi_code)
   {
@@ -1499,10 +1591,10 @@ int find_string (int start, int end)
 
   if (trace_flag)
   {
-    sprintf(log_line, "\nLOOKING for string (str_ptr %d nlen %d) ", str_ptr, end-start);
+    sprintf(log_line, "\nLOOKING for string (str_ptr %d nlen %d) ", str_ptr, end - start);
     s = log_line + strlen(log_line);
     strncpy(s, (const char *) str_pool + start, nlen);
-    strcpy(s+nlen, "");
+    strcpy(s + nlen, "");
     show_line(log_line, 0);
   }
 
@@ -1510,7 +1602,9 @@ int find_string (int start, int end)
 //  code in new_font (tex8.c) will take care of reuse of font name already
   for (k = 0; k < str_ptr - 1; k++)
   {
-    if (length(k) != nlen) continue;
+    if (length(k) != nlen)
+      continue;
+
     if (strncmp((const char *) str_pool + start, (const char *) str_pool + str_start[k], nlen) == 0)
     {
       if (trace_flag)
@@ -1530,7 +1624,7 @@ int find_string (int start, int end)
     sprintf(log_line, "\nNOT FOUND string ");
     s = log_line + strlen(log_line);
     strncpy(s, (const char*)str_pool + start, nlen);
-    strcpy(s+nlen, "\n");
+    strcpy(s + nlen, "\n");
     show_line(log_line, 0);
   }
 
@@ -1551,22 +1645,22 @@ void remove_string (int start, int end)
 
   if (trace_flag)
   {
-    int n = end-start;
+    int n = end - start;
     sprintf(log_line, "\nSTRIPPING OUT %d %d ", n, nlen);
     s = log_line + strlen(log_line);
     strncpy(s, (const char *)str_pool + start, n);
-    strcpy(s+n, "\n");
+    strcpy(s + n, "\n");
     show_line(log_line, 0);
   }
 
   if (nlen > 0)
-    memcpy(str_pool+start, str_pool+end, nlen);
+    memcpy(str_pool + start, str_pool + end, nlen);
 
   pool_ptr = start + nlen;    // poolprt - (end-start);
 }
 
 void show_string (int k)
-{   // debugging code
+{
   int nlen = length(k);
   char *s;
   
@@ -1578,7 +1672,6 @@ void show_string (int k)
   show_line(log_line, 0);
 }
 
-// debugging code
 void show_all_strings (void)
 {
   int k;
@@ -1681,26 +1774,32 @@ void pack_file_name_(str_number n, str_number a, str_number e)
   integer k;
   ASCII_code c;
   pool_pointer j;
+
   k = 0;
 
   for (j = str_start[a]; j <= str_start[a + 1] - 1; j++)
   {
     c = str_pool[j];
     incr(k);
+
     if (k <= PATHMAX)
       name_of_file[k] = xchr[c];
   }
+
   for (j = str_start[n]; j <= str_start[n + 1] - 1; j++)
   {
     c = str_pool[j];
     incr(k);
+
     if (k <= PATHMAX)
       name_of_file[k] = xchr[c];
   }
+
   for (j = str_start[e]; j <= str_start[e + 1] - 1; j++)
   {
     c = str_pool[j];
     incr(k);
+
     if (k <= PATHMAX)
       name_of_file[k] = xchr[c];
   }
@@ -1709,16 +1808,22 @@ void pack_file_name_(str_number n, str_number a, str_number e)
     name_length = k;
   else
     name_length = PATHMAX - 1;
+
 /*  pad it out with spaces ... what for ? in case we modify and forget  ? */
-  for (k = name_length + 1; k <= PATHMAX; k++) name_of_file[k]= ' ';
-  name_of_file[PATHMAX]= '\0';    /* paranoia 94/Mar/24 */
+  for (k = name_length + 1; k <= PATHMAX; k++)
+    name_of_file[k] = ' ';
+
+  name_of_file[PATHMAX] = '\0';    /* paranoia 94/Mar/24 */
+
   {
     name_of_file [name_length+1] = '\0';
+
     if (trace_flag)
     {
       sprintf(log_line, " pack_file_name `%s' (%d) ", name_of_file + 1, name_length); /* debugging */
       show_line(log_line, 0);
     }
+
     name_of_file [name_length + 1] = ' ';
   }
 }
@@ -1731,14 +1836,18 @@ void pack_buffered_name_(small_number n, integer a, integer b)
   integer k;
   ASCII_code c;
   integer j;
+
   if (n + b - a + 5 > PATHMAX)
     b = a + PATHMAX - n - 5;
+
   k = 0;
+
 /*  This loop kicks in when we want the default format name */
   for (j = 1; j <= n; j++)
   {
     c = xord[TEX_format_default[j]];
     incr(k);
+
     if (k <= PATHMAX)
       name_of_file[k] = xchr[c];
   }
@@ -1747,25 +1856,31 @@ void pack_buffered_name_(small_number n, integer a, integer b)
   {
     c = buffer[j];
     incr(k);
+
     if (k <= PATHMAX)
       name_of_file[k] = xchr[c];
   }
+
 /*  This adds the extension from the default format name */
   for (j = format_default_length - 3; j <= format_default_length; j++)
   {
     c = xord[TEX_format_default[j]];
     incr(k);
+
     if (k <= PATHMAX)
       name_of_file[k] = xchr[c];
   }
+
   if (k < PATHMAX)
     name_length = k;
   else
     name_length = PATHMAX - 1;
-/*  pad it out with spaces ... what for ? */
+
+ /*  pad it out with spaces ... what for ? */
   for (k = name_length + 1; k <= PATHMAX; k++)
     name_of_file[k]= ' ';
-  name_of_file[PATHMAX]= '\0';    /* paranoia 94/Mar/24 */
+
+  name_of_file[PATHMAX] = '\0';    /* paranoia 94/Mar/24 */
 }
 /* sec 0525 */
 str_number make_name_string (void)
@@ -1901,9 +2016,11 @@ void show_tex_inputs (void)
   if (v != NULL)
   {
     t = v;
+
     while (*t > '\0')
       print_char(*t++);
   }
+
   print_char(')');
 }
 
@@ -1974,7 +2091,8 @@ void prompt_file_name_(char * s, str_number e)
       }
     }
 
-    while (true) {
+    while (true)
+    {
       if (k == last)
         goto lab30;
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
@@ -1987,6 +2105,7 @@ void prompt_file_name_(char * s, str_number e)
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
       if (!more_name(buffer[k]))
         goto lab30;
+
       incr(k);
     }
 lab30:
@@ -2022,9 +2141,9 @@ void open_log_file (void)
   texmf_log_name = a_make_name_string(log_file);
   selector = log_only;
   log_opened = true;
+
   {
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-//  for our version DOS/Windows
   if (want_version)
   {
     stamp_it(log_line);         // ??? use log_line ???
@@ -2174,15 +2293,18 @@ void jobnameappend (void)
 void start_input (void)
 {
   bool addedextension = false;
+
   scan_file_name();
   pack_file_name(cur_name, cur_area, cur_ext); 
 
-  while (true) {        /* loop until we get a valid file name */
+  while (true)        /* loop until we get a valid file name */
+  {
     addedextension = false;
     begin_file_reading(); 
 /* *** *** *** *** *** following is new in 3.14159 *** *** *** *** *** *** */
 /*  if current extension is *not* empty, try to open using name as is */
 /*  string 335 is "" the empty string */
+/*  should be updated to current Kpathsea. */
     if ((cur_ext != 335) && a_open_in(input_file[cur_input.index_field], TEXINPUTPATH))
       goto lab30;
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
@@ -2191,17 +2313,18 @@ void start_input (void)
 /*  string 785 is .tex */
 /*    (! extensionirrelevantp(name_of_file, "tex"))){ */
     if ((cur_ext != 785) && (name_length + 5 < PATHMAX) &&
-        (! extensionirrelevantp(name_of_file, name_length, "tex")))
+        (!extensionirrelevantp(name_of_file, name_length, "tex")))
     {
+      //strcpy(name_of_file + name_length + 1, ".tex ");
       name_of_file[name_length + 1] = '.';
       name_of_file[name_length + 2] = 't';
       name_of_file[name_length + 3] = 'e';
       name_of_file[name_length + 4] = 'x';
-      name_of_file[name_length + 5] = ' ';  /* 96/Jan/20 ??? */
+      name_of_file[name_length + 5] = ' ';
       name_length = name_length + 4;
 
       addedextension = true;
-/* *** *** *** ***  following new in 3.14159 *** *** *** *** *** *** *** */
+
       if (a_open_in(input_file[cur_input.index_field], TEXINPUTPATH))
         goto lab30;
 
@@ -2232,31 +2355,41 @@ lab30:
 /*  did file name have an `extension' already and we added ".tex" ? */
     if (cur_ext != 335 && addedextension)     /* 98/Feb/7 */
       jobnameappend();   /* append `extension' to job_name */
+
     open_log_file();
   }
+
   if (term_offset + length(cur_input.name_field) > max_print_line - 2) /* was 3 ? */
     print_ln();
   else if ((term_offset > 0) || (file_offset > 0))
     print_char(' ');
+
   print_char('(');
-//  print_char(64);       // debugging only marker
+//  print_char('@');       // debugging only marker
   incr(open_parens);
+
   if (open_parens > max_open_parens)
     max_open_parens = open_parens;    /* 1999/Jan/17 */
+
   slow_print(cur_input.name_field);
-//  print_char(64);       // debugging only marker
+//  print_char('@');       // debugging only marker
 #ifndef _WINDOWS
   fflush(stdout);
 #endif
   cur_input.state_field = new_line;
+
   {
     line = 1;
+
     if (input_ln(input_file[cur_input.index_field], false));
+
     firm_up_the_line();
+
     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;
   }
@@ -2269,27 +2402,41 @@ void show_tex_fonts (void)
 {     /* 98/Jan/28 */
   char *s, *t, *v, *u;
   int n;
+
   s = "TEXFONTS";
-  if (encoding_specific) {
+
+  if (encoding_specific)
+  {
     u = encoding_name;                /* try specific */
-    if ((t = grabenv(u)) != NULL) {
-      if (strchr(t, ':') != NULL &&
-        sscanf(t, "%d", &n) == 0) {
+
+    if ((t = grabenv(u)) != NULL)
+    {
+      if (strchr(t, ':') != NULL && sscanf(t, "%d", &n) == 0)
+      {
         s = u;        /* look here instead of TEXFONTS=... */
       }
     }
   }
+
   print_nl("  ");
   print_char(' ');
   print_char('(');
   t = s;
-  while (*t > '\0') print_char(*t++);
+
+  while (*t > '\0')
+    print_char(*t++);
+
   print_char('=');
   v = grabenv(s);
-  if (v != NULL) {
+
+  if (v != NULL)
+  {
     t = v;
-    while (*t > '\0') print_char(*t++);
+
+    while (*t > '\0')
+      print_char(*t++);
   }
+
   print_char(')');
 }
 
@@ -2299,7 +2446,6 @@ void show_tex_fonts (void)
 /* sec 0560 */
 internal_font_number read_font_info_(halfword u, str_number nom, str_number aire, scaled s)
 {
-  register internal_font_number Result;
   font_index k;
   bool fileopened;
 /*  halfword lf, lh, bc, ec, nw, nh, nd, ni, nl, nk, ne, np;  */
@@ -2328,7 +2474,8 @@ internal_font_number read_font_info_(halfword u, str_number nom, str_number aire
       if (!b_open_in(tfm_file))
         goto lab11;
     }
-    else goto lab11;
+    else
+      goto lab11;
   } 
 /*   was just: goto lab11; */
   fileopened = true; 
@@ -2498,7 +2645,7 @@ internal_font_number read_font_info_(halfword u, str_number nom, str_number aire
   italic_base[f] = depth_base[f] + nd;
   lig_kern_base[f] = italic_base[f] + ni;
   kern_base[f] = lig_kern_base[f] + nl - 256 * (128);
-  exten_base[f] = kern_base[f] + 256 *(128) + nk;
+  exten_base[f] = kern_base[f] + 256 * (128) + nk;
   param_base[f] = exten_base[f] + ne;
 
   {
@@ -2554,6 +2701,7 @@ internal_font_number read_font_info_(halfword u, str_number nom, str_number aire
         z = s;
       else
         z = xn_over_d(z, - (integer) s, 1000);
+
     font_size[f] = z;
   }
 
@@ -2584,27 +2732,35 @@ internal_font_number read_font_info_(halfword u, str_number nom, str_number aire
         if (d >= nl)
           goto lab11;
         break;
+
       case 3 :
         if (d >= ne)
           goto lab11;
         break;
+
       case 2 :
         {
           {
             if ((d < bc)||(d > ec))
               goto lab11;
           }
-          while (d < k + bc - fmem_ptr) {
+
+          while (d < k + bc - fmem_ptr)
+          {
             qw = font_info[char_base[f]+ d].qqqq;
             if (((qw.b2)% 4)!= 2)
               goto lab45;
+
             d = qw.b3;
           }
+
           if (d == k + bc - fmem_ptr)
             goto lab11;
 lab45:; 
         }
         break;
+
       default:
         break;
     }
@@ -2612,10 +2768,13 @@ lab45:;
   {
     {
       alpha = 16;
-      while (z >= 8388608L) {   /* 2^23 */
+
+      while (z >= 8388608L)   /* 2^23 */
+      {
         z = z / 2;
         alpha = alpha + alpha;
       }
+
       beta = (char) (256 / alpha);
       alpha = alpha * z;
     }
@@ -2631,6 +2790,7 @@ lab45:;
       tfm_temp = getc(tfm_file);
       d = tfm_temp;
       sw = (((((d * z) / 256) + (c * z)) / 256) + (b * z)) / beta;
+
       if (a == 0)
         font_info[k].cint = sw;
       else if (a == 255)
@@ -2638,12 +2798,16 @@ lab45:;
       else
         goto lab11;
     }
+
     if (font_info[width_base[f]].cint != 0)
       goto lab11;
+
     if (font_info[height_base[f]].cint != 0)
       goto lab11;
+
     if (font_info[depth_base[f]].cint != 0)
       goto lab11;
+
     if (font_info[italic_base[f]].cint != 0)
       goto lab11;
   }
@@ -2653,7 +2817,7 @@ lab45:;
 
   if (nl > 0)
   {
-    for (k = lig_kern_base[f]; k <= kern_base[f] + 256 * (128)- 1; k++)
+    for (k = lig_kern_base[f]; k <= kern_base[f] + 256 * (128) - 1; k++)
     {
       {
         tfm_temp = getc(tfm_file);
@@ -2670,10 +2834,12 @@ lab45:;
         qw.b3 = d;
         font_info[k].qqqq = qw; /* store_four_quarters(font_info[k].qqqq */
       }
+
       if (a > 128)
       {
         if (256 * c + d >= nl)
           goto lab11;       /* error in TFM, abort */
+
         if (a == 255)
           if (k == lig_kern_base[f])
             bchar = b;
@@ -2686,17 +2852,22 @@ lab45:;
             if ((b < bc) || (b > ec))  /* check-existence(b) */
               goto lab11;         /* error in TFM, abort */
           }
+
           qw = font_info[char_base[f] + b].qqqq;
+
           if (!(qw.b0 > 0))
             goto lab11;         /* error in TFM, abort */
         }
+
         if (c < 128)
         {
           {
             if ((d < bc) || (d > ec))  /* check-existence(d) */
               goto lab11;         /* error in TFM, abort */
           }
+
           qw = font_info[char_base[f] + d].qqqq;
+
           if (!(qw.b0 > 0))
             goto lab11;         /* error in TFM, abort */
         }
@@ -2707,6 +2878,7 @@ lab45:;
             goto lab11;         /* error in TFM, abort */
       }
     }
+
     if (a == 255)
       bchlabel = 256 * c + d;
   }
@@ -2722,6 +2894,7 @@ lab45:;
     tfm_temp = getc(tfm_file);
     d = tfm_temp;
     sw = (((((d * z) / 256) + (c * z)) / 256) + (b * z)) / beta;
+
     if (a == 0)
       font_info[k].cint = sw;
     else if (a == 255)
@@ -2748,33 +2921,42 @@ lab45:;
 /*    store_four_quarters(font_info[k].qqqq); */
       font_info[k].qqqq = qw;
     }
+
     if (a != 0)
     {
       {
         if ((a < bc) || (a > ec))
           goto lab11;
       }
+
       qw = font_info[char_base[f] + a].qqqq;
+
       if (!(qw.b0 > 0))
         goto lab11;
     }
+
     if (b != 0)
     {
       {
         if ((b < bc) || (b > ec))
           goto lab11;
       }
+
       qw = font_info[char_base[f] + b].qqqq;
+
       if (!(qw.b0 > 0))
         goto lab11;
     }
+
     if (c != 0)
     {
       {
         if ((c < bc) || (c > ec))
           goto lab11;
       }
+
       qw = font_info[char_base[f] + c].qqqq;
+
       if (!(qw.b0 > 0))
         goto lab11;
     }
@@ -2783,7 +2965,9 @@ lab45:;
         if ((d < bc) || (d > ec))
           goto lab11;
       }
+
       qw = font_info[char_base[f] + d].qqqq;
+
       if (!(qw.b0 > 0))
         goto lab11;
     }
@@ -2794,8 +2978,10 @@ lab45:;
       {
         tfm_temp = getc(tfm_file);
         sw = tfm_temp;
+
         if (sw > 127)
           sw = sw - 256;
+
         tfm_temp = getc(tfm_file);
         sw = sw * 256 + tfm_temp;
         tfm_temp = getc(tfm_file);
@@ -2814,6 +3000,7 @@ lab45:;
         tfm_temp = getc(tfm_file);
         d = tfm_temp;
         sw = (((((d * z) / 256) + (c * z)) / 256) + (b * z)) / beta;
+
         if (a == 0)
           font_info[param_base[f] + k - 1].cint = sw;
         else if (a == 255)
@@ -2823,6 +3010,7 @@ lab45:;
 /*  use test_eof() here instead ? */
     if (feof(tfm_file))
       goto lab11;
+
     for (k = np + 1; k <= 7; k++)
       font_info[param_base[f] + k - 1].cint = 0;
   }
@@ -2831,21 +3019,27 @@ lab45:;
     font_params[f] = np;
   else
     font_params[f] = 7;
+
   hyphen_char[f] = default_hyphen_char;
   skew_char[f] = default_skew_char;
+
   if (bchlabel < nl)
     bchar_label[f] = bchlabel + lig_kern_base[f];
   else
     bchar_label[f]= non_address; /* i.e. 0 --- 96/Jan/15 */
+
   font_bchar[f] = bchar;
   font_false_bchar[f] = bchar;
+
   if (bchar <= ec)
     if (bchar >= bc)
     {
       qw = font_info[char_base[f] + bchar].qqqq;
+
       if ((qw.b0 > 0))
         font_false_bchar[f] = 256;
     }
+
   font_name[f] = nom;
   font_area[f] = aire;
   font_bc[f] = bc;
@@ -2866,6 +3060,7 @@ lab11:
   sprint_cs(u); 
   print_char('=');
   print_file_name(nom, aire, 335);  /* "" */
+
   if (s >= 0)
   {
     print_string(" at ");
@@ -2885,7 +3080,8 @@ lab11:
 
   if (aire == 335) /* "" only if path not specified */
   {
-    if (show_texinput_flag) show_tex_fonts();   /* 98/Jan/31 */
+    if (show_texinput_flag)
+      show_tex_fonts();   /* 98/Jan/31 */
   }
 
   help5("I wasn't able to read the size data for this font,",
@@ -2898,6 +3094,5 @@ lab30:
   if (fileopened)
     b_close(tfm_file);
 
-  Result = g;
-  return Result;
+  return g;
 }
\ No newline at end of file
index 488a0a0..2ec18b7 100644 (file)
@@ -28,24 +28,24 @@ void char_warning_(internal_font_number f, eight_bits c)
 { 
   if (tracing_lost_chars > 0)
   {
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-    if (show_missing == 0)            /* show on screen 94/June/10 */
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+    if (show_missing == 0)
       begin_diagnostic();
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-    if (show_missing)
-    {     /* add ! before 94/June/10 */
+
+    if (show_missing) /* add ! before 94/June/10 */
+    {
       print_nl("! ");
       print_string("Missing character: there is no ");
     }
     else
       print_nl("Missing character: there is no ");
+
     print(c);
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-    if (show_numeric)
-    {             /* bkph 93/Dec/21 */
+
+    if (show_numeric) /* bkph 93/Dec/21 */
+    {
       print_char(' ');
       print_char('(');
+
       if (c / 100 > 0)
       {
         print_char(48 + c / 100);
@@ -71,12 +71,13 @@ void char_warning_(internal_font_number f, eight_bits c)
 /*  if (show_missing) show_context(); */    /* in tex2.c 94/June/10 */
     if (show_missing)
     {
-      if (f != 0) show_context();     /* not if its the nullfont */
+      if (f != 0)
+        show_context();     /* not if its the nullfont */
     }
+
     if (show_missing == 0)            /* show on screen 94/June/10 */
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
       end_diagnostic(false);
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+
     missing_characters++;           /* bkph 93/Dec/16 */
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
   }
@@ -84,8 +85,8 @@ void char_warning_(internal_font_number f, eight_bits c)
 /* sec 0582 */
 halfword new_character_(internal_font_number f, eight_bits c)
 {
-  register halfword Result;
   halfword p;
+
   if (font_bc[f] <= c)
     if (font_ec[f] >= c)
       if ((font_info[char_base[f] + c].qqqq.b0 > 0))
@@ -93,12 +94,11 @@ halfword new_character_(internal_font_number f, eight_bits c)
         p = get_avail();
         font(p) = f;
         character(p) = c;
-        Result = p;
-        return (Result);
+        return p;
       }
+
   char_warning(f, c); /* char_warning(f,c); l.11283 */
-  Result = 0;       /* new_character:=null */
-  return Result;
+  return 0;
 }
 /* following needs access to dvi_buf=zdvibuf see coerce.h */
 /* sec 0598 */
@@ -113,16 +113,17 @@ void dvi_swap (void)
 
   if (dvi_limit == dvi_buf_size)
   {
-    writedvi(0, half_buf - 1);
+    write_dvi(0, half_buf - 1);
     dvi_limit = half_buf;
     dvi_offset = dvi_offset + dvi_buf_size;
     dvi_ptr = 0;
   }
   else
   {
-    writedvi(half_buf, dvi_buf_size - 1);
+    write_dvi(half_buf, dvi_buf_size - 1);
     dvi_limit = dvi_buf_size;
   }
+
   dvi_gone = dvi_gone + half_buf;
 }
 /* following needs access to dvi_buf=zdvibuf see coerce.h */
@@ -165,21 +166,21 @@ void zdvipop(integer l)
 void dvi_font_def_(internal_font_number f)
 {
   pool_pointer k;
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+
 #ifdef INCREASEFONTS
   if (f <= 256)
   {
-    dvi_out(243);
+    dvi_out(fnt_def1);
     dvi_out(f - 1);
   }
   else
   {
-    dvi_out(244);
+    dvi_out(fnt_def2);
     dvi_out(((f - 1) >> 8));
     dvi_out(((f - 1) & 255));
   }
 #else
-  dvi_out(243);
+  dvi_out(fnt_def1);
   dvi_out(f - 1);
 #endif
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
@@ -192,10 +193,11 @@ void dvi_font_def_(internal_font_number f)
   dvi_four(font_dsize[f]);
   dvi_out(length(font_area[f]));
   dvi_out(length(font_name[f]));
-/* sec 0603 */
-  for (k = str_start[font_area[f]]; k <= str_start[font_area[f]+ 1] - 1; k++)
+
+  for (k = str_start[font_area[f]]; k <= str_start[font_area[f] + 1] - 1; k++)
     dvi_out(str_pool[k]);
-  for (k = str_start[font_name[f]]; k <= str_start[font_name[f]+ 1] - 1; k++)
+
+  for (k = str_start[font_name[f]]; k <= str_start[font_name[f] + 1] - 1; k++)
     dvi_out(str_pool[k]);
 }
 /* following needs access to dvi_buf=zdvibuf see coerce.h */
@@ -205,94 +207,112 @@ void zmovement(scaled w, eight_bits o)
   small_number mstate;
   halfword p, q;
   integer k;
-  q = get_node(3);
-  mem[q + 1].cint = w;
-  mem[q + 2].cint = dvi_offset + dvi_ptr;
-  if (o == 157) /* 157 == down1 */
+
+  q = get_node(movement_node_size);
+  width(q) = w;
+  location(q) = dvi_offset + dvi_ptr;
+
+  if (o == down1)
   {
-    mem[q].hh.v.RH = down_ptr;
+    link(q) = down_ptr;
     down_ptr = q;
   }
   else
-  { /* 143 == right1 */
-    mem[q].hh.v.RH = right_ptr;
+  {
+    link(q) = right_ptr;
     right_ptr = q;
   }
-  p = mem[q].hh.v.RH;
-  mstate = 0;
-  while (p != 0) {  /* while p<>null do l.12153 */
-    if (mem[p + 1].cint == w)
-      switch(mstate + mem[p].hh.v.LH)
+
+  p = link(q);
+  mstate = none_seen;
+
+  while (p != 0)
+  {
+    if (width(p) == w)
+      switch(mstate + info(p))
       {
-        case 3:
-        case 4:
-        case 15:
-        case 16:
-          if (mem[p + 2].cint < dvi_gone)
+        case none_seen + yz_OK:
+        case none_seen + y_OK:
+        case z_seen + yz_OK:
+        case z_seen + y_OK:
+          if (location(p) < dvi_gone)
             goto lab45;
           else
           {
-            k = mem[p + 2].cint - dvi_offset;
+            k = location(p) - dvi_offset;
+
             if (k < 0)
               k = k + dvi_buf_size;
-            dvi_buf[k]= dvi_buf[k] + 5;
-            mem[p].hh.v.LH = 1;
+
+            dvi_buf[k] = dvi_buf[k] + y1 - down1;
+            info(p) = y_here;
             goto lab40;
           }
           break;
-        case 5:
-        case 9:
-        case 11:
-          if (mem[p + 2].cint < dvi_gone)
+
+        case none_seen + z_OK:
+        case y_seen + yz_OK:
+        case y_seen + z_OK:
+          if (location(p) < dvi_gone)
             goto lab45;
           else
           {
-            k = mem[p + 2].cint - dvi_offset;
+            k = location(p) - dvi_offset;
+
             if (k < 0)
               k = k + dvi_buf_size;
-            dvi_buf[k]= dvi_buf[k] + 10;
-            mem[p].hh.v.LH = 2;
+
+            dvi_buf[k] = dvi_buf[k] + z1 - down1;
+            info(p) = z_here;
             goto lab40;
           }
           break;
-        case 1:
-        case 2:
-        case 8:
-        case 13:
+
+        case none_seen + y_here:
+        case none_seen + z_here:
+        case y_seen + z_here:
+        case z_seen + y_here:
           goto lab40;
           break;
+
         default:
           break;
       }
-    else switch (mstate + mem[p].hh.v.LH)
+    else switch (mstate + info(p))
     {
-      case 1:
-        mstate = 6;
+      case none_seen + y_here:
+        mstate = y_seen;
         break;
-      case 2:
-        mstate = 12;
+
+      case none_seen + z_here:
+        mstate = z_seen;
         break;
-      case 8:
-      case 13:
+
+      case y_seen + z_here:
+      case z_seen + y_here:
         goto lab45;
         break;
+
       default:
         break;
     }
-    p = mem[p].hh.v.RH;
+    p = link(p);
   }
 lab45:
-  ;
-  mem[q].hh.v.LH = 3;
+
+  info(q) = yz_OK;
+
   if (abs(w) >= 8388608L) /* 2^23 */
   {
     dvi_out(o + 3);
     dvi_four(w);
     return;
   }
+
   if (abs(w) >= 32768L)
   {
     dvi_out(o + 2);
+
     if (w < 0)
       w = w + 16777216L;  /* 2^24 */
     //dvi_out(w / 65536L);
@@ -301,16 +321,22 @@ lab45:
     w = w & 65535L;
     goto lab2;
   }
+
   if (abs(w)>= 128)
   {
     dvi_out(o + 1);
+
     if (w < 0)
       w = w + 65536L;
+
     goto lab2;
   }
+
   dvi_out(o);
+
   if (w < 0)
     w = w + 256;
+
   goto lab1;
 lab2:
   //dvi_out(w / 256);
@@ -320,20 +346,26 @@ lab1:
   dvi_out(w & 255);
   return;
 lab40:
-  mem[q].hh.v.LH = mem[p].hh.v.LH;
-  if (mem[q].hh.v.LH == 1)
+  info(q) = info(p);
+
+  if (info(q) == y_here)
   {
-    dvi_out(o + 4);
-    while (mem[q].hh.v.RH != p) {
-      q = mem[q].hh.v.RH;
-      switch (mem[q].hh.v.LH)
+    dvi_out(o + y0 - down1);
+
+    while (link(q) != p)
+    {
+      q = link(q);
+
+      switch (info(q))
       {
-        case 3:
-          mem[q].hh.v.LH = 5;
+        case yz_OK:
+          info(q) = z_OK;
           break;
-        case 4:
-          mem[q].hh.v.LH = 6;
+
+        case y_OK:
+          info(q) = d_fixed;
           break;
+
         default:
           break;
       }
@@ -341,17 +373,22 @@ lab40:
   }
   else
   {
-    dvi_out(o + 9);
-    while (mem[q].hh.v.RH != p) {
-      q = mem[q].hh.v.RH;
-      switch (mem[q].hh.v.LH)
+    dvi_out(o + z0 - down1);
+
+    while (link(q) != p)
+    {
+      q = link(q);
+
+      switch (info(q))
       {
-        case 3:
-          mem[q].hh.v.LH = 4;
+        case yz_OK:
+          info(q) = y_OK;
           break;
-        case 5:
-          mem[q].hh.v.LH = 6;
+
+        case z_OK:
+          info(q) = d_fixed;
           break;
+
         default:
           break;
       }
@@ -362,22 +399,25 @@ lab40:
 void prune_movements_(integer l)
 {
   halfword p;
+
   while (down_ptr != 0)
   {
-    if (mem[down_ptr + 2].cint < l)
+    if (location(down_ptr) < l)
       goto lab30;
+
     p = down_ptr;
-    down_ptr = mem[p].hh.v.RH;
-    free_node(p, 3);
+    down_ptr = link(p);
+    free_node(p, movement_node_size);
   }
 lab30:
   while (right_ptr != 0)
   {
-    if (mem[right_ptr + 2].cint < l)
+    if (location(right_ptr) < l)
       return;
+
     p = right_ptr;
-    right_ptr = mem[p].hh.v.RH;
-    free_node(p, 3);
+    right_ptr = link(p);
+    free_node(p, movement_node_size);
   }
 }
 /* following needs access to dvi_buf=zdvibuf see coerce.h */
@@ -389,17 +429,19 @@ void special_out_(halfword p)
 
   if (cur_h != dvi_h)
   {
-    movement(cur_h - dvi_h, 143); /* 143 == right1 */
+    movement(cur_h - dvi_h, right1);
     dvi_h = cur_h;
   }
 
   if (cur_v != dvi_v)
   {
-    movement(cur_v - dvi_v, 157); /* 157 == down1 */
+    movement(cur_v - dvi_v, down1);
     dvi_v = cur_v;
   }
+
   old_setting = selector;
   selector = new_string;
+
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
 /* About output \special{...} make some space in string pool 97/Mar/9 */
 #ifdef ALLOCATESTRING
@@ -411,26 +453,23 @@ void special_out_(halfword p)
 /* Fixed 97/Mar/9 in version 2.0.3 */
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
 #ifdef ALLOCATESTRING
-/*  show_token_list(mem[mem[p + 1].hh.v.RH].hh.v.RH, 0,
-    current_pool_size - pool_ptr); */
-  show_token_list(mem[mem[p + 1].hh.v.RH].hh.v.RH, 0, 10000000L);
+  show_token_list(link(write_tokens(p)), 0, 10000000L);
 /*  Above is safe, since print/print_char/print_esc will extend string space */
 #else
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-  show_token_list(mem[mem[p + 1].hh.v.RH].hh.v.RH, 0, pool_size - pool_ptr);
+  show_token_list(link(write_tokens(p)), 0, pool_size - pool_ptr);
 #endif
   selector = old_setting;
   str_room(1);
 
   if (cur_length < 256)  /* can use xxx1 ? */
   {
-    dvi_out(239);
-/* long to unsigned char ... */
+    dvi_out(xxx1);
     dvi_out(cur_length);
   }
   else
-  { /* use xxx4 instead */
-    dvi_out(242);
+  {
+    dvi_out(xxx4);
     dvi_four(cur_length); 
   } 
 
@@ -439,23 +478,27 @@ void special_out_(halfword p)
   {
     int k = str_start[str_ptr];
     int kend = pool_ptr;
-    if (kend > k + 4) {
-      if (str_pool [k] == 's' &&
-        str_pool [k+1] == 'r' &&
-        str_pool [k+2] == 'c' &&
-        str_pool [k+3] == ':') {  /* \special{src: ... } */
+    /* \special{src: ... } */
+    if (kend > k + 4)
+    {
+      if (str_pool [k] == 's' && str_pool [k + 1] == 'r' && str_pool [k + 2] == 'c' && str_pool [k + 3] == ':')
+      {
         show_char('\n');
         s = log_line;
-        while (k < kend) {
+
+        while (k < kend)
+        {
           *s++ = str_pool[k++];
         }
+
         *s++ = ' ';
         *s++ = '\0';
         show_line(log_line, 0)
 #ifndef _WINDOWS
         fflush(stdout);
 #endif
-        if (cur_input.name_field > 17)  { /* redundant ? */
+        if (cur_input.name_field > 17) /* redundant ? */
+        {
           print(cur_input.name_field);          
           print_char('(');
           print_int(line);      /* line number */
@@ -485,52 +528,52 @@ void write_out_(halfword p)
 /*  small_number j;  */
   int j;              /* 1995/Jan/7 */
   halfword q, r;
-/* q:=get_avail; info(q):=right_brace_token+"}";@/ */
+
   q = get_avail();
-  info(q) = 637;
-/* r:=get_avail; link(q):=r; info(r):=end_write_token; ins_list(q);@/ */
-/* @d end_write_token==cs_token_flag+end_write */
+  info(q) = right_brace_token + '}';
   r = get_avail();
   link(q) = r;
-/*  mem[r].hh.v.LH = (hash_size + 4617);  */
-/*  mem[r].hh.v.LH = (hash_size + 4095 + 522); */
-  info(r) = (hash_size + hash_extra + 4095 + 522);
-  begin_token_list(q, 4);
-  begin_token_list(mem[p + 1].hh.v.RH, 15);
+  info(r) = end_write_token;
+  ins_list(q);
+  begin_token_list(write_tokens(p), write_text);
   q = get_avail();
-  mem[q].hh.v.LH = 379;
-  begin_token_list(q, 4);
+  info(q) = left_brace_token + '{';
+  ins_list(q);
   oldmode = mode;
   mode = 0;
   cur_cs = write_loc;
   q = scan_toks(false, true);
   get_token();
-/*  if (cur_tok != (hash_size + 4617)) */
-/*  if (cur_tok != (hash_size + 4095 + 522)) */
-  if (cur_tok != (hash_size + hash_extra + 4095 + 522))
+
+  if (cur_tok != end_write_token)
   {
     print_err("Unbalanced write command");
     help2("On this page there's a \\write with fewer real {'s than }'s.",
         "I can't handle that very well; good luck.");
     error();
+
     do
-    {
-      get_token();
-    }
-    while(!(cur_tok == (hash_size + hash_extra + 4095 + 522))); /*1996/Jan/10*/
+      {
+        get_token();
+      }
+    while(!(cur_tok == end_write_token)); /*1996/Jan/10*/
   }
+
   mode = oldmode;
   end_token_list();
   old_setting = selector;
-  j = mem[p + 1].hh.v.LH;
+  j = write_stream(p);
+
   if (write_open[j])
     selector = j;
   else
   {
-    if ((j == 17) && (selector == 19))
-      selector = 18;
+    if ((j == 17) && (selector == term_and_log))
+      selector = log_only;
+
     print_nl("");
   }
+
   token_show(def_ref);
   print_ln();
   flush_list(def_ref);
@@ -541,150 +584,177 @@ void out_what_(halfword p)
 {
 /*  small_number j;  */
   int j;            /* 1995/Jan/7 */
-  switch(mem[p].hh.b1)
-  {case 0 : 
-  case 1 : 
-  case 2 : 
-    if (!doing_leaders) {
-      j = mem[p + 1].hh.v.LH; 
-      if (mem[p].hh.b1 == 1){
-      write_out(p);
-    } else {
-      if (write_open[j])
-        (void) a_close(write_file[j]); 
-      if (mem[p].hh.b1 == 2)
-        write_open[j]= false; 
-      else if (j < 16){
-        cur_name = mem[p + 1].hh.v.RH; 
-        cur_area = mem[p + 2].hh.v.LH; 
-        cur_ext = mem[p + 2].hh.v.RH; 
-        if (cur_ext == 335)  /* "" */
-          cur_ext = 785;  /* => ".tex" */
-        pack_file_name(cur_name, cur_area, cur_ext); 
-        while(! a_open_out(write_file[j])) {
-          prompt_file_name("output file name", ".tex");
-    }
-    write_open[j]= true; 
-  } 
-      } 
-    } 
-    break; 
-  case 3 : 
-    special_out(p); 
-    break; 
-  case 4 : 
- ; 
-    break; 
-    default: 
-    {
-      confusion("ext4");
-      return;       // abort_flag set
-    }
-    break; 
-  } 
-} 
+
+  switch (subtype(p))
+  {
+    case open_node:
+    case write_node:
+    case close_node:
+      if (!doing_leaders)
+      {
+        j = write_stream(p);
+
+        if (subtype(p) == write_node)
+        {
+          write_out(p);
+        }
+        else
+        {
+          if (write_open[j])
+            (void) a_close(write_file[j]); 
+
+          if (subtype(p) == close_node)
+            write_open[j]= false; 
+          else if (j < 16)
+          {
+            cur_name = open_name(p);
+            cur_area = open_area(p);
+            cur_ext = open_ext(p); 
+
+            if (cur_ext == 335)  /* "" */
+              cur_ext = 785;  /* => ".tex" */
+
+            pack_file_name(cur_name, cur_area, cur_ext);
+
+            while(! a_open_out(write_file[j]))
+            {
+              prompt_file_name("output file name", ".tex");
+            }
+
+            write_open[j] = true;
+          }
+        }
+      }
+      break; 
+
+    case special_node:
+      special_out(p); 
+      break;
+
+    case language_node:
+      ;
+      break;
+
+    default:
+      {
+        confusion("ext4");
+        return;       // abort_flag set
+      }
+      break;
+  }
+}
 /* following needs access to dvi_buf=zdvibuf see coerce.h */
 /* sec 0619 */
 void hlist_out (void)
 {
-  scaled baseline;
-  scaled leftedge;
-  scaled saveh, savev;
-  halfword thisbox;
-/*  glue_ord gorder;  */
-  int gorder;           /* 95/Jan/7 */
-/*  char gsign;  */
-  int gsign;            /* 95/Jan/7 */
+  scaled base_line;
+  scaled left_edge;
+  scaled save_h, save_v;
+  halfword this_box;
+/*  glue_ord g_order;  */
+  int g_order;           /* 95/Jan/7 */
+/*  char g_sign;  */
+  int g_sign;            /* 95/Jan/7 */
   halfword p;
-  integer saveloc;
-  halfword leaderbox;
-  scaled leaderwd;
+  integer save_loc;
+  halfword leader_box;
+  scaled leader_wd;
   scaled lx;
-  bool outerdoingleaders;
+  bool outer_doing_leaders;
   scaled edge;
-  real gluetemp;
+  real glue_temp;
   real cur_glue;
   scaled cur_g;
 
   cur_g = 0;
   cur_glue = 0.0;
-  thisbox = temp_ptr;
-  gorder = glue_order(thisbox);
-  gsign = glue_sign(thisbox);
-  p = list_ptr(thisbox);
+  this_box = temp_ptr;
+  g_order = glue_order(this_box);
+  g_sign = glue_sign(this_box);
+  p = list_ptr(this_box);
   incr(cur_s);
+
   if (cur_s > 0)
     dvi_out(141);
+
   if (cur_s > max_push)
     max_push = cur_s;
-  saveloc = dvi_offset + dvi_ptr;
-  baseline = cur_v;
-  leftedge = cur_h;
-/* while p<>null do l.12314 */
-  while(p != 0)
+
+  save_loc = dvi_offset + dvi_ptr;
+  base_line = cur_v;
+  left_edge = cur_h;
+
+  while (p != 0)
 lab21:
-  if (is_char_node(p))
-  {
-    if (cur_h != dvi_h)
-    {
-      movement(cur_h - dvi_h, 143);   /* 143 == right1 */
-      dvi_h = cur_h;
-    }
-    if (cur_v != dvi_v)
-    {
-      movement(cur_v - dvi_v, 157);   /* 157 == down1 */
-      dvi_v = cur_v;
-    }
-    do
+    if (is_char_node(p))
     {
-      f = font(p);
-      c = character(p);
-      if (f != dvi_f)
+      if (cur_h != dvi_h)
+      {
+        movement(cur_h - dvi_h, right1);
+        dvi_h = cur_h;
+      }
+
+      if (cur_v != dvi_v)
       {
-        if (!font_used[f])
+        movement(cur_v - dvi_v, down1);
+        dvi_v = cur_v;
+      }
+
+      do
         {
-          dvi_font_def(f);
-          font_used[f] = true;
-        }
-        if (f <= 64)
-          dvi_out(f + 170); /* fnt_num_0 --- fnt_num_63 */
+          f = font(p);
+          c = character(p);
+
+          if (f != dvi_f)
+          {
+            if (!font_used[f])
+            {
+              dvi_font_def(f);
+              font_used[f] = true;
+            }
+
+            if (f <= 64 + font_base)
+              dvi_out(f - font_base - 1 + fnt_num_0); /* fnt_num_0 --- fnt_num_63 */
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
 #ifdef INCREASEFONTS
-        /* if we allow greater than 256 fonts */
-        else if (f <= 256)
-        {
-          dvi_out(235); /* fnt1 followed by f */
-          dvi_out(f - 1);
-        }
+            /* if we allow greater than 256 fonts */
+            else if (f <= 256)
+            {
+              dvi_out(fnt1);
+              dvi_out(f - 1);
+            }
 #else
-        /* normal TeX 82 case */
-        else
-        {
-          dvi_out(235); /* fnt1 followed by f */
-          dvi_out(f - 1);
-        }
+            /* normal TeX 82 case */
+            else
+            {
+              dvi_out(fnt1);
+              dvi_out(f - 1);
+            }
 #endif
 
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
 #ifdef INCREASEFONTS
-        /* fnt2 followed by f / 256,  f % 256 */
-        else
-        {
-          dvi_out(236);
-          dvi_out(((f - 1) >> 8)); /* top byte */
-          dvi_out(((f - 1) & 255)); /* bottom byte */
-        }
+            /* fnt2 followed by f / 256,  f % 256 */
+            else
+            {
+              dvi_out(fnt2);
+              dvi_out(((f - 1) >> 8));  /* top byte */
+              dvi_out(((f - 1) & 255)); /* bottom byte */
+            }
 #endif
 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-        dvi_f = f;
-      }
-      if (c >= 128)
-        dvi_out(128);
-      dvi_out(c);
-      cur_h = cur_h + font_info[width_base[f] + font_info[char_base[f] + c].qqqq.b0].cint;
-      p = link(p);
-    } while(!(!(p >= hi_mem_min)));
-    dvi_h = cur_h;
+            dvi_f = f;
+          }
+
+          if (c >= 128)
+            dvi_out(set1);
+
+          dvi_out(c);
+          cur_h = cur_h + char_width(f, char_info(f, c));
+          p = link(p);
+        }
+      while(!(!(p >= hi_mem_min)));
+      dvi_h = cur_h;
   }
   else
   {
@@ -696,21 +766,24 @@ lab21:
           cur_h = cur_h + width(p);
         else
         {
-          saveh = dvi_h;
-          savev = dvi_v;
-          cur_v = baseline + shift_amount(p);
+          save_h = dvi_h;
+          save_v = dvi_v;
+          cur_v = base_line + shift_amount(p);
           temp_ptr = p;
           edge = cur_h;
+
           if (type(p) == vlist_node)
             vlist_out();
           else
             hlist_out();
-          dvi_h = saveh;
-          dvi_v = savev;
+
+          dvi_h = save_h;
+          dvi_v = save_v;
           cur_h = edge + width(p);
-          cur_v = baseline;
+          cur_v = base_line;
         }
         break;
+
       case rule_node:
         {
           rule_ht = height(p);
@@ -719,70 +792,81 @@ lab21:
           goto lab14;
         }
         break;
+
       case whatsit_node:
         out_what(p);
         break;
+
       case glue_node:
         {
           g = glue_ptr(p);
           rule_wd = width(g) - cur_g;
-          if (gsign != normal)
+
+          if (g_sign != normal)
           {
-            if (gsign == stretching)
+            if (g_sign == stretching)
             {
-              if (stretch_order(g) == gorder)
+              if (stretch_order(g) == g_order)
               {
-                //gluetemp = glue_set(thisbox) * stretch(g);
                 cur_glue = cur_glue + stretch(g);
-                gluetemp = glue_set(thisbox) * cur_glue;
-                if (gluetemp > 1000000000.0)
-                  gluetemp = 1000000000.0;
-                else if (gluetemp < -1000000000.0)
-                  gluetemp = -1000000000.0;
-                cur_g = round(gluetemp);
-                //rule_wd = rule_wd + round(gluetemp);
+                glue_temp = glue_set(this_box) * cur_glue;
+
+                if (glue_temp > 1000000000.0)
+                  glue_temp = 1000000000.0;
+                else if (glue_temp < -1000000000.0)
+                  glue_temp = -1000000000.0;
+
+                cur_g = round(glue_temp);
               }
             }
-            else if (shrink_order(g) == gorder)
+            else if (shrink_order(g) == g_order)
             {
-              //gluetemp = glue_set(thisbox) * shrink(g);
               cur_glue = cur_glue - shrink(g);
-              gluetemp = glue_set(thisbox) * cur_glue;
-              if (gluetemp > 1000000000.0)
-                gluetemp = 1000000000.0;
-              else if (gluetemp < -1000000000.0)
-                gluetemp = -1000000000.0;
-              cur_g = round(gluetemp);
-              //rule_wd = rule_wd - round(gluetemp);
+              glue_temp = glue_set(this_box) * cur_glue;
+
+              if (glue_temp > 1000000000.0)
+                glue_temp = 1000000000.0;
+              else if (glue_temp < -1000000000.0)
+                glue_temp = -1000000000.0;
+
+              cur_g = round(glue_temp);
             }
           }
+
           rule_wd = rule_wd + cur_g;
+
           if (subtype(p) >= a_leaders)
           {
-            leaderbox = leader_ptr(p);
-            if (type(leaderbox) == rule_node)
+            leader_box = leader_ptr(p);
+
+            if (type(leader_box) == rule_node)
             {
-              rule_ht = height(leaderbox);
-              rule_dp = depth(leaderbox);
+              rule_ht = height(leader_box);
+              rule_dp = depth(leader_box);
               goto lab14;
             }
-            leaderwd = width(leaderbox);
-            if ((leaderwd > 0) && (rule_wd > 0))
+
+            leader_wd = width(leader_box);
+
+            if ((leader_wd > 0) && (rule_wd > 0))
             {
               rule_wd = rule_wd + 10;
               edge = cur_h + rule_wd;
               lx = 0;
+
               if (subtype(p) == a_leaders)
               {
-                saveh = cur_h;
-                cur_h = leftedge + leaderwd * ((cur_h - leftedge) / leaderwd);
-                if (cur_h < saveh)
-                  cur_h = cur_h + leaderwd;
+                save_h = cur_h;
+                cur_h = left_edge + leader_wd * ((cur_h - left_edge) / leader_wd);
+
+                if (cur_h < save_h)
+                  cur_h = cur_h + leader_wd;
               }
               else
               {
-                lq = rule_wd / leaderwd;
-                lr = rule_wd % leaderwd;
+                lq = rule_wd / leader_wd;
+                lr = rule_wd % leader_wd;
+
                 if (subtype(p) == c_leaders)
                   cur_h = cur_h + (lr / 2);
                 else
@@ -791,80 +875,100 @@ lab21:
                   cur_h = cur_h + ((lr - (lq - 1)* lx) / 2);
                 }
               }
-              while (cur_h + leaderwd <= edge)
+
+              while (cur_h + leader_wd <= edge)
               {
-                cur_v = baseline + shift_amount(leaderbox);
+                cur_v = base_line + shift_amount(leader_box);
+
                 if (cur_v != dvi_v)
                 {
-                  movement(cur_v - dvi_v, 157); /* 157 == down1 */
+                  movement(cur_v - dvi_v, down1);
                   dvi_v = cur_v;
                 }
-                savev = dvi_v;
+
+                save_v = dvi_v;
+
                 if (cur_h != dvi_h)
                 {
-                  movement(cur_h - dvi_h, 143); /* 143 == right1 */
+                  movement(cur_h - dvi_h, right1);
                   dvi_h = cur_h;
                 }
-                saveh = dvi_h;
-                temp_ptr = leaderbox;
-                outerdoingleaders = doing_leaders;
+
+                save_h = dvi_h;
+                temp_ptr = leader_box;
+                outer_doing_leaders = doing_leaders;
                 doing_leaders = true;
-                if (type(leaderbox) == vlist_node)
+
+                if (type(leader_box) == vlist_node)
                   vlist_out();
                 else
                   hlist_out();
-                doing_leaders = outerdoingleaders;
-                dvi_v = savev;
-                dvi_h = saveh;
-                cur_v = baseline;
-                cur_h = saveh + leaderwd + lx;
+
+                doing_leaders = outer_doing_leaders;
+                dvi_v = save_v;
+                dvi_h = save_h;
+                cur_v = base_line;
+                cur_h = save_h + leader_wd + lx;
               }
+
               cur_h = edge - 10;
               goto lab15;
             }
           }
+
           goto lab13;
         }
         break;
+
       case kern_node:
       case math_node:
         cur_h = cur_h + width(p);
         break;
+
       case ligature_node:
         {
-          mem[lig_trick]= mem[p + 1];
-          mem[lig_trick].hh.v.RH = mem[p].hh.v.RH;
+          mem[lig_trick] = mem[lig_char(p)];
+          link(lig_trick) = link(p);
           p = lig_trick;
           goto lab21;
         }
         break;
+
       default:
         break;
     }
+
     goto lab15;
 lab14:
     if ((rule_ht == -1073741824L))  /* - 2^30 */
-      rule_ht = height(thisbox);
+      rule_ht = height(this_box);
+
     if ((rule_dp == -1073741824L))     /* - 2^30 */
-      rule_dp = depth(thisbox);
+      rule_dp = depth(this_box);
+
     rule_ht = rule_ht + rule_dp;
-    if ((rule_ht > 0)&&(rule_wd > 0))
+
+    if ((rule_ht > 0) && (rule_wd > 0))
     {
       if (cur_h != dvi_h)
       {
-        movement(cur_h - dvi_h, 143);   /* 143 == right1 */
+        movement(cur_h - dvi_h, right1);
         dvi_h = cur_h;
       }
-      cur_v = baseline + rule_dp;
+
+      cur_v = base_line + rule_dp;
+
       if (cur_v != dvi_v)
       {
-        movement(cur_v - dvi_v, 157);   /* 157 == down1 */
+        movement(cur_v - dvi_v, down1);
         dvi_v = cur_v;
       }
-      dvi_out(132);
+
+      dvi_out(set_rule);
       dvi_four(rule_ht);
       dvi_four(rule_wd);
-      cur_v = baseline;
+
+      cur_v = base_line;
       dvi_h = dvi_h + rule_wd;
     }
 lab13:
@@ -872,52 +976,58 @@ lab13:
 lab15:
     p = link(p);
   }
-  prune_movements(saveloc);
+
+  prune_movements(save_loc);
+
   if (cur_s > 0)
-    dvi_pop(saveloc);
+    dvi_pop(save_loc);
+
   decr(cur_s);
 }
 /* following needs access to dvi_buf=zdvibuf see coerce.h */
 /* sec 0629 */
 void vlist_out (void)
 {
-  scaled leftedge;
-  scaled topedge;
-  scaled saveh, savev;
-  halfword thisbox;
-/*  glue_ord gorder;  */
-  int gorder;         /* 95/Jan/7 */
-/*  char gsign;  */
-  int gsign;          /* 95/Jan/7 */
+  scaled left_edge;
+  scaled top_edge;
+  scaled save_h, save_v;
+  halfword this_box;
+/*  glue_ord g_order;  */
+  int g_order;         /* 95/Jan/7 */
+/*  char g_sign;  */
+  int g_sign;          /* 95/Jan/7 */
   halfword p;
-  integer saveloc;
-  halfword leaderbox;
-  scaled leaderht;
+  integer save_loc;
+  halfword leader_box;
+  scaled leader_ht;
   scaled lx;
-  bool outerdoingleaders;
+  bool outer_doing_leaders;
   scaled edge;
-  real gluetemp;
+  real glue_temp;
   real cur_glue;
   scaled cur_g;
 
   cur_g = 0;
   cur_glue = 0.0;
-  thisbox = temp_ptr;
-  gorder = glue_order(thisbox);
-  gsign = glue_sign(thisbox);
-  p = list_ptr(thisbox);
+  this_box = temp_ptr;
+  g_order = glue_order(this_box);
+  g_sign = glue_sign(this_box);
+  p = list_ptr(this_box);
   incr(cur_s);
+
   if (cur_s > 0)
     dvi_out(141);
+
   if (cur_s > max_push)
     max_push = cur_s;
-  saveloc = dvi_offset + dvi_ptr;
-  leftedge = cur_h;
-  cur_v = cur_v - height(thisbox);
-  topedge = cur_v;
+
+  save_loc = dvi_offset + dvi_ptr;
+  left_edge = cur_h;
+  cur_v = cur_v - height(this_box);
+  top_edge = cur_v;
 
   while (p != 0)
-  {  /* while p<>null do l.12494 OK */
+  {
     if ((p >= hi_mem_min))
     {
       confusion("vlistout");
@@ -925,34 +1035,39 @@ void vlist_out (void)
     }
     else
     {
-      switch (mem[p].hh.b0)
+      switch (type(p))
       {
         case hlist_node:
         case vlist_node:
-          if (mem[p + 5].hh.v.RH == 0)
+          if (list_ptr(p) == 0)
             cur_v = cur_v + height(p) + depth(p);
           else
           {
             cur_v = cur_v + height(p);
+
             if (cur_v != dvi_v)
             {
-              movement(cur_v - dvi_v, 157);   /* 157 == down1 */
+              movement(cur_v - dvi_v, down1);
               dvi_v = cur_v;
             }
-            saveh = dvi_h;
-            savev = dvi_v;
-            cur_h = leftedge + shift_amount(p);
+
+            save_h = dvi_h;
+            save_v = dvi_v;
+            cur_h = left_edge + shift_amount(p);
             temp_ptr = p;
+
             if (type(p) == vlist_node)
               vlist_out();
             else
               hlist_out();
-            dvi_h = saveh;
-            dvi_v = savev;
-            cur_v = savev + depth(p);
-            cur_h = leftedge;
+
+            dvi_h = save_h;
+            dvi_v = save_v;
+            cur_v = save_v + depth(p);
+            cur_h = left_edge;
           }
           break;
+
         case rule_node:
           {
             rule_ht = height(p);
@@ -961,70 +1076,81 @@ void vlist_out (void)
             goto lab14;
           }
           break;
+
         case whatsit_node:
           out_what(p);
           break;
+
         case glue_node:
           {
             g = glue_ptr(p);
             rule_ht = width(g) - cur_g;
-            if (gsign != normal)
+
+            if (g_sign != normal)
             {
-              if (gsign == stretching)
+              if (g_sign == stretching)
               {
-                if (stretch_order(g) == gorder)
+                if (stretch_order(g) == g_order)
                 {
-                  //gluetemp = glue_set(thisbox) * mem[g + 2].cint;
                   cur_glue = cur_glue + stretch(g);
-                  gluetemp = glue_set(thisbox) * cur_glue;
-                  if (gluetemp > 1000000000.0)
-                    gluetemp = 1000000000.0;
-                  else if (gluetemp < -1000000000.0)
-                    gluetemp = -1000000000.0;
-                  //rule_ht = rule_ht + round(gluetemp);
-                  cur_g = round(gluetemp);
+                  glue_temp = glue_set(this_box) * cur_glue;
+
+                  if (glue_temp > 1000000000.0)
+                    glue_temp = 1000000000.0;
+                  else if (glue_temp < -1000000000.0)
+                    glue_temp = -1000000000.0;
+
+                  cur_g = round(glue_temp);
                 }
               }
-              else if (mem[g].hh.b1 == gorder)   /* BUG FIX !!! */
+              else if (shrink_order(g) == g_order)   /* BUG FIX !!! */
               {
-                //gluetemp = glue_set(thisbox) * mem[g + 3].cint;
                 cur_glue = cur_glue - shrink(g);
-                gluetemp = glue_set(thisbox) * cur_glue;
-                if (gluetemp > 1000000000.0)
-                  gluetemp = 1000000000.0;
-                else if (gluetemp < -1000000000.0)
-                  gluetemp = -1000000000.0;
-                //rule_ht = rule_ht - round(gluetemp);
-                cur_g = round(gluetemp);
+                glue_temp = glue_set(this_box) * cur_glue;
+
+                if (glue_temp > 1000000000.0)
+                  glue_temp = 1000000000.0;
+                else if (glue_temp < -1000000000.0)
+                  glue_temp = -1000000000.0;
+
+                cur_g = round(glue_temp);
               }
             }
+
             rule_ht = rule_ht + cur_g;
+
             if (subtype(p) >= a_leaders)
             {
-              leaderbox = leader_ptr(p);
-              if (type(leaderbox) == rule_node)
+              leader_box = leader_ptr(p);
+
+              if (type(leader_box) == rule_node)
               {
-                rule_wd = width(leaderbox);
+                rule_wd = width(leader_box);
                 rule_dp = 0;
                 goto lab14;
               }
-              leaderht = height(leaderbox) + depth(leaderbox);
-              if ((leaderht > 0) && (rule_ht > 0))
+
+              leader_ht = height(leader_box) + depth(leader_box);
+
+              if ((leader_ht > 0) && (rule_ht > 0))
               {
                 rule_ht = rule_ht + 10;
                 edge = cur_v + rule_ht;
                 lx = 0;
+
                 if (subtype(p) == a_leaders)
                 {
-                  savev = cur_v;
-                  cur_v = topedge + leaderht * ((cur_v - topedge) / leaderht);
-                  if (cur_v < savev)
-                    cur_v = cur_v + leaderht;
+                  save_v = cur_v;
+                  cur_v = top_edge + leader_ht * ((cur_v - top_edge) / leader_ht);
+
+                  if (cur_v < save_v)
+                    cur_v = cur_v + leader_ht;
                 }
                 else
                 {
-                  lq = rule_ht / leaderht;
-                  lr = rule_ht % leaderht;
+                  lq = rule_ht / leader_ht;
+                  lr = rule_ht % leader_ht;
+
                   if (subtype(p) == c_leaders)
                     cur_v = cur_v + (lr / 2);
                   else
@@ -1033,67 +1159,82 @@ void vlist_out (void)
                     cur_v = cur_v + ((lr - (lq - 1) * lx) / 2);
                   }
                 }
-                while (cur_v + leaderht <= edge)
+
+                while (cur_v + leader_ht <= edge)
                 {
-                  cur_h = leftedge + shift_amount(leaderbox);
+                  cur_h = left_edge + shift_amount(leader_box);
+
                   if (cur_h != dvi_h)
                   {
-                    movement(cur_h - dvi_h, 143);   /* 143 == right1 */
+                    movement(cur_h - dvi_h, right1);
                     dvi_h = cur_h;
                   }
-                  saveh = dvi_h;
-                  cur_v = cur_v + height(leaderbox);
+
+                  save_h = dvi_h;
+                  cur_v = cur_v + height(leader_box);
+
                   if (cur_v != dvi_v)
                   {
-                    movement(cur_v - dvi_v, 157);   /* 157 == down1 */
+                    movement(cur_v - dvi_v, down1);
                     dvi_v = cur_v;
                   }
-                  savev = dvi_v;
-                  temp_ptr = leaderbox;
-                  outerdoingleaders = doing_leaders;
+
+                  save_v = dvi_v;
+                  temp_ptr = leader_box;
+                  outer_doing_leaders = doing_leaders;
                   doing_leaders = true;
-                  if (type(leaderbox) == vlist_node)
+
+                  if (type(leader_box) == vlist_node)
                     vlist_out();
                   else
                     hlist_out();
-                  doing_leaders = outerdoingleaders;
-                  dvi_v = savev;
-                  dvi_h = saveh;
-                  cur_h = leftedge;
-                  cur_v = savev - height(leaderbox) + leaderht + lx;
+
+                  doing_leaders = outer_doing_leaders;
+                  dvi_v = save_v;
+                  dvi_h = save_h;
+                  cur_h = left_edge;
+                  cur_v = save_v - height(leader_box) + leader_ht + lx;
                 }
+
                 cur_v = edge - 10;
                 goto lab15;
               }
             }
+
             goto lab13;
           }
           break;
+
         case kern_node:
           cur_v = cur_v + width(p);
           break;
+
         default:
           break;
       }
       goto lab15;
 lab14:
       if ((rule_wd == -1073741824L))    /* -2^30 */
-        rule_wd = width(thisbox);
+        rule_wd = width(this_box);
+
       rule_ht = rule_ht + rule_dp;
       cur_v = cur_v + rule_ht;
+
       if ((rule_ht > 0) && (rule_wd > 0))
       {
         if (cur_h != dvi_h)
         {
-          movement(cur_h - dvi_h, 143);   /* 143 == right1 */
+          movement(cur_h - dvi_h, right1);
           dvi_h = cur_h;
         }
+
         if (cur_v != dvi_v)
         {
-          movement(cur_v - dvi_v, 157);   /* 157 == down1 */
+          movement(cur_v - dvi_v, down1);
           dvi_v = cur_v;
         }
-        dvi_out(137);
+
+        dvi_out(put_rule);
         dvi_four(rule_ht);
         dvi_four(rule_wd);
       }
@@ -1104,9 +1245,11 @@ lab13:
 lab15:
     p = link(p);
   }
-  prune_movements(saveloc);
+  prune_movements(save_loc);
+
   if (cur_s > 0)
-    dvi_pop(saveloc);
+    dvi_pop(save_loc);
+
   decr(cur_s);
 }
 /****************HPDF******************/
@@ -1122,7 +1265,7 @@ void error_handler (HPDF_STATUS error_no, HPDF_STATUS detail_no, void * user_dat
 /* sec 0638 */
 void ship_out_(halfword p)
 {
-  integer pageloc;
+  integer page_loc;
   char j, k;
   pool_pointer s;
   char old_setting;
@@ -1138,19 +1281,25 @@ void ship_out_(halfword p)
     print_ln();
   else if ((term_offset > 0) || (file_offset > 0))
     print_char(' ');
+
   print_char('[');
   j = 9;
+
   while((count(j) == 0) && (j > 0))
     decr(j);
+
   for (k = 0; k <= j; k++)
   {
     print_int(count(k));
+
     if (k < j)
       print_char('.');
   }
+
 #ifndef _WINDOWS
   fflush(stdout);
 #endif
+
   if (tracing_output > 0)
   {
     print_char(']');
@@ -1158,15 +1307,16 @@ void ship_out_(halfword p)
     show_box(p);
     end_diagnostic(true);
   }
-  if ((height(p) > 1073741823L) || /* 2^30 - 1 */
-      (depth(p) > 1073741823L) ||
-      (height(p) + depth(p) + v_offset > 1073741823L) ||
-      (width(p) + h_offset > 1073741823L))
+
+  if ((height(p) > max_dimen) || (depth(p) > max_dimen) ||
+      (height(p) + depth(p) + v_offset > max_dimen) ||
+      (width(p) + h_offset > max_dimen))
   {
     print_err("Huge page cannot be shipped out");
     help2("The page just created is more than 18 feet tall or",
         "more than 18 feet wide, so I suspect something went wrong.");
     error();
+
     if (tracing_output <= 0)
     {
       begin_diagnostic();
@@ -1176,14 +1326,17 @@ void ship_out_(halfword p)
     }
     goto lab30;
   }
+
   if (height(p) + depth(p) + v_offset > max_v)
     max_v = height(p) + depth(p) + v_offset;
+
   if (width(p) + h_offset > max_h)
     max_h = height(p) + h_offset;
+
   dvi_h = 0;
   dvi_v = 0;
   cur_h = h_offset;
-  dvi_f = 0;
+  dvi_f = null_font;
 
   if (output_file_name == 0)
   {
@@ -1202,25 +1355,8 @@ void ship_out_(halfword p)
 
   if (total_pages == 0)
   {
-    dvi_out(247);
-    dvi_out(2);
-/********BINDING WITH LIBHARU*********/
-/*
-    yandy_pdf = HPDF_New(error_handler, NULL);
-    yandy_page = HPDF_AddPage(yandy_pdf);
-    HPDF_SetInfoAttr(yandy_pdf, HPDF_INFO_PRODUCER, "Y&Y TeX with ApTeX");
-    HPDF_SetCompressionMode (yandy_pdf, HPDF_COMP_ALL);
-    HPDF_Page_SetSize (yandy_page, HPDF_PAGE_SIZE_A5, HPDF_PAGE_PORTRAIT);
-    yandy_font = HPDF_GetFont (yandy_pdf, "Times-Roman", NULL);
-    HPDF_Page_BeginText (yandy_page);
-    HPDF_Page_SetFontAndSize (yandy_page, yandy_font, 16);
-    HPDF_Page_TextOut (yandy_page, 60, HPDF_Page_GetHeight (yandy_page)-90,  "This is the \xAErst page.");
-    HPDF_Page_TextOut (yandy_page, 60, HPDF_Page_GetHeight (yandy_page)-180, "Wait for ...");
-    HPDF_Page_EndText (yandy_page);
-    HPDF_SaveToFile (yandy_pdf, "NOTICE.pdf");
-    HPDF_Free(yandy_pdf);
- */
-/********BINDING WITH LIBHARU*********/
+    dvi_out(pre);
+    dvi_out(id_byte);
     dvi_four(25400000L);  /* magic DVI scale factor */
     dvi_four(473628672L); /* 7227 * 65536 */
     prepare_mag();
@@ -1243,27 +1379,33 @@ void ship_out_(halfword p)
       dvi_out(str_pool[s]);
 
     pool_ptr = str_start[str_ptr];
-  } // end of if total_pages == 0
+  }
+
+  page_loc = dvi_offset + dvi_ptr;
+  dvi_out(bop);
 
-  pageloc = dvi_offset + dvi_ptr;
-  dvi_out(139);
   for (k = 0; k <= 9; k++)
     dvi_four(count(k));
+
   dvi_four(last_bop);
-  last_bop = pageloc;
+  last_bop = page_loc;
   cur_v = height(p) + v_offset;
   temp_ptr = p;
+
   if (type(p) == vlist_node)
     vlist_out();
   else
     hlist_out();
-  dvi_out(140);
+
+  dvi_out(eop);
   incr(total_pages);
   cur_s = -1;
 lab30:;
   if (tracing_output <= 0)
     print_char(']');
+
   dead_cycles = 0;
+
 #ifndef _WINDOWS
   fflush(stdout);
 #endif
@@ -1278,7 +1420,9 @@ lab30:;
     print_char(';');
   }
 #endif /* STAT */
+
   flush_node_list(p);
+
 #ifdef STAT
   if (tracing_stats > 1)
   {
@@ -1293,32 +1437,35 @@ lab30:;
 #endif /* STAT */
 }
 /* sec 0645 */
-void scan_spec_(group_code c, bool threecodes)
+void scan_spec_(group_code c, bool three_codes)
 {
   integer s;
-  char speccode;
+  char spec_code;
+
+  if (three_codes)
+    s = saved(0);
 
-  if (threecodes)
-    s = save_stack[save_ptr + 0].cint;
   if (scan_keyword("to"))
-    speccode = 0;
+    spec_code = exactly;
   else if (scan_keyword("spread"))
-    speccode = 1;
+    spec_code = additional;
   else
   {
-    speccode = 1;
+    spec_code = additional;
     cur_val = 0;
     goto lab40;
   }
+
   scan_dimen(false, false, false);
 lab40:
-  if (threecodes)
+  if (three_codes)
   {
-    save_stack[save_ptr + 0].cint = s;  /* s may be used without ... */
+    saved(0) = s;
     incr(save_ptr);
   }
-  save_stack[save_ptr + 0].cint = speccode;
-  save_stack[save_ptr + 1].cint = cur_val;
+
+  saved(0) = spec_code;
+  saved(1) = cur_val;
   save_ptr = save_ptr + 2;
   new_save_level(c);
   scan_left_brace();
@@ -1326,7 +1473,6 @@ lab40:
 /* sec 0649 */
 halfword hpack_(halfword p, scaled w, small_number m)
 {
-  register halfword Result;
   halfword r;
   halfword q;
   scaled h, d, x;
@@ -1356,26 +1502,32 @@ halfword hpack_(halfword p, scaled w, small_number m)
   total_shrink[fill] = 0;
   total_stretch[filll] = 0;
   total_shrink[filll] = 0;
+
   while (p != 0)
-  { /* while p<>null do l.12862 */
+  {
 lab21:
     while ((p >= hi_mem_min))
     {
       f = font(p);
-      i = font_info[char_base[f] + mem[p].hh.b1].qqqq;
-      hd = i.b1;
-      x = x + font_info[width_base[f] + i.b0].cint;
-      s = font_info[height_base[f] + (hd) / 16].cint;
+      i = char_info(f, character(p));
+      hd = height_depth(i);
+      x = x + char_width(f, i);
+      s = char_height(f, hd);
+
       if (s > h)
         h = s;
-      s = font_info[depth_base[f] + (hd) % 16].cint;
+
+      s = char_depth(f, hd);
+
       if (s > d)
         d = s;
+
       p = link(p);
     }
-    if (p != 0)  /* if p<>null then l.12886 */
+
+    if (p != 0)
     {
-      switch (mem[p].hh.b0)
+      switch (type(p))
       {
         case hlist_node:
         case vlist_node:
@@ -1383,16 +1535,20 @@ lab21:
         case unset_node:
           {
             x = x + width(p);
+
             if (type(p) >= rule_node)
               s = 0;
             else
               s = shift_amount(p);
+
             if (height(p) - s > h)
               h = height(p) - s;
+
             if (depth(p) + s > d)
               d = depth(p) + s;
           }
           break;
+
         case ins_node:
         case mark_node:
         case adjust_node:
@@ -1400,11 +1556,14 @@ lab21:
           {
             while (link(q) != p)
               q = link(q);
+
             if (type(p) == adjust_node)
             {
               link(adjust_tail) = adjust_ptr(p);
+
               while (link(adjust_tail)!= 0)
                 adjust_tail = link(adjust_tail);
+
               p = link(p);
               free_node(link(q), small_node_size);
             }
@@ -1414,10 +1573,12 @@ lab21:
               adjust_tail = p;
               p = link(p);
             }
+
             link(q) = p;
             p = q;
           }
           break;
+
         case whatsit_node:
           break;
         case glue_node:
@@ -1425,23 +1586,28 @@ lab21:
             g = glue_ptr(p);
             x = x + width(g);
             o = stretch_order(g);
-            total_stretch[o]= total_stretch[o] + stretch(g);
+            total_stretch[o] = total_stretch[o] + stretch(g);
             o = shrink_order(g);
-            total_shrink[o]= total_shrink[o] + shrink(g);
+            total_shrink[o] = total_shrink[o] + shrink(g);
+
             if (subtype(p) >= a_leaders)
             {
               g = leader_ptr(p);
+
               if (height(g) > h)
                 h = height(g);
+
               if (depth(g) > d)
                 d = depth(g);
             }
           }
           break;
+
         case kern_node:
         case math_node:
           x = x + width(p);
           break;
+
         case ligature_node:
           {
             mem[lig_trick] = mem[lig_char(p)];
@@ -1450,20 +1616,26 @@ lab21:
             goto lab21;
           }
           break;
+
         default:
           break;
       }
       p = link(p);
     }
   }
+
   if (adjust_tail != 0)
     link(adjust_tail) = 0;
+
   height(r) = h;
   depth(r) = d;
-  if (m == 1)
+
+  if (m == additional)
     w = x + w;
+
   width(r) = w;
   x = w - x;
+
   if (x == 0)
   {
     glue_sign(r) = normal;
@@ -1481,30 +1653,38 @@ lab21:
       o = fil;
     else
       o = normal;
+
     glue_order(r) = o;
     glue_sign(r) = stretching;
-    if (total_stretch[o]!= 0)
+
+    if (total_stretch[o] != 0)
       glue_set(r) = x / ((double) total_stretch[o]);
     else
     {
       glue_sign(r) = normal;
       glue_set(r) = 0.0;
     }
+
     if (o == normal)
       if (list_ptr(r) != 0)
       {
-        last_badness = badness(x, total_stretch[0]);
+        last_badness = badness(x, total_stretch[normal]);
+
         if (last_badness > hbadness)
         {
           print_ln();
+
           if (last_badness > 100)
             print_nl("Underfull");
           else
             print_nl("Loose");
+
           print_string(" \\hbox (badness ");
           print_int(last_badness);
+
           if (last_badness > 100) /* Y&Y TeX */
             underfull_hbox++;   /* 1996/Feb/9 */
+
           goto lab50;
         }
       }
@@ -1520,8 +1700,10 @@ lab21:
       o = fil;
     else
       o = normal;
+
     glue_order(r) = o;
     glue_sign(r) = shrinking;
+
     if (total_shrink[o] != 0)
       glue_set(r) =(- (integer) x) / ((double) total_shrink[o]);
     else
@@ -1529,24 +1711,30 @@ lab21:
       glue_sign(r) = normal;
       glue_set(r) = 0.0;
     }
+
     if ((total_shrink[o] < - (integer) x) && (o == 0) && (list_ptr(r) != 0))
     {
       last_badness = 1000000L;
       glue_set(r) = 1.0;
-      if ((- (integer) x - total_shrink[0] > hfuzz) || (hbadness < 100))
+
+      if ((- (integer) x - total_shrink[normal] > hfuzz) || (hbadness < 100))
       {
           if ((overfull_rule > 0) && (- (integer) x - total_shrink[0] > hfuzz))
           {
               while(link(q) != 0)
                 q = link(q);
               link(q) = new_rule();
               width(link(q)) = overfull_rule;
           }
+
           print_ln();
           print_nl("Overfull \\hbox (");
-          print_scaled(- (integer) x - total_shrink[0]);
+          print_scaled(- (integer) x - total_shrink[normal]);
           print_string("pt too wide");
+
           overfull_hbox++;      /* 1996/Feb/9 */
+
           goto lab50;
       }
     }
@@ -1554,6 +1742,7 @@ lab21:
       if (list_ptr(r) != 0)
       {
         last_badness = badness(- (integer) x, total_shrink[normal]);
+
         if (last_badness > hbadness)
         {
           print_ln();
@@ -1575,28 +1764,29 @@ lab50:
         print_string(") in paragraph at lines ");
       else
         print_string(") in alignment at lines ");
+
       print_int(abs(pack_begin_line));
       print_string("--");
     }
     else
       print_string(") detected at line ");
+
     print_int(line);
   }
+
   print_ln();
-  font_in_short_display = 0;
+  font_in_short_display = null_font;
   short_display(list_ptr(r));
   print_ln();
   begin_diagnostic();
   show_box(r);
   end_diagnostic(true);
 lab10:
-  Result = r;
-  return Result;
+  return r;
 }
 /* sec 0668 */
 halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
 {
-  register halfword Result;
   halfword r;
   scaled w, d, x;
   scaled s;
@@ -1607,7 +1797,7 @@ halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
   last_badness = 0;
   r = get_node(box_node_size);
   type(r) = vlist_node;
-  subtype(r) = 0;
+  subtype(r) = min_quarterword;
   shift_amount(r) = 0;
   list_ptr(r) = p;
   w = 0;
@@ -1629,7 +1819,7 @@ halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
       confusion("vpack");
       return 0;       // abort_flag set
     }
-    else switch (mem[p].hh.b0)
+    else switch (type(p))
     {
       case hlist_node:
       case vlist_node:
@@ -1638,16 +1828,20 @@ halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
         {
           x = x + d + height(p);
           d = depth(p);
+
           if (type(p) >= rule_node)
             s = 0;
           else
             s = shift_amount(p);
+
           if (width(p) + s > w)
             w = width(p) + s;
         }
         break;
+
       case whatsit_node:
         break;
+
       case glue_node:
         {
           x = x + d;
@@ -1662,22 +1856,26 @@ halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
           if (subtype(p) >= a_leaders)
           {
             g = leader_ptr(p);
+
             if (width(g) > w)
               w = width(g);
           }
         }
         break;
+
       case kern_node:
         {
           x = x + d + width(p);
           d = 0;
         }
         break;
+
       default:
         break;
     }
     p = link(p);
   }
+
   width(r) = w;
 
   if (d > l)
@@ -1688,10 +1886,12 @@ halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
   else
     depth(r) = d;
 
-  if (m == 1)
+  if (m == additional)
     h = x + h;
+
   height(r) = h;
   x = h - x;
+
   if (x == 0)
   {
     glue_sign(r) = normal;
@@ -1709,6 +1909,7 @@ halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
       o = fil;
     else
       o = normal;
+
     glue_order(r) = o;
     glue_sign(r) = stretching;
 
@@ -1724,17 +1925,22 @@ halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
       if (list_ptr(r) != 0)
       {
         last_badness = badness(x, total_stretch[normal]);
+
         if (last_badness > vbadness)
         {
           print_ln();
+
           if (last_badness > 100)
             print_nl("Underfull");
           else
             print_nl("Loose");
+
           print_string(" \\vbox (badness ");
           print_int(last_badness);
+
           if (last_badness > 100)
             underfull_vbox++; /* 1996/Feb/9 */
+
           goto lab50;
         }
       }
@@ -1750,9 +1956,11 @@ halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
       o = fil;
     else
       o = normal;
+
     glue_order(r) = o;
     glue_sign(r) = shrinking;
-    if (total_shrink[o]!= 0)
+
+    if (total_shrink[o] != 0)
       glue_set(r) =(- (integer) x)/ ((double) total_shrink[o]);
     else
     {
@@ -1764,13 +1972,16 @@ halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
     {
       last_badness = 1000000L;
       glue_set(r) = 1.0;
+
       if ((- (integer) x - total_shrink[0] > vfuzz) || (vbadness < 100))
       {
         print_ln();
         print_nl("Overfull \\vbox (");
         print_scaled(- (integer) x - total_shrink[0]);
         print_string("pt too high");
+
         overfull_vbox++;    /* 1996/Feb/9 */
+
         goto lab50;
       }
     }
@@ -1791,7 +2002,8 @@ halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
 lab50:
   if (output_active)
     print_string(") has occurred while \\output is active");
-  else {
+  else
+  {
     if (pack_begin_line != 0)
     {
       print_string(") in alignment at lines ");
@@ -1800,15 +2012,16 @@ lab50:
     }
     else
       print_string(") detected at line ");
+
     print_int(line);
     print_ln();
   }
+
   begin_diagnostic();
   show_box(r);
   end_diagnostic(true);
 lab10:
-  Result = r;
-  return Result;
+  return r;
 }
 /* sec 0679 */
 void append_to_vlist_(halfword b)
@@ -1818,7 +2031,7 @@ void append_to_vlist_(halfword b)
 
   if (cur_list.aux_field.cint > ignore_depth)
   {
-    d = width(baseline_skip) - cur_list.aux_field.cint - height(b);
+    d = width(baseline_skip) - prev_depth - height(b);
 
     if (d < line_skip_limit)
       p = new_param_glue(line_skip_code);
@@ -1830,37 +2043,43 @@ void append_to_vlist_(halfword b)
     link(tail) = p;
     tail = p;
   }
+
   link(tail) = b;
   tail = b;
-  cur_list.aux_field.cint = depth(b);
+  prev_depth = depth(b);
 }
 /* sec 0686 */
 halfword new_noad (void)
 {
   halfword p;
+
   p = get_node(noad_size);
   type(p) = ord_noad;
   subtype(p) = normal;
   mem[nucleus(p)].hh = empty_field;
   mem[subscr(p)].hh = empty_field;
   mem[supscr(p)].hh = empty_field;
+
   return p;
 }
 /* sec 0688 */
 halfword new_style_(small_number s)
 {
   halfword p;
+
   p = get_node(style_node_size);
   type(p) = style_node;
   subtype(p) = s;
   width(p) = 0;
   depth(p) = 0;
+
   return p;
 }
 /* sec 0689 */
 halfword new_choice (void)
 {
   halfword p;
+
   p = get_node(style_node_size);
   type(p) = choice_node;
   subtype(p) = 0;
@@ -1868,6 +2087,7 @@ halfword new_choice (void)
   text_mlist(p) = 0;
   script_mlist(p) = 0;
   script_script_mlist(p) = 0;
+
   return p;
 }
 /* sec 0693 */
@@ -1879,62 +2099,67 @@ void show_info (void)
 halfword fraction_rule_(scaled t)
 {
   halfword p;
+
   p = new_rule();
   height(p) = t;
   depth(p) = 0;
+
   return p;
 }
+/* sec 0705 */
 halfword overbar_(halfword b, scaled k, scaled t)
 {
-  register halfword Result;
   halfword p, q;
+
   p = new_kern(k);
-  mem[p].hh.v.RH = b;
+  link(p) = b;
   q = fraction_rule(t);
-  mem[q].hh.v.RH = p;
+  link(q) = p;
   p = new_kern(t);
-  mem[p].hh.v.RH = q;
-  Result = vpackage(p, 0, 1, 1073741823L); /* 2^30 - 1 */
-  return Result;
+  link(p) = q;
+  return vpackage(p, 0, 1, 1073741823L); /* 2^30 - 1 */
 }
+/* sec 0709 */
 halfword char_box_(internal_font_number f, quarterword c)
 {
-  register halfword Result;
   ffourquarters q;
   eight_bits hd;
   halfword b, p;
-  q = font_info[char_base[f] + c].qqqq;
-  hd = q.b1;
+
+  q = char_info(f, c);
+  hd = height_depth(q);
   b = new_null_box();
-  mem[b + 1].cint = font_info[width_base[f] + q.b0].cint + font_info[italic_base[f] + (q.b2) / 4].cint;
-  mem[b + 3].cint = font_info[height_base[f] + (hd) / 16].cint;
-  mem[b + 2].cint = font_info[depth_base[f] + (hd) % 16].cint;
-/*  long to unsigned short ... */
+  width(b) = char_width(f, q) + char_italic(f, q);
+  height(b) = char_height(f, hd);
+  depth(b) = char_depth(f, hd);
   p = get_avail();
-  mem[p].hh.b1 = c;
-  mem[p].hh.b0 = f;
-  mem[b + 5].hh.v.RH = p;
-  Result = b;
-  return Result;
+  character(p) = c;
+  font(p) = f;
+  list_ptr(b) = p;
+
+  return b;
 }
+/* sec 0711 */
 void stack_into_box_(halfword b, internal_font_number f, quarterword c)
 {
   halfword p;
+
   p = char_box(f, c);
-  mem[p].hh.v.RH = mem[b + 5].hh.v.RH;
-  mem[b + 5].hh.v.RH = p;
-  mem[b + 3].cint = mem[p + 3].cint;
-} 
+  link(p) = list_ptr(b);
+  list_ptr(b) = p;
+  height(b) = height(p);
+}
+/* sec 0712 */
 scaled height_plus_depth_(internal_font_number f, fquarterword c)
 {
-  register scaled Result;
   ffourquarters q;
   eight_bits hd;
-  q = font_info[char_base[f]+ c].qqqq;
-  hd = q.b1;
-  Result = font_info[height_base[f] + (hd) / 16].cint + font_info[depth_base[f] + (hd) % 16].cint;
-  return Result;
+
+  q = char_info(f, c);
+  hd = height_depth(q);
+  return char_height(f, hd) + char_depth(f, hd);
 }
+/* sec 0706 */
 halfword var_delimiter_(halfword d, small_number s, scaled v)
 {
   register halfword Result;
@@ -1949,117 +2174,153 @@ halfword var_delimiter_(halfword d, small_number s, scaled v)
   eight_bits hd;
 /*  small_number z;  */
   int z;                  /* 95/Jan/7 */
-/*  bool largeattempt;  */
-  int largeattempt;           /* 95/Jan/7 */
-  f = 0;
+/*  bool large_attempt;  */
+  int large_attempt;           /* 95/Jan/7 */
+
+  f = null_font;
   w = 0;
-  largeattempt = false;
-  z = mem[d].qqqq.b0;
-  x = mem[d].qqqq.b1;
+  large_attempt = false;
+  z = small_fam(d);
+  x = small_char(d);
+
   while (true)
   {
     if ((z != 0) || (x != 0))
     {
       z = z + s + 16;
+
       do
-      {
-        z = z - 16;
-        g = eqtb[(hash_size + 1835) + z].hh.v.RH;
-        if (g != 0) {
-          y = x;
-          if ((y >= font_bc[g]) && (y <= font_ec[g]))
+        {
+          z = z - 16;
+          g = fam_fnt(z);
+
+          if (g != null_font)
           {
-lab22:
-            q = font_info[char_base[g]+ y].qqqq;
-            if ((q.b0 > 0))
+            y = x;
+
+            if ((y >= font_bc[g]) && (y <= font_ec[g]))
             {
-              if (((q.b2) % 4) == 3)
+lab22:
+              q = char_info(g, y);
+              
+              if ((q.b0 > 0))
               {
-                f = g;
-                c = y;
-                goto lab40;
-              }
-              hd = q.b1;
-              u = font_info[height_base[g] + (hd) / 16].cint + font_info[depth_base[g] + (hd) % 16].cint;
-              if (u > w) {
-                f = g;
-                c = y;
-                w = u;
-                if (u >= v)
+                if (char_tag(q) == ext_tag)
+                {
+                  f = g;
+                  c = y;
                   goto lab40;
-              }
-              if (((q.b2)% 4)== 2) {
-                y = q.b3;
-                goto lab22;
+                }
+
+                hd = height_depth(q);
+                u = char_height(g, hd) + char_depth(g, hd);
+
+                if (u > w)
+                {
+                  f = g;
+                  c = y;
+                  w = u;
+
+                  if (u >= v)
+                    goto lab40;
+                }
+
+                if (char_tag(q) == list_tag)
+                {
+                  y = rem_byte(q);
+                  goto lab22;
+                }
               }
             }
           }
         }
-      } while (!(z < 16));
-    } 
-    if (largeattempt)
+      while (!(z < 16));
+    }
+
+    if (large_attempt)
       goto lab40;
-    largeattempt = true;
-    z = mem[d].qqqq.b2;
-    x = mem[d].qqqq.b3;
+
+    large_attempt = true;
+    z = large_fam(d);
+    x = large_char(d);
   }
 lab40:
-  if (f != 0)
-    if (((q.b2) % 4)== 3)   /* q may be used without ... */
+  if (f != null_font)
+    if (char_tag(q) == ext_tag)
     {
-      b = new_null_box(); 
-      mem[b].hh.b0 = 1; 
-      r = font_info[exten_base[f]+ q.b3].qqqq;
-      c = r.b3;
+      b = new_null_box();
+      type(b) = vlist_node;
+      r = font_info[exten_base[f] + rem_byte(q)].qqqq;
+      c = ext_rep(r);
       u = height_plus_depth(f, c);
       w = 0;
-      q = font_info[char_base[f]+ c].qqqq;
-      mem[b + 1].cint = font_info[width_base[f]+ q.b0].cint + font_info[italic_base[f]+(q.b2) / 4].cint;
-      c = r.b2;
-      if (c != 0)
+      q = char_info(f, c);
+      width(b) = char_width(f, q) + char_italic(f, q);
+      c = ext_bot(r);
+
+      if (c != min_quarterword)
         w = w + height_plus_depth(f, c);
-      c = r.b1;
-      if (c != 0)
+
+      c = ext_mid(r);
+
+      if (c != min_quarterword)
         w = w + height_plus_depth(f, c);
-      c = r.b0; 
-      if (c != 0)
+
+      c = ext_top(r);
+
+      if (c != min_quarterword)
         w = w + height_plus_depth(f, c);
+
       n = 0;
+
       if (u > 0)
-        while(w < v) {
+        while(w < v)
+        {
           w = w + u;
           incr(n);
-          if (r.b1 != 0)
+
+          if (ext_mid(r) != min_quarterword)
             w = w + u;
         }
-        c = r.b2;
-        if (c != 0)
-          stack_into_box(b, f, c); 
-        c = r.b3;
+
+      c = ext_bot(r);
+
+      if (c != min_quarterword)
+        stack_into_box(b, f, c);
+
+      c = ext_rep(r);
+
+      for (m = 1; m <= n; m++)
+        stack_into_box(b, f, c);
+
+      c = ext_mid(r);
+
+      if (c != min_quarterword)
+      {
+        stack_into_box(b, f, c);
+        c = ext_rep(r);
+
         for (m = 1; m <= n; m++)
-        {
           stack_into_box(b, f, c);
-        }
-        c = r.b1;
-        if (c != 0) {
-          stack_into_box(b, f, c); 
-          c = r.b3;
-          for (m = 1; m <= n; m++)
-          {
-            stack_into_box(b, f, c);
-          }
-        }
-        c = r.b0;
-        if (c != 0)
-          stack_into_box(b, f, c);
-        mem[b + 2].cint = w - mem[b + 3].cint;
-    } else b = char_box(f, c);
-  else {    /* c may be used without ... */
+      }
+
+      c = ext_top(r);
+
+      if (c != 0)
+        stack_into_box(b, f, c);
+      
+      depth(b) = w - height(b);
+    }
+    else
+      b = char_box(f, c);
+  else
+  {
     b = new_null_box();
-    mem[b + 1].cint = null_delimiter_space;
-  } 
-  mem[b + 4].cint = half(mem[b + 3].cint - mem[b + 2].cint) - font_info[22 + param_base[eqtb[(hash_size + 1837) + s].hh.v.RH]].cint;
-  Result = b;
-  return Result;
+    width(b) = null_delimiter_space;
+  }
+
+  shift_amount(b) = half(height(b) - depth(b)) - axis_height(s);
+
+  return b;
 }
-/* rebox_ etc used to follow here in tex4.c */
+/* rebox_ etc used to follow here in tex4.c */
\ No newline at end of file
index 2f5b080..eb9da95 100644 (file)
 /* sec 0715 */
 halfword rebox_(halfword b, scaled w)
 {
-  register halfword Result;
   halfword p;
   internal_font_number f;
   scaled v;
-/* begin if (width(b)<>w)and(list_ptr(b)<>null) then l.14010 */
-  if ((mem[b + 1].cint != w) && (mem[b + 5].hh.v.RH != 0))
+
+  if ((width(b) != w) && (list_ptr(b) != 0))
   {
-    if (mem[b].hh.b0 == 1)
+    if (type(b) == vlist_node)
       b = hpack(b, 0, 1);
-    p = mem[b + 5].hh.v.RH;
-/*  if (is_char_node(p))and(link(p)=null) then l.14013 */
-    if (((p >= hi_mem_min)) &&(mem[p].hh.v.RH == 0))
+
+    p = list_ptr(b);
+
+    if (((p >= hi_mem_min)) && (link(p) == 0))
     {
-      f = mem[p].hh.b0;
-      v = font_info[width_base[f] + font_info[char_base[f] + mem[p].hh.b1].qqqq.b0].cint;
-      if (v != mem[b + 1].cint)
-        mem[p].hh.v.RH = new_kern(mem[b + 1].cint - v);
+      f = font(p);
+      v = char_width(f, char_info(f, character(p)));
+
+      if (v != width(b))
+        link(p) = new_kern(width(b) - v);
     }
-    free_node(b, 7);
-    b = new_glue(12);
-    mem[b].hh.v.RH = p;
-/*   while link(p)<>null do p:=link(p); l.14019 */
-    while (mem[p].hh.v.RH != 0)
-      p = mem[p].hh.v.RH;
-    mem[p].hh.v.RH = new_glue(12);
-    Result = hpack(b, w, 0);
+
+    free_node(b, box_node_size);
+    b = new_glue(ss_glue);
+    link(b) = p;
+
+    while (link(p) != 0)
+      p = link(p);
+
+    link(p) = new_glue(ss_glue);
+    return hpack(b, w, exactly);
   }
   else
   {
-    mem[b + 1].cint = w;
-    Result = b;
+    width(b) = w;
+    return b;
   }
-  return Result;
 }
 /* This is to be the start of tex5.c */
 /* sec 0716 */
 halfword math_glue_(halfword g, scaled m)
 {
-  register halfword Result;
   halfword p;
   integer n;
   scaled f;
 
   n = x_over_n(m, 65536L);
   f = tex_remainder;
+
   if (f < 0)
   {
     decr(n);
     f = f + 65536L;
   }
-  p = get_node(4);
-  mem[p + 1].cint = mult_and_add(n, mem[g + 1].cint, xn_over_d(mem[g + 1].cint, f, 65536L), 1073741823L);  /* 2^30 - 1 */
-  mem[p].hh.b0 = mem[g].hh.b0;
-  if (mem[p].hh.b0 == 0)
-    mem[p + 2].cint = mult_and_add(n, mem[g + 2].cint, xn_over_d(mem[g + 2].cint, f, 65536L), 1073741823L);  /* 2^30 - 1 */
+
+  p = get_node(glue_spec_size);
+  width(p) = mult_and_add(n, width(g), xn_over_d(width(g), f, 65536L), 1073741823L);  /* 2^30 - 1 */
+  stretch_order(p) = stretch_order(g);
+
+  if (stretch_order(p) == normal)
+    stretch(p) = mult_and_add(n, stretch(g), xn_over_d(stretch(g), f, 65536L), 1073741823L);  /* 2^30 - 1 */
   else
-    mem[p + 2].cint = mem[g + 2].cint;
-  mem[p].hh.b1 = mem[g].hh.b1;
-  if (mem[p].hh.b1 == 0)
-    mem[p + 3].cint = mult_and_add(n, mem[g + 3].cint, xn_over_d(mem[g + 3].cint, f, 65536L), 1073741823L);  /* 2^30 - 1 */
+    stretch(p) = stretch(g);
+
+  shrink_order(p) = shrink_order(g);
+
+  if (shrink_order(p) == normal)
+    shrink(p) = mult_and_add(n, shrink(g), xn_over_d(shrink(g), f, 65536L), 1073741823L);  /* 2^30 - 1 */
   else
-    mem[p + 3].cint = mem[g + 3].cint;
-  Result = p;
-  return Result;
+    shrink(p) = shrink(g);
+
+  return p;
 }
 /* sec 0717 */
 void math_kern_ (halfword p, scaled m)
@@ -97,55 +103,58 @@ void math_kern_ (halfword p, scaled m)
   integer n;
   scaled f;
 
-  if (mem[p].hh.b1 == 99)
+  if (subtype(p) == mu_glue)
   {
     n = x_over_n(m, 65536L);
     f = tex_remainder;
+
     if (f < 0)
     {
       decr(n);
       f = f + 65536L;
     }
-    mem[p + 1].cint = mult_and_add(n, mem[p + 1].cint, xn_over_d(mem[p + 1].cint, f, 65536L), 1073741823L);  /* 2^30 - 1 */
-/*    mem[p].hh.b1 = 0;  */
-    mem[p].hh.b1 = 1; /* changed in 3.14159 */
+
+    width(p) = mult_and_add(n, width(p), xn_over_d(width(p), f, 65536L), 1073741823L);  /* 2^30 - 1 */
+    subtype(p) = explicit;
   }
 }
 /* sec 0718 */
 void flush_math (void)
 {
-  flush_node_list(mem[head].hh.v.RH);
-  flush_node_list(cur_list.aux_field.cint);
-  mem[head].hh.v.RH = 0;
+  flush_node_list(link(head));
+  flush_node_list(incompleat_noad);
+  link(head) = 0;
   tail = head;
-  cur_list.aux_field.cint = 0;
+  incompleat_noad = 0;
 }
 /* sec 0720 */
 halfword clean_box_(halfword p, small_number s)
 {
-  register halfword Result;
   halfword q;
-  small_number savestyle;
+  small_number save_style;
   halfword x;
   halfword r;
 
-  switch(mem[p].hh.v.RH)
+  switch(math_type(p))
   {
-    case 1:
+    case math_char:
       {
         cur_mlist = new_noad();
-        mem[cur_mlist + 1]= mem[p];
+        mem[nucleus(cur_mlist)] = mem[p];
       }
       break;
-    case 2:
+
+    case sub_box:
       {
-        q = mem[p].hh.v.LH;
+        q = info(p);
         goto lab40;
       }
       break;
-    case 3:
-      cur_mlist = mem[p].hh.v.LH;
+
+    case sub_mlist:
+      cur_mlist = info(p);
       break;
+
     default:
       {
         q = new_null_box();
@@ -153,42 +162,47 @@ halfword clean_box_(halfword p, small_number s)
       }
     break;
   }
-  savestyle = cur_style;
+
+  save_style = cur_style;
   cur_style = s;
   mlist_penalties = false;
   mlist_to_hlist();
-  q = mem[temp_head].hh.v.RH;
-  cur_style = savestyle;
+  q = link(temp_head);
+  cur_style = save_style;
+
   {
-    if (cur_style < 4)
-      cur_size = 0;
+    if (cur_style < script_style)
+      cur_size = text_size;
     else
-      cur_size = 16 * ((cur_style - 2) / 2);
-    cur_mu = x_over_n(font_info[6 + param_base[eqtb[(hash_size + 1837) + cur_size].hh.v.RH]].cint, 18);
+      cur_size = 16 * ((cur_style - text_style) / 2);
+
+    cur_mu = x_over_n(math_quad(cur_size), 18);
   }
 lab40:
   if ((q >= hi_mem_min) || (q == 0))
     x = hpack(q, 0, 1);
-  else if ((mem[q].hh.v.RH == 0) && (mem[q].hh.b0 <= 1) && (mem[q + 4].cint == 0))
+  else if ((link(q) == 0) && (type(q) <= vlist_node) && (shift_amount(q) == 0))
     x = q;
   else
     x = hpack(q, 0, 1);
-  q = mem[x + 5].hh.v.RH;
+
+  q = list_ptr(x);
+
   if ((q >= hi_mem_min))
   {
-    r = mem[q].hh.v.RH;
-/*   if r<>null then if link(r)=null then l.14140 */
+    r = link(q);
+
     if (r != 0)
-      if (mem[r].hh.v.RH == 0)
+      if (link(r) == 0)
         if (!(r >= hi_mem_min))
-          if (mem[r].hh.b0 == 11)
+          if (type(r) == kern_node)
           {
-            free_node(r, 2);
-            mem[q].hh.v.RH = 0;   /* link(q):=null; */
+            free_node(r, small_node_size);
+            link(q) = 0;
           }
   }
-  Result = x;
-  return Result;
+
+  return x;
 }
 /* sec 0722 */
 void fetch_(halfword a)
index 8fbb9cd..865f15d 100644 (file)
@@ -378,10 +378,10 @@ void close_files_and_terminate (void)
     }
 
     if (dvi_limit == half_buf)
-      writedvi(half_buf, dvi_buf_size - 1);
+      write_dvi(half_buf, dvi_buf_size - 1);
 
     if (dvi_ptr > 0)
-      writedvi(0, dvi_ptr - 1); 
+      write_dvi(0, dvi_ptr - 1); 
 
     print_nl("Output written on ");
 
index 1922811..b7baa53 100644 (file)
@@ -1917,6 +1917,8 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 #define math_shift_group  15
 #define math_left_group   16
 #define max_group_code    16
+/* sec 0274 */
+#define saved(a) save_stack[save_ptr + a].cint
 /* sec 0289 */
 #define cs_token_flag     07777 // 4095
 #define left_brace_token  0400  // 256  = 2^8 * left_brace
@@ -1992,6 +1994,8 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 /* sec 0416 */
 #define input_line_no_code (glue_val + 1)
 #define badness_code       (glue_val + 2)
+/* sec 0421 */
+#define max_dimen 07777777777
 /* sec 0438 */
 #define octal_token             (other_token + '\'') // 3111
 #define hex_token               (other_token + '"' ) // 3106
@@ -2085,6 +2089,71 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 #define quad(f)          param(quad_code, f)
 #define extra_space(f)   param(extra_space_code, f)
 /* sec 0564 */
+/* sec 0585 */
+#define set1      128 // c[1]
+#define set2      129 // c[2]
+#define set3      130 // c[3]
+#define set4      131 // c[4]
+#define set_rule  132 // a[4] b[4]
+#define put1      133 // c[1]
+#define put2      134 // c[2]
+#define put3      135 // c[3]
+#define put4      136 // c[4]
+#define put_rule  137 // a[4] b[4]
+#define nop       138 // NULL
+#define bop       139 // c0[4] c1[4] ... c9[4] p[4]
+#define eop       140 // NULL
+//#define dvi_push 141
+//#define dvi_pop  142
+#define right1    143 // b[1]
+#define right2    144 // b[2]
+#define right3    145 // b[3]
+#define right4    146 // b[4]
+#define w0        147 //
+#define w1        148 // b[1]
+#define w2        149 // b[2]
+#define w3        150 // b[3]
+#define w4        151 // b[4]
+#define x0        152 //
+#define x1        153 // b[1]
+#define x2        154 // b[2]
+#define x3        155 // b[3]
+#define x4        156 // b[4]
+#define down1     157 // a[1]
+#define down2     158 // a[2]
+#define down3     159 // a[3]
+#define down4     160 // a[4]
+#define y0        161 //
+#define y1        162 // a[1]
+#define y2        163 // a[2]
+#define y3        164 // a[3]
+#define y4        165 // a[4]
+#define z0        166 //
+#define z1        167 // a[1]
+#define z2        168 // a[2]
+#define z3        169 // a[3]
+#define z4        170 // a[4]
+#define fnt_num_0 171 //
+#define fnt1      235 // k[1]
+#define fnt2      236 // k[2]
+#define fnt3      237 // k[3]
+#define fnt4      238 // k[4]
+#define xxx1      239 // k[1] x[k]
+#define xxx2      240 // k[2] x[k]
+#define xxx3      241 // k[3] x[k]
+#define xxx4      242 // k[4] x[k]
+#define fnt_def1  243 // k[1] c[4] s[4] d[4] a[1] l[1] n[a + l]
+#define fnt_def2  244 // k[2] c[4] s[4] d[4] a[1] l[1] n[a + l]
+#define fnt_def3  245 // k[3] c[4] s[4] d[4] a[1] l[1] n[a + l]
+#define fnt_def4  246 // k[4] c[4] s[4] d[4] a[1] l[1] n[a + l]
+#define pre       247 // i[1] num[4] den[4] mag[4] k[1] x[k]
+#define post      248 //
+#define post_post 249 //
+/* sec 0587 */
+#define id_byte 2
+/* sec 0605 */
+#define movement_node_size 3
+#define location(a) mem[a + 2].cint
 /* sec 0608 */
 #define y_here  1
 #define z_here  2
@@ -2096,6 +2165,9 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 #define none_seen 0
 #define y_seen    6
 #define z_seen    12
+/* sec 0644 */
+#define exactly    0
+#define additional 1
 /* sec 0769 */
 #define u_part(a)     mem[(a) + height_offset].cint
 #define v_part(a)     mem[(a) + depth_offset].cint
@@ -2335,6 +2407,8 @@ EXTERN int tfm_temp;        /* only used in tex3.c 95/Jan/7 */
 /* sec 1344 */
 #define immediate_code    4
 #define set_language_code 5
+/* sec 1371 */
+#define end_write_token (cs_token_flag + end_write)
 /* sec 79 */
 extern void set_cur_lang(void);
 extern str_number make_string_pool (char *s);
index 742c86d..c571a63 100644 (file)
@@ -51,7 +51,7 @@
 #ifdef TeX
   #define dump_file fmt_file
   #define dump_path TEXFORMATPATH
-  #define mwrite_out writedvi
+  #define mwrite_out write_dvi
   #define out_file dvi_file
   #define out_buf dvi_buf
 #else /* not TeX */
@@ -106,10 +106,10 @@ extern bool input_line (FILE *);
 
 /* This was horseshit, since for MSDOS it did no errors checking! - bkph */
 #ifdef TeX
-/* #define  writedvi(a, b)              \
+/* #define  write_dvi(a, b)              \
   (void) fwrite ((char *) &dvi_buf[a], sizeof (dvi_buf[a]),   \
                  (int) ((b) - (a) + 1), dvi_file) */
-#define writedvi(a, b)              \
+#define write_dvi(a, b)              \
   if (fwrite ((char *) &dvi_buf[a], sizeof (dvi_buf[a]),    \
          (int) ((b) - (a) + 1), dvi_file) != (size_t) ((b) - (a) + 1))   \
      FATAL_PERROR ("\n! dvi file")
@@ -128,7 +128,7 @@ extern bool input_line (FILE *);
 /* USE fwrite(...) instead of write(fileno (...)) ! */
 
 #ifdef TeX
-#define writedvi(start, end)            \
+#define write_dvi(start, end)            \
   if (write (fileno (dvi_file), (char *) &dvi_buf[start],     \
              (int) ((end) - (start) + 1))       \
       != (int) ((end) - (start) + 1))         \