OSDN Git Service

char * -> const char *.
[putex/putex.git] / src / texsourc / tex2.c
index 242242d..3c33419 100644 (file)
 /* following bit used to be end of tex1.c */
 #ifdef STAT
 /* sec 0284 */
-void restore_trace_(halfword p, char * s)
+void restore_trace_(pointer p, const char * s)
 {
   begin_diagnostic();
   print_char('{');
-  print_string(s);
+  prints(s);
   print_char(' ');
   show_eqtb(p);
   print_char('}');
@@ -36,7 +36,7 @@ void restore_trace_(halfword p, char * s)
 /* sec 0281 */
 void unsave (void)
 {
-  halfword p;
+  pointer p;
   quarterword l;
   halfword t;
 
@@ -49,7 +49,7 @@ void unsave (void)
       decr(save_ptr);
 
       if (save_type(save_ptr) == level_boundary)
-        goto lab30;
+        goto done;
 
       p = save_index(save_ptr);
 
@@ -106,7 +106,8 @@ void unsave (void)
         }
       }
     }
-lab30:
+
+done:
     cur_group = save_level(save_ptr);
     cur_boundary = save_index(save_ptr);
   }
@@ -124,7 +125,7 @@ void prepare_mag (void)
   {
     print_err("Incompatible magnification (");
     print_int(mag);
-    print_string(");");
+    prints(");");
     print_nl(" the previous value will be retained");
     help2("I can handle only one magnification ratio per job. So I've",
         "reverted to the magnification you used earlier on this run.");
@@ -143,7 +144,7 @@ void prepare_mag (void)
   mag_set = mag;
 }
 /* sec 0295 */
-void token_show_ (halfword p)
+void token_show_ (pointer p)
 {
   if (p != 0)
     show_token_list(link(p), 0, 10000000L);
@@ -175,7 +176,7 @@ void show_cur_cmd_chr (void)
   if (mode != shown_mode)
   {
     print_mode(mode);
-    print_string(": ");
+    prints(": ");
     shown_mode = mode;
   }
 
@@ -188,7 +189,7 @@ void show_context (void)
 {
   char old_setting;
   integer nn;
-  boolean bottomline;
+  boolean bottom_line;
   integer i;
   integer j;
   integer l;
@@ -200,17 +201,17 @@ void show_context (void)
   base_ptr = input_ptr;
   input_stack[base_ptr] = cur_input;
   nn = -1;
-  bottomline = false;
+  bottom_line = false;
 
   while (true)
   {
     cur_input = input_stack[base_ptr];
 
-    if ((state != 0))
-      if ((cur_input.name_field > 17) || (base_ptr == 0))
-        bottomline = true;
+    if ((state != token_list))
+      if ((name > 17) || (base_ptr == 0))
+        bottom_line = true;
 
-    if ((base_ptr == input_ptr) || bottomline || (nn < error_context_lines))
+    if ((base_ptr == input_ptr) || bottom_line || (nn < error_context_lines))
     {
       if ((base_ptr == input_ptr) || (state != token_list) ||
           (index != backed_up) || (loc != 0))
@@ -218,10 +219,10 @@ void show_context (void)
         tally = 0;
         old_setting = selector;
 
-        if (state != 0)
+        if (state != token_list)
         {
-          if (cur_input.name_field <= 17)
-            if ((cur_input.name_field == 0))
+          if (name <= 17)
+            if (name == 0)
               if (base_ptr == 0)
                 print_nl("<*>");
               else
@@ -229,10 +230,12 @@ void show_context (void)
             else
             {
               print_nl("<read ");
-              if (cur_input.name_field == 17)
+
+              if (name == 17)
                 print_char('*');
               else
-                print_int(cur_input.name_field - 1);
+                print_int(name - 1);
+
               print_char('>');
             }
           else
@@ -241,14 +244,12 @@ void show_context (void)
             {
               print_ln();
 
-              if (cur_input.name_field > 17)
-                print(cur_input.name_field);
+              if (name > 17)
+                print(name);
 
               print_char('(');
               print_int(line);
-              print_char(')');
-              print_char(' ');
-              print_char(':');
+              prints(") :");
             }
             else
             {
@@ -258,13 +259,7 @@ void show_context (void)
           }
 
           print_char(' ');
-
-          {
-            l = tally;
-            tally = 0;
-            selector = pseudo;
-            trick_count = 1000000L;
-          }
+          begin_pseudoprint();
 
           if (buffer[limit] == end_line_char)
             j = limit;
@@ -275,13 +270,8 @@ void show_context (void)
             for (i = start; i <= j - 1; i++)
             {
               if (i == loc)
-              {
-                first_count = tally;
-                trick_count = tally + 1 + error_line - half_error_line;
+                set_trick_count();
 
-                if (trick_count < error_line)
-                  trick_count = error_line;
-              }
               print(buffer[i]);
             }
         }
@@ -311,7 +301,7 @@ void show_context (void)
 
             case macro:
               print_ln();
-              print_cs(cur_input.name_field);
+              print_cs(name);
               break;
 
             case output_text:
@@ -359,12 +349,7 @@ void show_context (void)
               break;
           }
 
-          {
-            l = tally;
-            tally = 0;
-            selector = pseudo;
-            trick_count = 1000000L;
-          }
+          begin_pseudoprint();
 
           if (index < macro)
             show_token_list(start, loc, 100000L);
@@ -375,13 +360,7 @@ void show_context (void)
         selector = old_setting;
 
         if (trick_count == 1000000L)
-        {
-          first_count = tally;
-          trick_count = tally + 1 + error_line - half_error_line;
-
-          if (trick_count < error_line)
-            trick_count = error_line;
-        }
+          set_trick_count();
         
         if (tally < trick_count)
           m = tally - first_count;
@@ -395,14 +374,14 @@ void show_context (void)
         }
         else
         {
-          print_string("...");
+          prints("...");
           p = l + first_count - half_error_line + 3;
           n = half_error_line;
         }
 
         for (q = p; q <= first_count - 1; q++)
           print_char(trick_buf[q % error_line]);
-        
+
         print_ln();
 
         for (q = 1; q <= n; q++)
@@ -417,7 +396,8 @@ void show_context (void)
           print_char(trick_buf[q % error_line]);
 
         if (m + n > error_line)
-          print_string("...");
+          prints("...");
+
         incr(nn);
       }
     }
@@ -427,45 +407,19 @@ void show_context (void)
       incr(nn); 
     }
 
-    if (bottomline)
-      goto lab30;
+    if (bottom_line)
+      goto done;
 
     decr(base_ptr);
   }
-lab30:
+
+done:
   cur_input = input_stack[input_ptr];
 }
-//#pragma optimize("g", off)          /* 98/Dec/10 experiment */
 /* sec 0323 */
-void begin_token_list_ (halfword p, quarterword t)
+void begin_token_list_ (pointer p, quarterword t)
 {
-  {
-    if (input_ptr > max_in_stack)
-    {
-      max_in_stack = input_ptr;
-
-#ifdef ALLOCATEINPUTSTACK
-      if (input_ptr == current_stack_size)
-        input_stack = realloc_input_stack(increment_stack_size);
-
-      if (input_ptr == current_stack_size) /* check again after allocation */
-      {
-        overflow("input stack size", current_stack_size);
-        return;     // abort_flag set
-      }
-#else
-      if (input_ptr == stack_size) /* input stack - not dynamic */
-      {
-        overflow("input stack size", stack_size);
-        return;     // abort_flag set
-      }
-#endif
-    }
-
-    input_stack[input_ptr] = cur_input;
-    incr(input_ptr);
-  }
-
+  push_input();
   state = token_list;
   start = p;
   index = t;
@@ -496,11 +450,11 @@ void begin_token_list_ (halfword p, quarterword t)
             break;
 
           default:
-            print_cmd_chr(assign_toks, t + (hash_size + 1307));
+            print_cmd_chr(assign_toks, t - output_text + output_routine_loc);
             break;
         }
 
-        print_string("->");
+        prints("->");
         token_show(p);
         end_diagnostic(false);
       }
@@ -509,7 +463,6 @@ void begin_token_list_ (halfword p, quarterword t)
   else
     loc = p;
 }
-//#pragma optimize("", on)          /* 98/Dec/10 experiment */
 /* sec 0324 */
 void end_token_list (void) 
 { 
@@ -520,6 +473,7 @@ void end_token_list (void)
     else
     {
       delete_token_ref(start);
+
       if (index == macro)
         while (param_ptr > limit)
         {
@@ -534,7 +488,7 @@ void end_token_list (void)
     else
     {
       fatal_error("(interwoven alignment preambles are not allowed)");
-      return;     // abort_flag set
+      return;
     }
 
   pop_input();
@@ -543,7 +497,7 @@ void end_token_list (void)
 /* sec 0325 */
 void back_input (void)
 {
-  halfword p;
+  pointer p;
 
   while ((state == 0) && (loc == 0) &&
       (index != v_template))
@@ -560,31 +514,7 @@ void back_input (void)
     else
       incr(align_state);
 
-  {
-    if (input_ptr > max_in_stack)
-    {
-      max_in_stack = input_ptr;
-#ifdef ALLOCATEINPUTSTACK
-      if (input_ptr == current_stack_size)
-        input_stack = realloc_input_stack(increment_stack_size);
-
-      if (input_ptr == current_stack_size) /* check again after allocation */
-      {
-        overflow("input stack size", current_stack_size);
-        return;     // abort_flag set
-      }
-#else
-      if (input_ptr == stack_size) /* stack size - not dynamic */
-      {
-        overflow("input stack size", stack_size);
-        return;     // abort_flag set
-      }
-#endif
-    }
-    input_stack[input_ptr] = cur_input;
-    incr(input_ptr);
-  }
-
+  push_input();
   state = token_list;
   start = p;
   index = backed_up;
@@ -612,56 +542,38 @@ void begin_file_reading (void)
 {
   if (in_open == max_in_open)
   {
-    overflow("text input levels", max_in_open); /* text input levels - NOT DYNAMIC */
-    return;     // abort_flag set
+    overflow("text input levels", max_in_open);
+    return;
   }
+
 #ifdef ALLOCATEBUFFER
   if (first == current_buf_size)
     buffer = realloc_buffer(increment_buf_size);
 
-  if (first == current_buf_size) /* check again after allocation */
+  if (first == current_buf_size)
   {
     overflow("buffer size", current_buf_size);
-    return;     // abort_flag set
+    return;
   }
 #else
   if (first == buf_size)
   {
-    overflow("buffer size", buf_size);  /* buffer size - not dynamic */
-    return;     // abort_flag set
+    overflow("buffer size", buf_size);
+    return;
   }
 #endif
+
   incr(in_open);
-  if (in_open > high_in_open)     /* 1999 Jan 17 */
+
+  if (in_open > high_in_open) /* 1999 Jan 17 */
     high_in_open = in_open;
-  {
-    if (input_ptr > max_in_stack)
-    {
-      max_in_stack = input_ptr;
-#ifdef ALLOCATEINPUTSTACK
-      if (input_ptr == current_stack_size)
-        input_stack = realloc_input_stack(increment_stack_size);
-      if (input_ptr == current_stack_size)
-      {
-        overflow("input stack size", current_stack_size);  /* check again after allocation */
-        return;     // abort_flag set
-      }
-#else
-      if (input_ptr == stack_size)
-      {
-        overflow("input stack size", stack_size);    /* input stack - not dynamic */
-        return;     // abort_flag set
-      }
-#endif
-    }
-    input_stack[input_ptr] = cur_input;
-    incr(input_ptr);
-  }
+
+  push_input();
   index = in_open;
   line_stack[index] = line;
   start = first;
   state = 1;
-  cur_input.name_field = 0;
+  name = 0;
 }
 /* sec 0329 */
 void end_file_reading (void)
@@ -669,8 +581,8 @@ void end_file_reading (void)
   first = start;
   line = line_stack[index];
 
-  if (cur_input.name_field > 17)
-    a_close(input_file[index]);
+  if (name > 17)
+    a_close(cur_file);
 
   pop_input();
   decr(in_open);
@@ -679,9 +591,8 @@ void end_file_reading (void)
 /* sec 0330 */
 void clear_for_error_prompt (void) 
 {
-  while ((state != 0) &&
-      (cur_input.name_field == 0) && (input_ptr > 0) &&
-      (loc > limit))
+  while ((state != 0) && (name == 0) &&
+    (input_ptr > 0) && (loc > limit))
     end_file_reading();
 
   print_ln();
@@ -689,8 +600,8 @@ void clear_for_error_prompt (void)
 /* sec 0336 */
 void check_outer_validity (void)
 {
-  halfword p;
-  halfword q;
+  pointer p;
+  pointer q;
 
   if (scanner_status != 0)
   {
@@ -698,7 +609,7 @@ void check_outer_validity (void)
 
     if (cur_cs != 0)
     {
-      if ((state == 0) || (cur_input.name_field < 1) || (cur_input.name_field > 17))
+      if ((state == 0) || (name < 1) || (name > 17))
       {
         p = get_avail();
         info(p) = cs_token_flag + cur_cs;
@@ -721,39 +632,40 @@ void check_outer_validity (void)
         print_err("Forbidden control sequence found");
       }
 
-      print_string(" while scanning ");
+      prints(" while scanning ");
       p = get_avail();
 
       switch (scanner_status)
       {
         case defining:
-          print_string("definition");
+          prints("definition");
           info(p) = right_brace_token + '}';
           break;
 
         case matching:
-          print_string("use");
+          prints("use");
           info(p) = par_token;
           long_state = outer_call;
           break;
 
         case aligning:
-          print_string("preamble");
+          prints("preamble");
           info(p) = right_brace_token + '}';
           q = p;
           p = get_avail();
           link(p) = q;
-          info(p) = cs_token_flag + frozen_cr; /*96/Jan/10*/
+          info(p) = cs_token_flag + frozen_cr;
           align_state = -1000000L;
           break;
 
         case absorbing:
-          print_string("text");
+          prints("text");
           info(p) = right_brace_token + '}';
           break;
       }
+
       ins_list(p);
-      print_string(" of ");
+      prints(" of ");
       sprint_cs(warning_index);
       help4("I suspect you have forgotten a `}', causing me",
           "to read past where you wanted me to stop.",
@@ -765,7 +677,7 @@ void check_outer_validity (void)
     {
       print_err("Incomplete ");
       print_cmd_chr(if_test, cur_if);
-      print_string("; all text was ignored after line ");
+      prints("; all text was ignored after line ");
       print_int(skip_line);
       help3("A forbidden control sequence occurred in skipped text.",
           "This kind of error happens when you say `\\if...' and forget",
@@ -776,9 +688,10 @@ void check_outer_validity (void)
       else
         help_line[2] = "The file ended while I was skipping conditional text.";
 
-      cur_tok = cs_token_flag + frozen_fi; /* 96/Jan/10 */
+      cur_tok = cs_token_flag + frozen_fi;
       ins_error();
-  }
+    }
+
     deletions_allowed = true;
   }
 }
@@ -826,19 +739,19 @@ void get_token (void)
 /* sec 0389 */
 void macro_call (void)
 {
-  halfword r;
-  halfword p;
-  halfword q;
-  halfword s;
-  halfword t;
-  halfword u, v;
-  halfword rbrace_ptr;
+  pointer r;
+  pointer p;
+  pointer q;
+  pointer s;
+  pointer t;
+  pointer u, v;
+  pointer rbrace_ptr;
   small_number n;
   halfword unbalance;
   halfword m;
-  halfword ref_count;
+  pointer ref_count;
   small_number save_scanner_status;
-  halfword save_warning_index;
+  pointer save_warning_index;
   ASCII_code match_chr;
 
   save_scanner_status = scanner_status;
@@ -880,7 +793,8 @@ void macro_call (void)
           p = temp_head;
           m = 0;
         }
-lab22:
+
+continu:
         get_token();
 
         if (cur_tok == info(r))
@@ -892,10 +806,10 @@ lab22:
             if (cur_tok < left_brace_limit)
               decr(align_state);
 
-            goto lab40;
+            goto found;
           }
           else
-            goto lab22;
+            goto continu;
         }
 
         if (s != r)
@@ -903,17 +817,18 @@ lab22:
           {
             print_err("Use of ");
             sprint_cs(warning_index);
-            print_string(" doesn't match its definition");
+            prints(" doesn't match its definition");
             help4("If you say, e.g., `\\def\\a1{...}', then you must always",
               "put `1' after `\\a', since control sequence names are",
               "made up of letters only. The macro here has not been",
               "followed by the required stuff, so I'm ignoring it.");
             error();
-            goto lab10;
+            goto exit;
           }
           else
           {
             t = s;
+
             do
               {
                 store_new_token(info(t));
@@ -925,20 +840,20 @@ lab22:
                 {
                   if (u == r)
                     if (cur_tok != info(v))
-                      goto lab30;
+                      goto done;
                     else
                     {
                       r = link(v);
-                      goto lab22;
+                      goto continu;
                     }
 
                     if (info(u) != info(v))
-                      goto lab30;
+                      goto done;
 
                     u = link(u);
                     v = link(v);
                 }
-lab30:
+done:
                 t = link(t);
               }
             while (!(t == r));
@@ -954,7 +869,7 @@ lab30:
               runaway();
               print_err("Paragraph ended before ");
               sprint_cs(warning_index);
-              print_string("was complete");
+              prints("was complete");
               help3("I suspect you've forgotten a `}', causing me to apply this",
                   "control sequence to too much text. How can we recover?",
                   "My plan is to forget the whole thing and hope for the best.");
@@ -967,7 +882,7 @@ lab30:
             for (m = 0; m <= n; m++)
               flush_list(pstack[m]);
 
-            goto lab10;
+            goto exit;
           }
 
         if (cur_tok < right_brace_limit)
@@ -988,7 +903,7 @@ lab30:
                     runaway();
                     print_err("Paragraph ended before ");
                     sprint_cs(warning_index);
-                    print_string(" was complete");
+                    prints(" was complete");
                     help3("I suspect you've forgotten a `}', causing me to apply this",
                         "control sequence to too much text. How can we recover?",
                         "My plan is to forget the whole thing and hope for the best.");
@@ -1000,7 +915,7 @@ lab30:
 
                   for (m = 0; m <= n; m++)
                     flush_list(pstack[m]);
-                  goto lab10;
+                  goto exit;
                 }
 
               if (cur_tok < right_brace_limit)
@@ -1011,10 +926,10 @@ lab30:
                   decr(unbalance);
 
                   if (unbalance == 0)
-                    goto lab31;
+                    goto done1;
                 }
             }
-lab31:
+done1:
             rbrace_ptr = p;
             store_new_token(cur_tok);
           }
@@ -1023,7 +938,7 @@ lab31:
             back_input();
             print_err("Argument of ");
             sprint_cs(warning_index);
-            print_string(" has an extra }");
+            prints(" has an extra }");
             help6("I've run across a `}' that doesn't seem to match anything.",
                 "For example, `\\def\\a#1{...}' and `\\a}' would produce",
                 "this error. If you simply proceed now, the `\\par' that",
@@ -1034,31 +949,32 @@ lab31:
             long_state = call;
             cur_tok = par_token;
             ins_error();
-            goto lab22;
+            goto continu;
           }
         else
         {
           if (cur_tok == space_token)
             if (info(r) <= end_match_token)
               if (info(r) >= match_token)
-                goto lab22;
+                goto continu;
 
           store_new_token(cur_tok);
         }
 
-        incr(m);          /* m may be used without having been ... */
+        incr(m);
 
         if (info(r) > end_match_token)
-          goto lab22;
+          goto continu;
 
         if (info(r) < match_token)
-          goto lab22;
-lab40:
+          goto continu;
+
+found:
         if (s != 0)
         {
           if ((m == 1) && (info(p) < right_brace_limit) && (p != temp_head))
           {
-            link(rbrace_ptr) = 0; /* rbrace_ptr may be used without ... */
+            link(rbrace_ptr) = 0;
             free_avail(p);
             p = link(temp_head);
             pstack[n] = link(p);
@@ -1072,10 +988,10 @@ lab40:
           if (tracing_macros > 0)
           {
             begin_diagnostic();
-            //print_nl(match_chr); /* matchchar may be used without ... */
+            //print_nl(match_chr);
             print_nl(""); print(match_chr);
             print_int(n);
-            print_string("<-");
+            prints("<-");
             show_token_list(pstack[n - 1], 0, 1000);
             end_diagnostic(false);
           }
@@ -1089,7 +1005,7 @@ lab40:
     end_token_list();
 
   begin_token_list(ref_count, macro);
-  cur_input.name_field = warning_index;
+  name = warning_index;
   loc = link(r);
 
   if (n > 0)
@@ -1102,16 +1018,16 @@ lab40:
       if (max_param_stack > current_param_size)
         param_stack = realloc_param_stack(increment_param_size);
 
-      if (max_param_stack > current_param_size) /* check again after allocation */
+      if (max_param_stack > current_param_size)
       {
         overflow("parameter stack size", current_param_size);
-        return;     // abort_flag set
+        return;
       }
 #else
       if (max_param_stack > param_size)
       {
-        overflow("parameter stack size", param_size); /* parameter stack - not dynamic */
-        return;     // abort_flag set
+        overflow("parameter stack size", param_size);
+        return;
       }
 #endif
     }
@@ -1121,7 +1037,8 @@ lab40:
 
     param_ptr = param_ptr + n;
   }
-lab10:
+
+exit:
   scanner_status = save_scanner_status;
   warning_index = save_warning_index;
 }
@@ -1130,7 +1047,7 @@ void insert_relax (void)
 {
   cur_tok = cs_token_flag + cur_cs;
   back_input();
-  cur_tok = cs_token_flag + frozen_relax;  /* 96/Jan/10 */
+  cur_tok = cs_token_flag + frozen_relax;
   back_input();
   index = inserted;
 }
@@ -1142,7 +1059,7 @@ void expand (void)
   integer j;
   integer cv_backup;
   small_number cvl_backup, radix_backup, co_backup;
-  halfword backup_backup;
+  pointer backup_backup;
   small_number save_scanner_status;
 
   cv_backup = cur_val;
@@ -1188,7 +1105,7 @@ void expand (void)
         if (t >= cs_token_flag)
         {
           p = get_avail();
-          info(p) = cs_token_flag + frozen_dont_expand; /*96/Jan/10*/
+          info(p) = cs_token_flag + frozen_dont_expand;
           link(p) = loc;
           start = p;
           loc = p;
@@ -1211,7 +1128,7 @@ void expand (void)
         {
           print_err("Missing ");
           print_esc("endcsname");
-          print_string(" inserted");
+          prints(" inserted");
           help2("The control sequence marked <to be read again> should",
               "not appear between \\csname and \\endcsname.");
           back_error();
@@ -1230,16 +1147,16 @@ void expand (void)
             if (max_buf_stack == current_buf_size)
               buffer = realloc_buffer (increment_buf_size);
 
-            if (max_buf_stack == current_buf_size) /* check again after allocation */
+            if (max_buf_stack == current_buf_size)
             {
               overflow("buffer size", current_buf_size);
-              return;     // abort_flag set
+              return;
             }
 #else
             if (max_buf_stack == buf_size)
             {
-              overflow("buffer size", buf_size); /* buffer size - not dynamic */
-              return;     // abort_flag set
+              overflow("buffer size", buf_size);
+              return;
             }
 #endif
           }
@@ -1336,7 +1253,7 @@ void expand (void)
   }
   else
   {
-    cur_tok = cs_token_flag + frozen_endv; /* 96/Jan/10 */
+    cur_tok = cs_token_flag + frozen_endv;
     back_input();
   }
 
@@ -1349,11 +1266,11 @@ void expand (void)
 /* sec 0380 */
 void get_x_token (void)
 {
-lab20:
+restart:
   get_next();
 
   if (cur_cmd <= max_command)
-    goto lab30;
+    goto done;
 
   if (cur_cmd >= call)
     if (cur_cmd < end_template)
@@ -1362,14 +1279,14 @@ lab20:
     {
       cur_cs = frozen_endv;
       cur_cmd = endv;
-      goto lab30;
+      goto done;
     }
   else
     expand();
 
-  goto lab20;
+  goto restart;
 
-lab30:
+done:
   if (cur_cs == 0)
     cur_tok = (cur_cmd * 256) + cur_chr;
   else
@@ -1427,8 +1344,8 @@ void scan_optional_equals (void)
 /* sec 0407 */
 boolean scan_keyword(const char * s)
 {
-  halfword p;
-  halfword q;
+  pointer p;
+  pointer q;
   const char * k;
 
   p = backup_head;
@@ -1527,7 +1444,7 @@ void scan_twenty_seven_bit_int (void)
 {
   scan_int();
 
-  if ((cur_val < 0) || (cur_val > 134217727L)) /* 2^27 - 1 */
+  if ((cur_val < 0) || (cur_val > 134217727L))
   {
     print_err("Bad delimiter code");
     help2("A numeric delimiter code must be between 0 and 2^{27}-1.",
@@ -1580,7 +1497,7 @@ void find_font_dimen_(boolean writing)
   scan_font_ident();
   f = cur_val;
 
-  if (n < 0 || (n == 0 && font_dimen_zero == 0)) /* change 98/Oct/5 */
+  if (n < 0)
     cur_val = fmem_ptr;
   else
   {
@@ -1629,9 +1546,9 @@ void find_font_dimen_(boolean writing)
   {
     print_err("Font ");
     print_esc(""); print(font_id_text(f));
-    print_string(" has only ");
+    prints(" has only ");
     print_int(font_params[f]);
-    print_string(" fontdimen parameters");
+    prints(" fontdimen parameters");
     help2("To increase the number of font parameters, you must",
       "use \\fontdimen immediately after the \\font is loaded.");
     error();
@@ -1822,7 +1739,7 @@ void scan_something_internal_(small_number level, boolean negative)
       {
         scan_eight_bit_int();
 
-        switch(m)
+        switch (m)
         {
           case int_val:
             cur_val = count(cur_val);
@@ -1865,7 +1782,7 @@ void scan_something_internal_(small_number level, boolean negative)
         cur_val_level = cur_chr;
 
         if (!is_char_node(tail) && (mode != 0))
-          switch(cur_chr)
+          switch (cur_chr)
           {
             case int_val:
               if (type(tail) == penalty_node)
@@ -1910,7 +1827,7 @@ void scan_something_internal_(small_number level, boolean negative)
       {
         print_err("You can't use `");
         print_cmd_chr(cur_cmd, cur_chr);
-        print_string("' after ");
+        prints("' after ");
         print_esc("the");
         help1("I'm forgetting what you said and using zero instead.");
         error();
@@ -1954,22 +1871,23 @@ void get_next (void)
 {
   integer k;
   halfword t;
-/*  char cat; */    /* make this an int ? */
-  int cat;      /* make this an int ? 95/Jan/7 */
+/* char cat; */
+  int cat;
   ASCII_code c, cc;
   char d;
 
-lab20:
+restart:
   cur_cs = 0;
 
   if (state != token_list)
   {
-lab25:
+lab_switch:
     if (loc <= limit)
     {
       cur_chr = buffer[loc];
       incr(loc);
-lab21:
+
+reswitch:
       cur_cmd = cat_code(cur_chr);
 
       switch (state + cur_cmd)
@@ -1977,7 +1895,7 @@ lab21:
         case any_state_plus(ignore):
         case skip_blanks + spacer:
         case new_line + spacer:
-          goto lab25;
+          goto lab_switch;
           break;
 
         case any_state_plus(escape):
@@ -1986,7 +1904,7 @@ lab21:
               cur_cs = null_cs;
             else
             {
-lab26:
+start_cs:
               k = loc;
               cur_chr = buffer[k];
               cat = cat_code(cur_chr);
@@ -2019,27 +1937,18 @@ lab26:
                         if (c < 128)
                         {
                           d = 2;
-                          if ((((c >= 48) && (c <= 57)) || ((c >= 97) && (c <= 102))))
+                          if (is_hex(c))
                             if (k + 2 <= limit)
                             {
                               cc = buffer[k + 2];
 
-                              if ((((cc >= 48) && (cc <= 57)) || ((cc >= 97) && (cc <= 102))))
+                              if (is_hex(cc))
                                 incr(d);
                             }
 
                           if (d > 2)
                           {
-                            if (c <= 57)
-                              cur_chr = c - 48;
-                            else
-                              cur_chr = c - 87;
-
-                            if (cc <= 57)
-                              cur_chr = 16 * cur_chr + cc - 48;
-                            else
-                              cur_chr = 16 * cur_chr + cc - 87;
-
+                            hex_to_cur_chr();
                             buffer[k - 1] = cur_chr;
                           }
                           else if (c < 64)
@@ -2056,7 +1965,7 @@ lab26:
                             incr(k);
                           }
 
-                          goto lab26;
+                          goto start_cs;
                         }
                       }
                 }
@@ -2068,7 +1977,7 @@ lab26:
                 {
                   cur_cs = id_lookup(loc, k - loc);
                   loc = k;
-                  goto lab40;
+                  goto found;
                 }
               }
               else
@@ -2082,27 +1991,19 @@ lab26:
                       if (c < 128)             /* ? */
                       {
                         d = 2;
-                        if ((((c >= 48) && (c <= 57)) || ((c >= 97) && (c <= 102))))
+
+                        if (is_hex(c))
                           if (k + 2 <= limit)
                           {
                             cc = buffer[k + 2];
 
-                            if ((((cc >= 48) && (cc <= 57)) || ((cc >= 97) && (cc <= 102))))
+                            if (is_hex(cc))
                               incr(d);
                           }
 
                         if (d > 2)
                         {
-                          if (c <= 57)
-                            cur_chr = c - 48;
-                          else
-                            cur_chr = c - 87;
-
-                          if (cc <= 57)          /* cc may be used without ... */
-                            cur_chr = 16 * cur_chr + cc - 48;
-                          else
-                            cur_chr = 16 * cur_chr + cc - 87;
-
+                          hex_to_cur_chr();
                           buffer[k - 1] = cur_chr;
                         }
                         else if (c < 64)
@@ -2118,14 +2019,16 @@ lab26:
                           buffer[k] = buffer[k + d];
                           incr(k);
                         }
-                        goto lab26;
+
+                        goto start_cs;
                       }
                     }
               }
+
               cur_cs = single_base + buffer[loc];
               incr(loc);
             }
-lab40:
+found:
             cur_cmd = eq_type(cur_cs);
             cur_chr = equiv(cur_cs);
             
@@ -2157,26 +2060,16 @@ lab40:
                 {
                   loc = loc + 2;
 
-                  if ((((c >= 48) && (c <= 57)) || ((c >= 97) && (c <= 102))))
+                  if (is_hex(c))
                     if (loc <= limit)
                     {
                       cc = buffer[loc];
 
-                      if ((((cc >= 48) && (cc <= 57)) || ((cc >= 97) && (cc <= 102))))
+                      if (is_hex(cc))
                       {
                         incr(loc);
-
-                        if (c <= 57)
-                          cur_chr = c - 48;
-                        else
-                          cur_chr = c - 87;
-
-                        if (cc <= 57)
-                          cur_chr = 16 * cur_chr + cc - 48;
-                        else
-                          cur_chr = 16 * cur_chr + cc - 87;
-
-                        goto lab21;
+                        hex_to_cur_chr();
+                        goto reswitch;
                       }
                     }
 
@@ -2185,7 +2078,7 @@ lab40:
                   else
                     cur_chr = c - 64;
 
-                  goto lab21;
+                  goto reswitch;
                 }
               }
 
@@ -2201,7 +2094,7 @@ lab40:
             deletions_allowed = false;
             error();
             deletions_allowed = true;
-            goto lab20;
+            goto restart;
           }
           break;
 
@@ -2224,7 +2117,7 @@ lab40:
         case any_state_plus(comment):
           {
             loc = limit + 1;
-            goto lab25;
+            goto lab_switch;
           }
           break;
 
@@ -2277,14 +2170,14 @@ lab40:
     {
       state = new_line;
 
-      if (cur_input.name_field > 17)
+      if (name > 17)
       {
         incr(line);
         first = start;
 
         if (!force_eof)
         {
-          if (input_ln(input_file[index], true))
+          if (input_ln(cur_file, true))
             firm_up_the_line();
           else
             force_eof = true;
@@ -2294,16 +2187,14 @@ lab40:
         {
           print_char(')');
           decr(open_parens);
-#ifndef _WINDOWS
-          fflush(stdout);
-#endif
+          update_terminal();
           force_eof = false;
           end_file_reading();
           check_outer_validity();
-          goto lab20;
+          goto restart;
         }
 
-        if ((end_line_char < 0) || (end_line_char > 255))
+        if (end_line_char_inactive())
           decr(limit);
         else
           buffer[limit] = end_line_char;
@@ -2313,7 +2204,7 @@ lab40:
       }
       else
       {
-        if (!(cur_input.name_field == 0))
+        if (!(name == 0))
         {
           cur_cmd = 0;
           cur_chr = 0;
@@ -2323,7 +2214,7 @@ lab40:
         if (input_ptr > 0)
         {
           end_file_reading();
-          goto lab20;
+          goto restart;
         }
 
         if (selector < log_only)
@@ -2331,7 +2222,7 @@ lab40:
 
         if (interaction > nonstop_mode)
         {
-          if ((end_line_char < 0) || (end_line_char > 255))
+          if (end_line_char_inactive())
             incr(limit);
 
           if (limit == start)
@@ -2342,7 +2233,7 @@ lab40:
           prompt_input("*");
           limit = last;
 
-          if ((end_line_char < 0) || (end_line_char > 255))
+          if (end_line_char_inactive())
             decr(limit);
           else
             buffer[limit]= end_line_char;
@@ -2353,12 +2244,12 @@ lab40:
         else
         {
           fatal_error("*** (job aborted, no legal \\end found)");
-          return;     // abort_flag set
+          return;
         }
       }
 
       check_interrupt();
-      goto lab25;
+      goto lab_switch;
     }
   }
   else if (loc != 0)
@@ -2409,7 +2300,7 @@ lab40:
         case out_param:
           {
             begin_token_list(param_stack[limit + cur_chr - 1], parameter);
-            goto lab20;
+            goto restart;
           }
           break;
 
@@ -2421,7 +2312,7 @@ lab40:
   else
   {
     end_token_list();
-    goto lab20;
+    goto restart;
   }
 
   if (cur_cmd <= car_ret)
@@ -2431,7 +2322,7 @@ lab40:
         if ((scanner_status == aligning) && (cur_align == 0))
         {
           fatal_error("(interwoven alignment preambles are not allowed)");
-          return;     // abort_flag set
+          return;
         }
 
         cur_cmd = extra_info(cur_align);
@@ -2443,6 +2334,6 @@ lab40:
           begin_token_list(v_part(cur_align), v_template);
 
         align_state = 1000000L;
-        goto lab20;
+        goto restart;
       }
 }
\ No newline at end of file