OSDN Git Service

removed libmd5.
[putex/putex.git] / src / texsourc / tex3.c
index 0baadff..8dbdc16 100644 (file)
-/* Copyright 2014 Clerk Ma
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301 USA.  */
-
-#define EXTERN extern
-
-#include "texd.h"
-
-/* sec 0440 */
-void scan_int (void)
-{
-  boolean negative;
-  integer m;
-  small_number d;
-  boolean vacuous;
-  boolean OKsofar;
-
-  radix = 0;
-  OKsofar = true;
-  negative = false;
-
-  do
-    {
-      do 
-        {
-          get_x_token();
-        }
-      while (!(cur_cmd != spacer));
-
-      if (cur_tok == other_token + '-')
-      {
-        negative = !negative;
-        cur_tok = other_token + '+';
-      }
-    }
-  while (!(cur_tok != other_token + '+'));
-
-  if (cur_tok == alpha_token)
-  {
-    get_token();
-
-    if (cur_tok < cs_token_flag)
-    {
-      cur_val = cur_chr;
-
-      if (cur_cmd <= right_brace)
-        if (cur_cmd == right_brace)
-          incr(align_state);
-        else
-          decr(align_state);
-    }
-    else if (cur_tok < cs_token_flag + single_base)
-      cur_val = cur_tok - cs_token_flag - active_base;
-    else
-      cur_val = cur_tok - cs_token_flag - single_base;
-
-    if (cur_val > 255)
-    {
-      print_err("Improper alphabetic constant");
-      help2("A one-character control sequence belongs after a ` mark.",
-        "So I'm essentially inserting \\0 here.");
-      cur_val = '0';
-      back_error();
-    }
-    else
-    {
-      get_x_token();
-
-      if (cur_cmd != spacer)
-        back_input();
-    }
-  }
-  else if ((cur_cmd >= min_internal) && (cur_cmd <= max_internal))
-  {
-    scan_something_internal(int_val, false);
-  }
-  else
-  {
-    radix = 10;
-    m = 214748364L;   /* 7FFFFFFF hex */
-
-    if (cur_tok == octal_token)
-    {
-      radix = 8;
-      m = 268435456L;   /* 2^28 */
-      get_x_token();
-    }
-    else if (cur_tok == hex_token)
-    {
-      radix = 16;
-      m = 134217728L;   /* 2^27 8000000 hex */
-      get_x_token();
-    }
-
-    vacuous = true;
-    cur_val = 0;
-
-    while (true)
-    {
-      if ((cur_tok < zero_token + radix) && (cur_tok >= zero_token) && (cur_tok <= zero_token + 9))
-        d = cur_tok - zero_token;
-      else if (radix == 16)
-        if ((cur_tok <= A_token + 5) && (cur_tok >= A_token))
-          d = cur_tok - A_token + 10;
-        else if ((cur_tok <= other_A_token + 5) && (cur_tok >= other_A_token))
-          d = cur_tok - other_A_token;
-        else
-          goto lab30;
-      else
-        goto lab30;
-
-      vacuous = false;
-
-      if ((cur_val >= m) && ((cur_val > m) || (d > 7) || (radix != 10)))
-      {
-        if (OKsofar)
-        {
-          print_err("Number too big");
-          help2("I can only go up to 2147483647='17777777777=\"7FFFFFFF,",
-            "so I'm using that number instead of yours.");
-          error();
-          cur_val = 2147483647L;    /* 7FFFFFFF hex */
-          OKsofar = false;
-        }
-      }
-      else
-        cur_val = cur_val * radix + d;
-      get_x_token();
-    }
-lab30:;
-
-    if (vacuous)
-    {
-      print_err("Missing number, treated as zero");
-      help3("A number should have been here; I inserted `0'.",
-        "(If you can't figure out why I needed to see a number,",
-        "look up `weird error' in the index to The TeXbook.)");
-      back_error();
-    } 
-    else if (cur_cmd != spacer)
-      back_input();
-  }
-
-  if (negative)
-    cur_val = - (integer) cur_val;
-}
-/* sec 0448 */
-void scan_dimen_(boolean mu, boolean inf, boolean shortcut)
-{
-  boolean negative;
-  integer f;
-  integer num, denom;
-  small_number k, kk;
-  halfword p, q;
-  scaled v;
-  integer savecurval;
-
-  f = 0;
-  arith_error = false;
-  cur_order = 0;
-  negative = false;
-
-  if (!shortcut)
-  {
-    negative = false;
-
-    do
-      {
-        do
-          {
-            get_x_token();
-          }
-        while (!(cur_cmd != spacer));
-
-        if (cur_tok == other_token + '-')
-        {
-          negative = ! negative;
-          cur_tok = other_token + '+';
-        }
-      }
-    while (!(cur_tok != other_token + '+'));
-
-    if ((cur_cmd >= min_internal) && (cur_cmd <= max_internal))
-    {
-      if (mu)
-      {
-        scan_something_internal(mu_val, false);
-
-        if (cur_val_level >= glue_val)
-        {
-          v = width(cur_val);
-          delete_glue_ref(cur_val);
-          cur_val = v;
-        }
-
-        if (cur_val_level == mu_val)
-          goto lab89;
-
-        if (cur_val_level != int_val)
-          mu_error();
-      }
-      else
-      {
-        scan_something_internal(dimen_val, false);
-
-        if (cur_val_level == dimen_val)
-          goto lab89;
-      }
-    }
-    else
-    {
-      back_input();
-
-      if (cur_tok == continental_point_token)
-        cur_tok = point_token;
-
-      if (cur_tok != point_token)
-      {
-        scan_int();
-      }
-      else
-      {
-        radix = 10;
-        cur_val = 0;
-      }
-
-      if (cur_tok == continental_point_token)
-        cur_tok = point_token;
-
-      if ((radix == 10) && (cur_tok == point_token))
-      {
-        k = 0;
-        p = 0;      /* p:=null l.8883 */
-        get_token();
-
-        while (true)
-        {
-          get_x_token();
-
-          if ((cur_tok > zero_token + 9) || (cur_tok < zero_token))
-            goto lab31;
-
-          if (k < 17)
-          {
-            q = get_avail();
-            link(q) = p;
-            info(q) = cur_tok - zero_token;
-            p = q;
-            incr(k);
-          }
-        }
-lab31:
-        for (kk = k; kk >= 1; kk--)
-        {
-          dig[kk - 1] = info(p);
-          q = p;
-          p = link(p);
-          free_avail(q);
-        }
-
-        f = round_decimals(k);
-
-        if (cur_cmd != spacer)
-          back_input();
-        }
-      }
-  }
-
-  if (cur_val < 0)
-  {
-    negative = !negative;
-    cur_val = - (integer) cur_val;
-  }
-
-  if (inf)
-  {
-    if (scan_keyword("fil"))
-    {
-      cur_order = fil;
-
-      while (scan_keyword("l"))
-      {
-        if (cur_order == filll)
-        {
-          print_err("Illegal unit of measure (");
-          print_string("replaced by filll)");
-          help1("I dddon't go any higher than filll.");
-          error();
-        }
-        else
-          incr(cur_order);
-      }
-      goto lab88;
-    }
-  }
-
-  savecurval = cur_val;
-
-  do
-    {
-      get_x_token();
-    }
-  while (!(cur_cmd != spacer));
-
-  if ((cur_cmd < min_internal) || (cur_cmd > max_internal))
-    back_input();
-  else
-  {
-    if (mu)
-    {
-      scan_something_internal(mu_val, false);
-
-      if (cur_val_level >= glue_val)
-      {
-        v = width(cur_val);
-        delete_glue_ref(cur_val);
-        cur_val = v;
-      }
-
-      if (cur_val_level != mu_val)
-      {
-        mu_error();
-      }
-    }
-    else
-    {
-      scan_something_internal(dimen_val, false);
-    }
-
-    v = cur_val;
-    goto lab40;
-  }
-
-  if (mu)
-    goto lab45;
-
-  if (scan_keyword("em"))
-    v = quad(cur_font);
-  else if (scan_keyword("ex"))
-    v = x_height(cur_font);
-  else
-    goto lab45;
-
-  {
-    get_x_token();
-
-    if (cur_cmd != spacer)
-      back_input();
-  }
-lab40:
-  cur_val = mult_and_add(savecurval, v, xn_over_d(v, f, 65536L), 1073741823L);   /* 2^30 - 1 */
-  goto lab89;
-lab45:
-  if (mu)
-  {
-    if (scan_keyword("mu"))
-      goto lab88;
-    else
-    {
-      print_err("Illegal unit of measure (");
-      print_string("mu inserted)");
-      help4("The unit of measurement in math glue must be mu.",
-          "To recover gracefully from this error, it's best to",
-          "delete the erroneous units; e.g., type `2' to delete",
-          "two letters. (See Chapter 27 of The TeXbook.)");
-      error();
-      goto lab88;
-    }
-  }
-
-  if (scan_keyword("true"))
-  {
-    prepare_mag();
-
-    if (mag != 1000)
-    {
-      cur_val = xn_over_d(cur_val, 1000, mag);
-      f = (1000 * f + 65536L * tex_remainder) / mag;
-      cur_val = cur_val + (f / 65536L);
-      f = f % 65536L;
-    }
-  }
-
-  if (scan_keyword("pt"))
-    goto lab88;
-
-  if (scan_keyword("in"))
-    set_conversion(7227, 100);
-  else if (scan_keyword("pc"))
-    set_conversion(12, 1);
-  else if (scan_keyword("cm"))
-    set_conversion(7227, 254);
-  else if (scan_keyword("mm"))
-    set_conversion(7227, 2540);
-  else if (scan_keyword("bp"))
-    set_conversion(7227, 7200);
-  else if (scan_keyword("dd"))
-    set_conversion(1238, 1157);
-  else if (scan_keyword("cc"))
-    set_conversion(14856, 1157);
-  else if (scan_keyword("Q"))
-    set_conversion(7227, 10160);
-  else if (scan_keyword("H"))
-    set_conversion(7227, 10160);
-  else if (scan_keyword("sp"))
-    goto lab30;
-  else
-  {
-    print_err("Illegal unit of measure (");
-    print_string("pt inserted)");
-    help6("Dimensions can be in units of em, ex, in, pt, pc,",
-      "cm, mm, dd, cc, bp, or sp; but yours is a new one!",
-      "I'll assume that you meant to say pt, for printer's points.",
-      "To recover gracefully from this error, it's best to",
-      "delete the erroneous units; e.g., type `2' to delete",
-      "two letters. (See Chapter 27 of The TeXbook.)");
-    error();
-    goto lab32;
-  }
-
-  cur_val = xn_over_d(cur_val, num, denom);
-  f = (num * f + 65536L * tex_remainder) / denom;
-  cur_val = cur_val +(f / 65536L);
-  f = f % 65536L;
-lab32:;
-lab88:
-  if (cur_val >= 16384)     /* 2^14 */
-    arith_error = true;
-  else
-    cur_val = cur_val * 65536L + f;
-lab30:;
-  {
-    get_x_token();
-
-    if (cur_cmd != spacer)
-      back_input();
-  }
-lab89:
-  if (arith_error || (abs(cur_val) >= 1073741824L)) /* 2^30 */
-  {
-    print_err("Dimension too large");
-    help2("I can't work with sizes bigger than about 19 feet.",
-        "Continue and I'll use the largest value I can.");
-    error();
-    cur_val = 1073741823L;  /* 2^30 - 1 */
-    arith_error = false;
-  }
-
-  if (negative)
-    cur_val = - (integer) cur_val;
-}
-/* sec 0461 */
-void scan_glue_(small_number level)
-{
-  boolean negative;
-  halfword q;
-  boolean mu;
-
-  mu = (level == mu_val);
-  negative = false;
-
-  do
-    {
-      do
-        {
-          get_x_token();
-        }
-      while (!(cur_cmd != spacer));
-
-      if (cur_tok == other_token + '-')
-      {
-        negative = !negative;
-        cur_tok = other_token + '+';
-      }
-    }
-  while (!(cur_tok != other_token + '+'));
-
-  if ((cur_cmd >= min_internal) && (cur_cmd <= max_internal))
-  {
-    scan_something_internal(level, negative);
-
-    if (cur_val_level >= glue_val)
-    {
-      if (cur_val_level != level)
-      {
-        mu_error();
-      }
-      return;
-    }
-
-    if (cur_val_level == int_val)
-    {
-      scan_dimen(mu, false, true);
-    }
-    else if (level == mu_val)
-    {
-      mu_error();
-    }
-  }
-  else
-  {
-    back_input();
-    scan_dimen(mu, false, false);
-
-    if (negative)
-      cur_val = - (integer) cur_val;
-  }
-  q = new_spec(zero_glue);
-  width(q) = cur_val;
-
-  if (scan_keyword("plus"))
-  {
-    scan_dimen(mu, true, false);
-    stretch(q) = cur_val;
-    stretch_order(q) = cur_order;
-  }
-
-  if (scan_keyword("minus"))
-  {
-    scan_dimen(mu, true, false);
-    shrink(q) = cur_val;
-    shrink_order(q) = cur_order;
-  }
-
-  cur_val = q;
-}
-/* sec 0463 */
-halfword scan_rule_spec (void)
-{
-  halfword q;
-
-  q = new_rule();
-
-  if (cur_cmd == vrule)
-    width(q) = default_rule;
-  else
-  {
-    height(q) = default_rule;
-    depth(q) = 0;
-  }
-
-lab21:
-
-  if (scan_keyword("width"))
-  {
-    scan_dimen(false, false, false);
-    width(q) = cur_val;
-    goto lab21;
-  }
-
-  if (scan_keyword("height"))
-  {
-    scan_dimen(false, false, false);
-    height(q) = cur_val;
-    goto lab21;
-  }
-
-  if (scan_keyword("depth"))
-  {
-    scan_dimen(false, false, false);
-    depth(q) = cur_val;
-    goto lab21;
-  }
-
-  return q;
-}
-/* sec 0464 */
-halfword str_toks_(pool_pointer b)
-{
-  halfword p;
-  halfword q;
-  halfword t;
-  pool_pointer k;
-
-  str_room(1);
-  p = temp_head;
-  link(p) = 0;
-  k = b;
-
-  while (k < pool_ptr)
-  {
-    t = str_pool[k];
-
-    if (t == ' ')
-      t = space_token;
-    else
-      t = other_token + t;
-
-    fast_store_new_token(t);
-    incr(k);
-  }
-
-  pool_ptr = b;
-
-  return p;
-}
-/* sec 0465 */
-halfword the_toks (void)
-{
-  register halfword Result;
-  char old_setting;
-  halfword p, q, r;
-  pool_pointer b;
-
-  get_x_token();
-  scan_something_internal(tok_val, false);
-
-  if (cur_val_level >= ident_val)
-  {
-    p = temp_head;
-    link(p) = 0;
-
-    if (cur_val_level == ident_val)
-      store_new_token(cs_token_flag + cur_val);
-    else if (cur_val != 0)
-    {
-      r = link(cur_val);
-
-      while (r != 0)
-      {
-        fast_store_new_token(info(r));
-        r = link(r);
-      }
-    }
-
-    Result = p;
-  }
-  else
-  {
-    old_setting = selector;
-    selector = new_string;
-    b = pool_ptr;
-
-    switch (cur_val_level)
-    {
-      case int_val:
-        print_int(cur_val);
-        break;
-      case dimen_val:
-        {
-          print_scaled(cur_val);
-          print_string("pt");
-        }
-        break;
-      case glue_val:
-        {
-          print_spec(cur_val, "pt");
-          delete_glue_ref(cur_val);
-        }
-        break;
-      case mu_val:
-        {
-          print_spec(cur_val, "mu");
-          delete_glue_ref(cur_val);
-        }
-        break;
-    }
-    selector = old_setting;
-    Result = str_toks(b);
-  }
-
-  return Result;
-}
-/* sec 0467 */
-void ins_the_toks (void) 
-{ 
-  link(garbage) = the_toks();
-  begin_token_list(link(temp_head), 4);
-}
-/* sec 0470 */
-void conv_toks (void)
-{
-  char old_setting;
-  char c;
-  small_number savescannerstatus;
-  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;
-      scanner_status = 0;
-      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;
-
-  switch (c)
-  {
-    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]);
-
-      if (font_size[cur_val] != font_dsize[cur_val])
-      {
-        print_string(" at ");
-        print_scaled(font_size[cur_val]);
-        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);
-}
-/* sec 0473 */
-halfword scan_toks_(boolean macrodef, boolean xpand)
-{
-  register halfword Result;
-  halfword t;
-  halfword s;
-  halfword p;
-  halfword q;
-  halfword unbalance;
-  halfword hashbrace;
-
-  if (macrodef)
-    scanner_status = defining;
-  else
-    scanner_status = absorbing;
-
-  warning_index = cur_cs;
-  def_ref = get_avail();
-  token_ref_count(def_ref) = 0;
-  p = def_ref;
-  hashbrace = 0;
-  t = zero_token;
-
-  if (macrodef)
-  {
-    while (true)
-    {
-      get_token();
-
-      if (cur_tok < right_brace_limit)
-        goto lab31;
-
-      if (cur_cmd == mac_param)
-      {
-        s = match_token + cur_chr;
-        get_token();
-
-        if (cur_cmd == left_brace)
-        {
-          hashbrace = cur_tok;
-          store_new_token(cur_tok);
-          store_new_token(end_match_token);
-          goto lab30;
-        }
-
-        if (t == zero_token + 9)
-        {
-          print_err("You already have nine parameters");
-          help1("I'm going to ignore the # sign you just used.");
-          error();
-        }
-        else
-        {
-          incr(t);
-
-          if (cur_tok != t)
-          {
-            print_err("Parameters must be numbered consecutively");
-            help2("I've inserted the digit you should have used after the #.",
-                "Type `1' to delete what you did use.");
-            back_error();
-          }
-          cur_tok = s;
-        }
-      }
-
-      store_new_token(cur_tok);
-    }
-
-lab31:
-    store_new_token(end_match_token);
-
-    if (cur_cmd == right_brace)
-    {
-      print_err("Missing { inserted");
-      incr(align_state);
-      help2("Where was the left brace? You said something like `\\def\\a}',",
-          "which I'm going to interpret as `\\def\\a{}'.");
-      error();
-      goto lab40;
-    }
-lab30:;
-  }
-  else
-  {
-    scan_left_brace();
-  }
-
-  unbalance = 1;
-
-  while (true)
-  {
-    if (xpand)
-    {
-      while (true)
-      {
-        get_next();
-
-        if (cur_cmd <= max_command)
-          goto lab32;
-
-        if (cur_cmd != the)
-        {
-          expand();
-        }
-        else
-        {
-          q = the_toks();
-
-          if (link(temp_head) != 0)
-          {
-            link(p) = link(temp_head);
-            p = q;
-          }
-        }
-      }
-lab32:
-      x_token();
-    }
-    else
-      get_token();
-
-    if (cur_tok < right_brace_limit)
-      if (cur_cmd < right_brace)
-        incr(unbalance);
-      else
-      {
-        decr(unbalance);
-
-        if (unbalance == 0)
-          goto lab40;
-      }
-    else if (cur_cmd == mac_param)
-      if (macrodef)
-      {
-        s = cur_tok;
-
-        if (xpand)
-          get_x_token();
-        else
-          get_token();
-
-        if (cur_cmd != mac_param)
-          if ((cur_tok <= zero_token) || (cur_tok > t))
-          {
-            print_err("Illegal parameter number in definition of ");
-            sprint_cs(warning_index);
-            help3("You meant to type ## instead of #, right?",
-                "Or maybe a } was forgotten somewhere earlier, and things",
-                "are all screwed up? I'm going to assume that you meant ##.");
-            back_error();
-            cur_tok = s;
-          }
-          else
-            cur_tok = out_param_token - '0' + cur_chr;
-      }
-
-    store_new_token(cur_tok);
-  }
-lab40:
-  scanner_status = 0;
-
-  if (hashbrace != 0)
-    store_new_token(hashbrace);
-
-  Result = p;
-  return Result;
-}
-/* used only in ITEX.C */
-/* sec 0482 */
-void read_toks_(integer n, halfword r)
-{
-  halfword p;
-  halfword q;
-  integer s;
-/*  small_number m;  */
-  int m; /* 95/Jan/7 */
-
-  scanner_status = defining;
-  warning_index = r;
-  def_ref = get_avail();
-  token_ref_count(def_ref) = 0;
-  p = def_ref;
-  store_new_token(end_match_token);
-
-  if ((n < 0) || (n > 15))
-    m = 16;
-  else
-    m = n;
-
-  s = align_state;
-  align_state = 1000000L;
-
-  do
-    {
-      begin_file_reading();
-      cur_input.name_field = m + 1;
-
-      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
-        {
-          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
-        {
-          (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)
-          {
-            runaway();
-            print_err("File ended within ");
-            print_esc("read");
-            help1("This \\read has unbalanced braces.");
-            align_state = 1000000L;
-            error();
-          }
-        }
-      }
-
-      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;
-        }
-
-        store_new_token(cur_tok);
-      }
-lab30:
-      end_file_reading();
-    }
-  while(!(align_state == 1000000L));
-
-  cur_val = def_ref;
-  scanner_status = normal;
-  align_state = s;
-}
-/* sec 0494 */
-void pass_text (void)
-{
-  integer l;
-  small_number savescannerstatus;
-
-  savescannerstatus = scanner_status;
-  scanner_status = skipping;
-  l = 0;
-  skip_line = line;
-
-  while (true)
-  {
-    get_next();
-
-    if (cur_cmd == fi_or_else)
-    {
-      if (l == 0)
-        goto lab30;
-
-      if (cur_chr == 2)
-        decr(l);
-    }
-    else if (cur_cmd == if_test)
-      incr(l);
-  }
-lab30:
-  scanner_status = savescannerstatus;
-}
-/* sec 0497 */
-void change_if_limit_(small_number l, halfword p)
-{
-  halfword q;
-
-  if (p == cond_ptr)
-    if_limit = l;
-  else
-  {
-    q = cond_ptr;
-
-    while (true)
-    {
-      if (q == 0)
-      {
-        confusion("if");
-        return;       // abort_flag set
-      }
-
-      if (link(q) == p)
-      {
-        type(p) = l;
-        return;
-      }
-
-      q = link(q);
-    }
-  }
-}
-/* called from tex2.c */
-/* sec 0498 */
-void conditional (void)
-{
-  boolean b;
-  char r;
-  integer m, n;
-  halfword p, q;
-  small_number savescannerstatus;
-  halfword savecondptr;
-  small_number thisif;
-
-  {
-    p = get_node(if_node_size);
-    link(p) = cond_ptr;
-    type(p) = if_limit;
-    subtype(p) = cur_if;
-    if_line_field(p) = if_line;
-    cond_ptr = p;
-    cur_if = cur_chr;
-    if_limit = if_code;
-    if_line = line;
-  }
-
-  savecondptr = cond_ptr;
-  thisif = cur_chr;
-
-  switch (thisif)
-  {
-    case if_char_code:
-    case if_cat_code:
-      {
-        {
-          get_x_token();
-
-          if (cur_cmd == relax)
-            if (cur_chr == no_expand_flag)
-            {
-              cur_cmd = active_char;
-              cur_chr = cur_tok - cs_token_flag - active_base;
-            }
-        }
-
-        if ((cur_cmd > active_char) || (cur_chr > 255))
-        {
-          m = relax;
-          n = 256;
-        }
-        else
-        {
-          m = cur_cmd;
-          n = cur_chr;
-        }
-        {
-          get_x_token();
-
-          if (cur_cmd == relax)
-            if (cur_chr == no_expand_flag)
-            {
-              cur_cmd = active_char;
-              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:
-      {
-        if (thisif == if_int_code)
-          scan_int();
-        else
-          scan_dimen(false, false, false);
-
-        n = cur_val;
-        
-        do
-          {
-            get_x_token();
-          }
-        while(!(cur_cmd != spacer));
-
-        if ((cur_tok >= other_token + '<') && (cur_tok <= other_token + '>'))
-          r = cur_tok - other_token;
-        else
-        {
-          print_err("Missing = inserted for ");
-          print_cmd_chr(if_test, thisif);
-          help1("I was expecting to see `<', `=', or `>'. Didn't.");
-          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)
-          b = false;
-        else if (thisif == if_hbox_code)
-          b = (type(p) == hlist_node);
-        else
-          b = (type(p) == vlist_node);
-      }
-      break;
-
-    case ifx_code:
-      {
-        savescannerstatus = scanner_status;
-        scanner_status = 0;
-        get_next();
-        n = cur_cs;
-        p = cur_cmd;
-        q = cur_chr;
-        get_next();
-
-        if (cur_cmd != p)
-          b = false;
-        else if (cur_cmd < call)
-          b = (cur_chr == q);
-        else
-        {
-          p = link(cur_chr);
-          q = link(equiv(n));
-
-          if (p == q)
-            b = true;
-          else
-          {
-            while ((p != 0) && (q != 0))
-              if (info(p) != info(q))
-                p = 0;
-              else
-              {
-                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] == 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();
-          print_string("{case ");
-          print_int(n); 
-          print_char('}');
-          end_diagnostic(false);
-        }
-
-        while (n != 0)
-        {
-          pass_text();
-
-          if (cond_ptr == savecondptr)
-            if (cur_chr == or_code)
-              decr(n);
-            else 
-              goto lab50;
-          else if (cur_chr == fi_code)
-          {
-            p = cond_ptr;
-            if_line = if_line_field(p);
-            cur_if = subtype(p);
-            if_limit = type(p);
-            cond_ptr = link(p);
-            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)
-  {
-    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.");
-      error();
-    }
-    else if (cur_chr == fi_code)
-    {
-      p = cond_ptr;
-      if_line = if_line_field(p);
-      cur_if = subtype(p);
-      if_limit = type(p);
-      cond_ptr = link(p);
-      free_node(p, if_node_size);
-    }
-  }
-
-lab50:
-  if (cur_chr == fi_code)
-  {
-    p = cond_ptr;
-    if_line = if_line_field(p);
-    cur_if = subtype(p);
-    if_limit = type(p);
-    cond_ptr = link(p);
-    free_node(p, if_node_size);
-  }
-  else
-    if_limit = fi_code;
-}
-/* sec 0515 */
-void begin_name (void)
-{
-  area_delimiter = 0;
-  ext_delimiter = 0;
-}
-/* This gathers up a file name and makes a string of it */
-/* Also tries to break it into `file area' `file name' and `file extension' */
-/* Used by scan_file_name and prompt_file_name */
-/* We assume tilde has been converted to pseudo_tilde and space to pseudo_space */
-/* returns false if it is given a space character - end of file name */
-/* sec 0516 */
-boolean more_name_(ASCII_code c)
-{
-  if (quoted_file_name == 0 && c == ' ')
-    return false;
-  else if (quoted_file_name != 0 && c == '"')
-  {
-    quoted_file_name = 0; /* catch next space character */
-    return true;    /* accept ending quote, but throw away */
-  }
-  else
-  {   
-    str_room(1);
-    append_char(c);
-    //  for DOS/Windows
-    if ((c == '/' || c == '\\' || c == ':')) 
-    {
-      area_delimiter = cur_length;
-      ext_delimiter = 0;
-    } 
-    else if (c == '.')
-      ext_delimiter = cur_length;
-
-    return true;
-  }
-}
-/******************************** 2000 August 15th start ***********************/
-
-// The following code is to save string space used by TeX for filenames
-// Not really critical in a system that has dynamic memory allocation
-// And may slow it down slightly - although this linear search only
-// occurs when opening a file, which is somewhat slow inany case...
-
-// see if string from str_pool[start] to str_pool[end]
-// occurs elsewhere in string pool - returns string number
-// returns -1 if not found in string pool 2000 Aug 15
-
-int find_string (int start, int end)
-{
-  int k, nlen = end - start;
-  char *s;
-
-  if (trace_flag)
-  {
-    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, "");
-    show_line(log_line, 0);
-  }
-
-//  avoid problems with(cur_name == flushablestring)by going only up to str_ptr-1
-//  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 (strncmp((const char *) str_pool + start, (const char *) str_pool + str_start[k], nlen) == 0)
-    {
-      if (trace_flag)
-      {
-        sprintf(log_line, "\nFOUND the string %d (%d) ", k, str_start[k+1]-str_start[k]);
-        s = log_line + strlen(log_line);
-        strncpy(s, (const char *)str_pool + start, nlen);
-        strcpy(s+nlen, "\n");
-        show_line(log_line, 0);
-      }
-      return k;     // return number of matching string
-    }
-  }
-
-  if (trace_flag)
-  {
-    sprintf(log_line, "\nNOT FOUND string ");
-    s = log_line + strlen(log_line);
-    strncpy(s, (const char*)str_pool + start, nlen);
-    strcpy(s + nlen, "\n");
-    show_line(log_line, 0);
-  }
-
-  return -1;          // no match found
-}
-
-// snip out the string from str_pool[start] to str_pool[end]
-// and move everything above it down 2000 Aug 15
-
-void remove_string (int start, int end)
-{
-  int nlen = pool_ptr - end;  // how many bytes to move down
-  char *s;
-  
-//  int trace_flag=1;   // debugging only
-//  if (end < start) show_line("\nEND < START", 1);
-//  if (pool_ptr < end) show_line("\nPOOLPTR < END", 1);
-
-  if (trace_flag)
-  {
-    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");
-    show_line(log_line, 0);
-  }
-
-  if (nlen > 0)
-    memcpy(str_pool + start, str_pool + end, nlen);
-
-  pool_ptr = start + nlen;    // poolprt - (end-start);
-}
-
-void show_string (int k)
-{
-  int nlen = length(k);
-  char *s;
-  
-  sprintf(log_line, "\nSTRING %5d (%3d) %5d--%5d ",
-      k, nlen, str_start[k], str_start[k+1]);
-  s = log_line + strlen(log_line);      
-  strncpy(s, (const char *)str_pool + str_start[k], nlen);
-  strcpy(s + nlen, "");
-  show_line(log_line, 0);
-}
-
-void show_all_strings (void)
-{
-  int k;
-
-  for (k = 0; k < str_ptr; k++)
-    show_string(k);
-}
-
-/********************************** 2000 August 15 end ****************************/
-/* sec 0517 */
-void end_name (void) 
-{
-#ifdef ALLOCATESTRING
-  if (str_ptr + 3 > current_max_strings)
-    str_start = realloc_str_start(increment_max_strings + 3);
-
-  if (str_ptr + 3 > current_max_strings)
-  {
-    overflow("number of strings", current_max_strings - init_str_ptr);
-    return;     // abort_flag set
-  }
-#else
-  if (str_ptr + 3 > max_strings)
-  {
-    overflow("number of strings", max_strings - init_str_ptr);
-    return;     // abort_flag set
-  }
-#endif
-
-  if (area_delimiter == 0)   // no area delimiter ':' '/' or '\' found
-    cur_area = 335;     // "" default area 
-  else
-  {
-    if (save_strings_flag && (cur_area = find_string(str_start[str_ptr], str_start[str_ptr] + area_delimiter)) > 0)
-    {
-      remove_string(str_start[str_ptr], str_start[str_ptr] + area_delimiter);
-      area_delimiter = 0; // area_delimiter - area_delimiter;
-
-      if (ext_delimiter != 0)
-        ext_delimiter = ext_delimiter - area_delimiter;
-
-//      str_start[str_ptr + 1]= str_start[str_ptr]+ area_delimiter; // test only
-//      incr(str_ptr);    // test only
-    }
-    else         // carve out string for "cur_area"
-    {
-      cur_area = str_ptr; 
-      str_start[str_ptr + 1] = str_start[str_ptr] + area_delimiter; 
-      incr(str_ptr);
-    }
-  }
-
-  if (ext_delimiter == 0) // no extension delimiter '.' found
-  {
-    cur_ext = 335;        // "" default extension 
-
-    if (save_strings_flag && (cur_name = find_string(str_start[str_ptr], pool_ptr)) > 0)
-    {
-      remove_string(str_start[str_ptr], pool_ptr);
-//    (void) make_string();  // test only
-    }
-    else            // Make string from str_start[str_ptr]to pool_ptr
-      cur_name = make_string();
-  } 
-  else            // did find an extension
-  {
-    if (save_strings_flag &&
-      (cur_name = find_string(str_start[str_ptr], str_start[str_ptr] + ext_delimiter - area_delimiter-1)) > 0)
-    {
-      remove_string(str_start[str_ptr], str_start[str_ptr] + ext_delimiter - area_delimiter - 1);
-//    str_start[str_ptr + 1]= str_start[str_ptr]+ ext_delimiter - area_delimiter - 1;   // test only
-//    incr(str_ptr);    // test only
-    }
-    else             // carve out string for "cur_name"
-    {
-      cur_name = str_ptr;
-      str_start[str_ptr + 1]= str_start[str_ptr]+ ext_delimiter - area_delimiter - 1;
-      incr(str_ptr);
-    }
-
-    if (save_strings_flag && (cur_ext = find_string(str_start[str_ptr], pool_ptr)) > 0)
-    {
-      remove_string(str_start[str_ptr], pool_ptr);
-//    (void) make_string();  // test only
-    }
-    else            // Make string from str_start[str_ptr]to pool_ptr
-      cur_ext = make_string();
-  }
-}
-
-/* n current name, a current area, e current extension */
-/* result in name_of_file[] */
-/* sec 0519 */
-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];
-  }
-
-  if (k < PATHMAX)
-    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 */
-
-  {
-    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] = ' ';
-  }
-}
-/* Called only from two places tex9.c for format name - specified and default */
-/* for specified format name args are 0, a, b name in buffer[a] --- buffer[b] */
-/* for default args are format_default_length-4, 1, 0 */
-/* sec 0523 */
-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];
-  }
-/*  This loop kicks in when we want a specififed format name */
-  for (j = a; j <= b; j++)
-  {
-    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 ? */
-  for (k = name_length + 1; k <= PATHMAX; k++)
-    name_of_file[k]= ' ';
-
-  name_of_file[PATHMAX] = '\0';    /* paranoia 94/Mar/24 */
-}
-/* sec 0525 */
-str_number make_name_string (void)
-{
-  integer k;
-
-#ifdef ALLOCATESTRING
-  if (pool_ptr + name_length > current_pool_size)
-    str_pool = realloc_str_pool(increment_pool_size + name_length);
-
-  if (str_ptr == current_max_strings)
-    str_start = realloc_str_start(increment_max_strings);
-
-  if ((pool_ptr + name_length > current_pool_size) || (str_ptr == current_max_strings) || (cur_length > 0))
-#else
-  if ((pool_ptr + name_length > pool_size) || (str_ptr == max_strings) || (cur_length > 0))
-#endif
-  {
-    return '?';
-  }
-  else
-  {
-    for (k = 1; k <= name_length; k++)
-      append_char(xord[name_of_file[k]]);
-
-    return make_string();
-  }
-}
-/* sec 0525 */
-str_number a_make_name_string_(alpha_file * f)
-{
-  return make_name_string();
-}
-/* sec 0525 */
-str_number b_make_name_string_(byte_file * f)
-{
-  return make_name_string(); 
-}
-/* sec 0525 */
-str_number w_make_name_string_(word_file * f)
-{
-  return make_name_string();
-}
-
-/* Used by start_input to scan file name on command line */
-/* Also in tex8.c new_font_, open_or_close_in, and do_extension */
-/* sec 0526 */
-void scan_file_name (void)
-{
-  name_in_progress = true;
-  begin_name();
-
-  do
-    {
-      get_x_token(); 
-    }
-  while (!(cur_cmd != spacer));
-
-  quoted_file_name = false;
-
-  if (allow_quoted_names)
-  {
-    if (cur_chr == '"')
-    {
-      quoted_file_name = 1;
-      get_x_token();
-    }
-  }
-
-  while (true)
-  {
-    if ((cur_cmd > other_char) || (cur_chr > 255)) 
-    {
-      back_input();
-      goto lab30; 
-    } 
-
-    if (!more_name(cur_chr))    /* up to next white space */
-      goto lab30;
-
-    get_x_token();
-  }
-
-lab30:
-  end_name();
-  name_in_progress = false;
-}
-/* argument is string .fmt, .log, or .dvi */
-/* sec 0529 */
-void pack_job_name_(str_number s)
-{
-  cur_area = 335;       /* "" */
-  cur_ext  = s;
-  cur_name = job_name;
-  pack_file_name(cur_name, cur_area, cur_ext);
-}
-
-/**********************************************************************/
-/* show TEXINPUTS=... or format specific  */
-/* only show this if name was not fully qualified ? */
-void show_tex_inputs (void)
-{
-  char *s, *t, *v;
-
-  s = "TEXINPUTS";        /* default */
-
-  if (format_specific)
-  {
-    s = format_name;                /* try specific */
-
-    if (grabenv(s) == NULL)
-      s = "TEXINPUTS";  /* no format specific */
-  }
-
-  if (grabenv(s) == NULL)
-    s = "TEXINPUT";     /* 94/May/19 */
-
-  print_nl("  ");
-  print_char(' ');
-  print_char('(');
-  t = s;
-
-  while (*t > '\0')
-    print_char(*t++);
-
-  print_char('=');
-  v = grabenv(s);
-
-  if (v != NULL)
-  {
-    t = v;
-
-    while (*t > '\0')
-      print_char(*t++);
-  }
-
-  print_char(')');
-}
-
-/**********************************************************************/
-/* sec 0530 */
-/* s - what can't be found, e - default */
-void prompt_file_name_(char * s, str_number e) 
-{
-  integer k;
-
-  if (interaction == scroll_mode);
-
-  if (!strcmp("input file name", s))
-    print_err("I can't find file `");
-  else
-    print_err("I can't write on file `");
-
-  print_file_name(cur_name, cur_area, cur_ext);
-  print_string("'.");
-
-  if (!strcmp("input file name", s))
-  {
-    if (cur_area == 335) /* "" only if path not specified */
-    {
-      if (show_texinput_flag)
-        show_tex_inputs();
-    }
-  }
-
-  if (e == 785)    /* .tex */
-    show_context();
-
-  print_nl("Please type another ");
-  print_string(s); 
-
-  if (interaction < 2)
-  {
-    fatal_error("*** (job aborted, file error in nonstop mode)");
-    return;     // abort_flag set
-  }
-
-  if (!knuth_flag)
-#ifdef _WINDOWS
-    show_line(" (or ^z to exit)", 0);
-#else
-    show_line(" (or Ctrl-Z to exit)", 0);
-#endif
-  {
-    print_string(": ");
-    term_input(": ", 0);
-  }
-/*  should we deal with tilde and space in file name here ??? */
-  {
-    begin_name();
-    k = first;
-
-    while ((buffer[k] == ' ') && (k < last))
-      incr(k);
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-    quoted_file_name = 0;         /* 98/March/15 */
-
-    if (allow_quoted_names && k < last) /* check whether quoted name */
-    {
-      if (buffer[k]== '"')
-      {
-        quoted_file_name = 1;
-        incr(k);
-      }
-    }
-
-    while (true)
-    {
-      if (k == last)
-        goto lab30;
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-/*  convert tilde '~' to pseudo tilde */
-      if (pseudo_tilde != 0 && buffer[k]== '~')
-        buffer[k] = pseudo_tilde;
-/*  convert space ' ' to pseudo space */
-      if (pseudo_space != 0 && buffer[k]== ' ')
-        buffer[k] = pseudo_space;
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-      if (!more_name(buffer[k]))
-        goto lab30;
-
-      incr(k);
-    }
-lab30:
-    end_name();
-  }
-
-  if (cur_ext == 335)    /* "" */
-    cur_ext = e;      /* use default extension */
-
-  pack_file_name(cur_name, cur_area, cur_ext);
-}
-/* sec 0534 */
-void open_log_file (void)
-{
-  char old_setting;
-  integer k;
-  integer l;
-  char * months;
-
-  old_setting = selector;
-
-  if (job_name == 0)
-    job_name = 790;
-
-  pack_job_name(".log");
-
-  while (!a_open_out(log_file))
-  {
-    selector = term_only;
-    prompt_file_name("transcript file name", ".log");
-  }
-
-  texmf_log_name = a_make_name_string(log_file);
-  selector = log_only;
-  log_opened = true;
-
-  {
-    if (want_version)
-    {
-      stamp_it(log_line);
-      strcat(log_line, "\n");
-      (void) fputs(log_line, log_file);
-      stampcopy(log_line);
-      strcat(log_line, "\n");
-      (void) fputs(log_line, log_file);
-    }
-    
-    (void) fputs(tex_version, log_file); 
-    (void) fprintf(log_file, " (%s %s)", application, yandyversion);
-
-    if (format_ident > 0)
-      slow_print(format_ident);
-
-    print_string("  ");
-
-    if (civilize_flag)
-      print_int(year);
-    else
-      print_int(day);
-
-    print_char(' ');
-    months = " JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
-
-    for (k = 3 * month - 2; k <= 3 * month; k++)
-      (void) putc(months[k],  log_file);
-
-    print_char(' ');
-
-    if (civilize_flag)
-      print_int(day);
-    else
-      print_int(year);
-
-    print_char(' ');
-    print_two(tex_time / 60);
-    print_char(':');
-    print_two(tex_time % 60);
-  }
-
-  input_stack[input_ptr] = cur_input;
-  print_nl("**");
-  l = input_stack[0].limit_field;
-
-  if (buffer[l] == end_line_char)
-    decr(l);
-
-  for (k = 1; k <= l; k++)
-    print(buffer[k]);
-
-  print_ln(); 
-
-  if (show_fmt_flag)
-  {
-    if (format_file != NULL)
-    {
-      fprintf(log_file, "(%s)\n", format_file);
-      free(format_file);
-      format_file = NULL;
-    }
-  }
-
-  selector = old_setting + 2;
-}
-
-/**************************** start of insertion 98/Feb/7 **************/
-// Attempt to deal with foo.bar.tex given as foo.bar on command line
-// Makes copy of job_name with extension
-
-void more_name_copy(ASCII_code c)
-{
-#ifdef ALLOCATESTRING
-  if (pool_ptr + 1 > current_pool_size)
-    str_pool = realloc_str_pool (increment_pool_size);
-
-  if (pool_ptr + 1 > current_pool_size)
-  {
-    overflow("pool size", current_pool_size - init_pool_ptr);
-    return;
-  }
-#else
-  if (pool_ptr + 1 > pool_size)
-  {
-    overflow("pool size", pool_size - init_pool_ptr);
-    return;
-  }
-#endif
-
-  str_pool[pool_ptr] = c; 
-  incr(pool_ptr);
-}
-
-int end_name_copy(void)
-{
-#ifdef ALLOCATESTRING
-  if (str_ptr + 1 > current_max_strings)
-    str_start = realloc_str_start(increment_max_strings + 1);
-
-  if (str_ptr + 1 > current_max_strings)
-  {
-    overflow("number of strings", current_max_strings - init_str_ptr);
-    return 0;
-  }
-#else
-  if (str_ptr + 1 > max_strings)
-  {
-    overflow("number of strings", max_strings - init_str_ptr);
-    return 0;
-  }
-#endif
-
-  return make_string();
-}
-
-void job_name_append (void)
-{ 
-  int k, n;
-
-  k = str_start[job_name];
-  n = str_start[job_name + 1];
-
-  while (k < n)
-    more_name_copy(str_pool[k++]);
-
-  k = str_start[cur_ext];
-  n = str_start[cur_ext + 1];
-
-  while (k < n)
-    more_name_copy(str_pool[k++]);
-
-  job_name = end_name_copy();
-}
-
-/**************************** end of insertion 98/Feb/7 **************/
-/* sec 0537 */
-void start_input(void)
-{
-  boolean added_extension = false;
-
-  scan_file_name();
-  pack_file_name(cur_name, cur_area, cur_ext); 
-
-  while (true)
-  {
-    added_extension = false;
-    begin_file_reading(); 
-
-    if ((cur_ext != 335) && a_open_in(input_file[cur_input.index_field], TEXINPUTPATH))
-      goto lab30;
-
-    if ((cur_ext != 785) && (name_length + 5 < PATHMAX))
-    {
-      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] = ' ';
-      name_length = name_length + 4;
-
-      added_extension = true;
-
-      if (a_open_in(input_file[cur_input.index_field], TEXINPUTPATH))
-        goto lab30;
-
-      name_length = name_length - 4;
-      name_of_file[name_length + 1] = ' ';
-      added_extension = false;
-    }
-
-    if ((cur_ext == 335) && a_open_in(input_file[cur_input.index_field], TEXINPUTPATH))
-      goto lab30;
-
-    end_file_reading();
-    prompt_file_name("input file name", ".tex");
-  }
-
-lab30: 
-  cur_input.name_field = a_make_name_string(input_file[cur_input.index_field]);
-
-  if (job_name == 0)
-  {
-    job_name = cur_name;
-
-    if (cur_ext != 335 && added_extension)
-      job_name_append();
-
-    open_log_file();
-  }
-
-  if (term_offset + length(cur_input.name_field) > max_print_line - 2)
-    print_ln();
-  else if ((term_offset > 0) || (file_offset > 0))
-    print_char(' ');
-
-  print_char('(');
-  incr(open_parens);
-
-  if (open_parens > max_open_parens)
-    max_open_parens = open_parens;
-
-  slow_print(cur_input.name_field);
-
-#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;
-  }
-}
-
-/**********************************************************************/
-/* show TEXFONTS=... or format specific  */
-/* only show this if name was not fully qualified ? */
-void show_tex_fonts (void)
-{
-  char *s, *t, *v, *u;
-  int n;
-
-  s = "TEXFONTS";
-
-  if (encoding_specific)
-  {
-    u = encoding_name;                /* try specific */
-
-    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++);
-
-  print_char('=');
-  v = grabenv(s);
-
-  if (v != NULL)
-  {
-    t = v;
-
-    while (*t > '\0')
-      print_char(*t++);
-  }
-
-  print_char(')');
-}
-/* sec 0560 */
-internal_font_number read_font_info_(halfword u, str_number nom, str_number aire, scaled s)
-{
-  font_index k;
-  boolean file_opened;
-  halfword lf, lh, nw, nh, nd, ni, nl, nk, ne, np;
-  int bc, ec;
-  internal_font_number f;
-  internal_font_number g;
-  eight_bits a, b, c, d;
-  four_quarters qw;
-  scaled sw;
-  integer bch_label;
-  short bchar;
-  scaled z;
-  integer alpha;
-  char beta;
-
-  g = 0;
-  file_opened = false;
-  pack_file_name(nom, aire, 805); /* .tfm */
-
-  if (!b_open_in(tfm_file))
-  {
-    goto lab11;
-  } 
-
-  file_opened = true; 
-
-  {
-    read_sixteen(lf);
-    tfm_temp = getc(tfm_file);
-    read_sixteen(lh);
-    tfm_temp = getc(tfm_file);
-    read_sixteen(bc);
-    tfm_temp = getc(tfm_file);
-    read_sixteen(ec);
-
-    if ((bc > ec + 1) || (ec > 255))
-      goto lab11;
-
-    if (bc > 255)
-    {
-      bc = 1;
-      ec = 0;
-    }
-
-    tfm_temp = getc(tfm_file);
-    read_sixteen(nw);
-    tfm_temp = getc(tfm_file);
-    read_sixteen(nh);
-    tfm_temp = getc(tfm_file);
-    read_sixteen(nd);
-    tfm_temp = getc(tfm_file);
-    read_sixteen(ni);
-    tfm_temp = getc(tfm_file);
-    read_sixteen(nl);
-    tfm_temp = getc(tfm_file);
-    read_sixteen(nk);
-    tfm_temp = getc(tfm_file);
-    read_sixteen(ne);
-    tfm_temp = getc(tfm_file);
-    read_sixteen(np);
-
-    if (lf != 6 + lh + (ec - bc + 1) + nw + nh + nd + ni + nl + nk + ne + np)
-      goto lab11;
-
-    if ((nw == 0) || (nh == 0) || (nd == 0) || (ni == 0))
-      goto lab11;
-  }
-
-  lf = lf - 6 - lh;
-
-  if (np < 7)
-    lf = lf + 7 - np;
-
-#ifdef ALLOCATEFONT
-  if ((fmem_ptr + lf > current_font_mem_size))
-    font_info = realloc_font_info (increment_font_mem_size + lf);
-
-  if ((font_ptr == font_max) || (fmem_ptr + lf > current_font_mem_size))
-#else
-  if ((font_ptr == font_max) || (fmem_ptr + lf > font_mem_size))
-#endif
-  {
-    if (trace_flag)
-    {
-      sprintf(log_line, "font_ptr %d font_max %d fmem_ptr %d lf %d font_mem_size %d\n",
-          font_ptr, font_max, fmem_ptr, lf, font_mem_size);
-      show_line(log_line, 0);
-    }
-
-    print_err("Font ");
-    sprint_cs(u);
-    print_char('=');
-    print_file_name(nom, aire, 335); /* "" */
-
-    if (s >= 0)
-    {
-      print_string(" at ");
-      print_scaled(s);
-      print_string("pt");
-    }
-    else if (s != -1000)
-    {
-      print_string(" scaled ");
-      print_int(- (integer) s);
-    }
-
-    print_string(" not loaded: Not enough room left");
-    help4("I'm afraid I won't be able to make use of this font,",
-        "because my memory for character-size data is too small.",
-        "If you're really stuck, ask a wizard to enlarge me.",
-        "Or maybe try `I\\font<same font id>=<name of loaded font>'.");
-    error();
-    goto lab30;
-  }
-
-  f = font_ptr + 1;
-  char_base[f] = fmem_ptr - bc;
-  width_base[f] = char_base[f] + ec + 1;
-  height_base[f] = width_base[f] + nw;
-  depth_base[f] = height_base[f] + nh;
-  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;
-  param_base[f] = exten_base[f] + ne;
-
-  {
-    if (lh < 2)
-      goto lab11;
-    
-    store_four_quarters(font_check[f]);
-    tfm_temp = getc(tfm_file);
-    read_sixteen(z);
-    tfm_temp = getc(tfm_file);
-    z = z * 256 + tfm_temp;
-    tfm_temp = getc(tfm_file);
-    z =(z * 16) + (tfm_temp / 16);
-
-    if (z < 65536L)
-      goto lab11; 
-
-    while (lh > 2)
-    {
-      tfm_temp = getc(tfm_file);
-      tfm_temp = getc(tfm_file);
-      tfm_temp = getc(tfm_file);
-      tfm_temp = getc(tfm_file);
-      decr(lh);
-    }
-
-    font_dsize[f] = z;
-
-    if (s != -1000)
-      if (s >= 0)
-        z = s;
-      else
-        z = xn_over_d(z, - (integer) s, 1000);
-
-    font_size[f] = z;
-  }
-
-  for (k = fmem_ptr; k <= width_base[f] - 1; k++)
-  {
-    store_four_quarters(font_info[k].qqqq);
-
-    if ((a >= nw) || (b / 16 >= nh) || (b % 16 >= nd) || (c / 4 >= ni))
-      goto lab11;
-
-    switch (c % 4)
-    {
-      case lig_tag:
-        if (d >= nl)
-          goto lab11;
-        break;
-
-      case ext_tag:
-        if (d >= ne)
-          goto lab11;
-        break;
-
-      case list_tag:
-        {
-          {
-            if ((d < bc) || (d > ec))
-              goto lab11;
-          }
-
-          while (d < k + bc - fmem_ptr)
-          {
-            qw = char_info(f, d);
-            if (char_tag(qw) != list_tag)
-              goto lab45;
-
-            d = rem_byte(qw);
-          }
-
-          if (d == k + bc - fmem_ptr)
-            goto lab11;
-lab45:; 
-        }
-        break;
-
-      default:
-        break;
-    }
-  }
-
-  {
-    {
-      alpha = 16;
-
-      while (z >= 8388608L)   /* 2^23 */
-      {
-        z = z / 2;
-        alpha = alpha + alpha;
-      }
-
-      beta = (char) (256 / alpha);
-      alpha = alpha * z;
-    }
-
-    for (k = width_base[f]; k <= lig_kern_base[f] - 1; k++)
-    {
-      tfm_temp = getc(tfm_file);
-      a = tfm_temp;
-      tfm_temp = getc(tfm_file);
-      b = tfm_temp;
-      tfm_temp = getc(tfm_file);
-      c = tfm_temp;
-      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)
-        font_info[k].cint = sw - alpha;
-      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;
-  }
-
-  bch_label = 32767;     /* '77777 */
-  bchar = 256;
-
-  if (nl > 0)
-  {
-    for (k = lig_kern_base[f]; k <= kern_base[f] + 256 * (128) - 1; k++)
-    {
-      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;
-      }
-      else
-      {
-        if (b != bchar)
-        {
-          {
-            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 */
-        }
-        else if (256 * (c - 128) + d >= nk)
-          goto lab11;           /* error in TFM, abort */
-
-        if (a < 128)
-          if (k - lig_kern_base[f] + a + 1 >= nl)
-            goto lab11;         /* error in TFM, abort */
-      }
-    }
-
-    if (a == 255)
-      bch_label = 256 * c + d;
-  }
-
-  for (k = kern_base[f] + 256 * (128); k <= exten_base[f] - 1; k++)
-  {
-    tfm_temp = getc(tfm_file);
-    a = tfm_temp;
-    tfm_temp = getc(tfm_file);
-    b = tfm_temp;
-    tfm_temp = getc(tfm_file);
-    c = tfm_temp;
-    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)
-      font_info[k].cint = sw - alpha;
-    else goto lab11;
-  }
-
-  /*  read extensible character recipes */
-  for (k = exten_base[f]; k <= param_base[f] - 1; k++)
-  {
-    store_four_quarters(font_info[k].qqqq);
-
-    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;
-    }
-
-    {
-      {
-        if ((d < bc) || (d > ec))
-          goto lab11;
-      }
-
-      qw = font_info[char_base[f] + d].qqqq;
-
-      if (!(qw.b0 > 0))
-        goto lab11;
-    }
-  }
-
-  {
-    for (k = 1; k <= np; k++)
-      if (k == 1)
-      {
-        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);
-        sw = sw * 256 + tfm_temp;
-        tfm_temp = getc(tfm_file);
-        font_info[param_base[f]].cint = (sw * 16) + (tfm_temp / 16);
-      }
-      else
-      {
-        tfm_temp = getc(tfm_file);
-        a = tfm_temp;
-        tfm_temp = getc(tfm_file);
-        b = tfm_temp;
-        tfm_temp = getc(tfm_file);
-        c = tfm_temp;
-        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)
-          font_info[param_base[f] + k - 1].cint = sw - alpha;
-        else goto lab11;
-      }
-
-    if (feof(tfm_file))
-      goto lab11;
-
-    for (k = np + 1; k <= 7; k++)
-      font_info[param_base[f] + k - 1].cint = 0;
-  }
-
-  if (np >= 7)
-    font_params[f] = np;
-  else
-    font_params[f] = 7;
-
-  hyphen_char[f] = default_hyphen_char;
-  skew_char[f] = default_skew_char;
-
-  if (bch_label < nl)
-    bchar_label[f] = bch_label + lig_kern_base[f];
-  else
-    bchar_label[f] = non_address;
-
-  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;
-  font_ec[f] = ec;
-  font_glue[f] = 0;
-  char_base[f] = char_base[f];
-  width_base[f] = width_base[f];
-  lig_kern_base[f] = lig_kern_base[f];
-  kern_base[f] = kern_base[f];
-  exten_base[f] = exten_base[f];
-  decr(param_base[f]);
-  fmem_ptr = fmem_ptr + lf;
-  font_ptr = f;
-  g = f;
-  goto lab30;
-
-lab11:
-  print_err("Font ");
-  sprint_cs(u); 
-  print_char('=');
-  print_file_name(nom, aire, 335);
-
-  if (s >= 0)
-  {
-    print_string(" at ");
-    print_scaled(s);
-    print_string("pt");
-  }
-  else if (s != -1000)
-  {
-    print_string("scaled");
-    print_int(- (integer) s);
-  } 
-
-  if (file_opened)
-    print_string(" not loadable: Bad metric (TFM) file");
-  else
-    print_string(" not loadable: Metric (TFM) file not found");
-
-  if (aire == 335)
-  {
-    if (show_texinput_flag)
-      show_tex_fonts();
-  }
-
-  help5("I wasn't able to read the size data for this font,",
-      "so I will ignore the font specification.",
-      "[Wizards can fix TFM files using TFtoPL/PLtoTF.]",
-      "You might try inserting a different font spec;",
-      "e.g., type `I\\font<same font id>=<substitute font name>'.");
-  error();
-
-lab30:
-  if (file_opened)
-    b_close(tfm_file);
-
-  return g;
+/* Copyright 2014 Clerk Ma\r
+\r
+   This program is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 2 of the License, or\r
+   (at your option) any later version.\r
+\r
+   This program is distributed in the hope that it will be useful, but\r
+   WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+   General Public License for more details.\r
+\r
+   You should have received a copy of the GNU General Public License\r
+   along with this program; if not, write to the Free Software\r
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
+   02110-1301 USA.  */\r
+\r
+#define EXTERN extern\r
+\r
+#include "yandytex.h"\r
+\r
+/* sec 0440 */\r
+void scan_int (void)\r
+{\r
+  boolean negative;\r
+  integer m;\r
+  small_number d;\r
+  boolean vacuous;\r
+  boolean OK_so_far;\r
+\r
+  radix = 0;\r
+  OK_so_far = true;\r
+  negative = false;\r
+\r
+  do\r
+    {\r
+      do \r
+        {\r
+          get_x_token();\r
+        }\r
+      while (!(cur_cmd != spacer));\r
+\r
+      if (cur_tok == other_token + '-')\r
+      {\r
+        negative = !negative;\r
+        cur_tok = other_token + '+';\r
+      }\r
+    }\r
+  while (!(cur_tok != other_token + '+'));\r
+\r
+  if (cur_tok == alpha_token)\r
+  {\r
+    get_token();\r
+\r
+    if (cur_tok < cs_token_flag)\r
+    {\r
+      cur_val = cur_chr;\r
+\r
+      if (cur_cmd <= right_brace)\r
+        if (cur_cmd == right_brace)\r
+          incr(align_state);\r
+        else\r
+          decr(align_state);\r
+    }\r
+    else if (cur_tok < cs_token_flag + single_base)\r
+      cur_val = cur_tok - cs_token_flag - active_base;\r
+    else\r
+      cur_val = cur_tok - cs_token_flag - single_base;\r
+\r
+    if (cur_val > 255)\r
+    {\r
+      print_err("Improper alphabetic constant");\r
+      help2("A one-character control sequence belongs after a ` mark.",\r
+        "So I'm essentially inserting \\0 here.");\r
+      cur_val = '0';\r
+      back_error();\r
+    }\r
+    else\r
+    {\r
+      get_x_token();\r
+\r
+      if (cur_cmd != spacer)\r
+        back_input();\r
+    }\r
+  }\r
+  else if ((cur_cmd >= min_internal) && (cur_cmd <= max_internal))\r
+  {\r
+    scan_something_internal(int_val, false);\r
+  }\r
+  else\r
+  {\r
+    radix = 10;\r
+    m = 214748364L;   /* 7FFFFFFF hex */\r
+\r
+    if (cur_tok == octal_token)\r
+    {\r
+      radix = 8;\r
+      m = 268435456L;   /* 2^28 */\r
+      get_x_token();\r
+    }\r
+    else if (cur_tok == hex_token)\r
+    {\r
+      radix = 16;\r
+      m = 134217728L;   /* 2^27 8000000 hex */\r
+      get_x_token();\r
+    }\r
+\r
+    vacuous = true;\r
+    cur_val = 0;\r
+\r
+    while (true)\r
+    {\r
+      if ((cur_tok < zero_token + radix) && (cur_tok >= zero_token) && (cur_tok <= zero_token + 9))\r
+        d = cur_tok - zero_token;\r
+      else if (radix == 16)\r
+        if ((cur_tok <= A_token + 5) && (cur_tok >= A_token))\r
+          d = cur_tok - A_token + 10;\r
+        else if ((cur_tok <= other_A_token + 5) && (cur_tok >= other_A_token))\r
+          d = cur_tok - other_A_token;\r
+        else\r
+          goto done;\r
+      else\r
+        goto done;\r
+\r
+      vacuous = false;\r
+\r
+      if ((cur_val >= m) && ((cur_val > m) || (d > 7) || (radix != 10)))\r
+      {\r
+        if (OK_so_far)\r
+        {\r
+          print_err("Number too big");\r
+          help2("I can only go up to 2147483647='17777777777=\"7FFFFFFF,",\r
+            "so I'm using that number instead of yours.");\r
+          error();\r
+          cur_val = 2147483647L;    /* 7FFFFFFF hex */\r
+          OK_so_far = false;\r
+        }\r
+      }\r
+      else\r
+        cur_val = cur_val * radix + d;\r
+\r
+      get_x_token();\r
+    }\r
+\r
+done:\r
+    if (vacuous)\r
+    {\r
+      print_err("Missing number, treated as zero");\r
+      help3("A number should have been here; I inserted `0'.",\r
+        "(If you can't figure out why I needed to see a number,",\r
+        "look up `weird error' in the index to The TeXbook.)");\r
+      back_error();\r
+    } \r
+    else if (cur_cmd != spacer)\r
+      back_input();\r
+  }\r
+\r
+  if (negative)\r
+    cur_val = - (integer) cur_val;\r
+}\r
+/* sec 0448 */\r
+void scan_dimen (boolean mu, boolean inf, boolean shortcut)\r
+{\r
+  boolean negative;\r
+  integer f;\r
+  integer num, denom;\r
+  small_number k, kk;\r
+  halfword p, q;\r
+  scaled v;\r
+  integer save_cur_val;\r
+\r
+  f = 0;\r
+  arith_error = false;\r
+  cur_order = normal;\r
+  negative = false;\r
+\r
+  if (!shortcut)\r
+  {\r
+    negative = false;\r
+\r
+    do\r
+      {\r
+        do\r
+          {\r
+            get_x_token();\r
+          }\r
+        while (!(cur_cmd != spacer));\r
+\r
+        if (cur_tok == other_token + '-')\r
+        {\r
+          negative = ! negative;\r
+          cur_tok = other_token + '+';\r
+        }\r
+      }\r
+    while (!(cur_tok != other_token + '+'));\r
+\r
+    if ((cur_cmd >= min_internal) && (cur_cmd <= max_internal))\r
+    {\r
+      if (mu)\r
+      {\r
+        scan_something_internal(mu_val, false);\r
+\r
+        if (cur_val_level >= glue_val)\r
+        {\r
+          v = width(cur_val);\r
+          delete_glue_ref(cur_val);\r
+          cur_val = v;\r
+        }\r
+\r
+        if (cur_val_level == mu_val)\r
+          goto attach_sign;\r
+\r
+        if (cur_val_level != int_val)\r
+          mu_error();\r
+      }\r
+      else\r
+      {\r
+        scan_something_internal(dimen_val, false);\r
+\r
+        if (cur_val_level == dimen_val)\r
+          goto attach_sign;\r
+      }\r
+    }\r
+    else\r
+    {\r
+      back_input();\r
+\r
+      if (cur_tok == continental_point_token)\r
+        cur_tok = point_token;\r
+\r
+      if (cur_tok != point_token)\r
+      {\r
+        scan_int();\r
+      }\r
+      else\r
+      {\r
+        radix = 10;\r
+        cur_val = 0;\r
+      }\r
+\r
+      if (cur_tok == continental_point_token)\r
+        cur_tok = point_token;\r
+\r
+      if ((radix == 10) && (cur_tok == point_token))\r
+      {\r
+        k = 0;\r
+        p = 0;\r
+        get_token();\r
+\r
+        while (true)\r
+        {\r
+          get_x_token();\r
+\r
+          if ((cur_tok > zero_token + 9) || (cur_tok < zero_token))\r
+            goto done1;\r
+\r
+          if (k < 17)\r
+          {\r
+            q = get_avail();\r
+            link(q) = p;\r
+            info(q) = cur_tok - zero_token;\r
+            p = q;\r
+            incr(k);\r
+          }\r
+        }\r
+\r
+done1:\r
+        for (kk = k; kk >= 1; kk--)\r
+        {\r
+          dig[kk - 1] = info(p);\r
+          q = p;\r
+          p = link(p);\r
+          free_avail(q);\r
+        }\r
+\r
+        f = round_decimals(k);\r
+\r
+        if (cur_cmd != spacer)\r
+          back_input();\r
+        }\r
+      }\r
+  }\r
+\r
+  if (cur_val < 0)\r
+  {\r
+    negative = !negative;\r
+    cur_val = - (integer) cur_val;\r
+  }\r
+\r
+  if (inf)\r
+  {\r
+    if (scan_keyword("fil"))\r
+    {\r
+      cur_order = fil;\r
+\r
+      while (scan_keyword("l"))\r
+      {\r
+        if (cur_order == filll)\r
+        {\r
+          print_err("Illegal unit of measure (");\r
+          prints("replaced by filll)");\r
+          help1("I dddon't go any higher than filll.");\r
+          error();\r
+        }\r
+        else\r
+          incr(cur_order);\r
+      }\r
+\r
+      goto attach_fraction;\r
+    }\r
+  }\r
+\r
+  save_cur_val = cur_val;\r
+\r
+  do\r
+    {\r
+      get_x_token();\r
+    }\r
+  while (!(cur_cmd != spacer));\r
+\r
+  if ((cur_cmd < min_internal) || (cur_cmd > max_internal))\r
+    back_input();\r
+  else\r
+  {\r
+    if (mu)\r
+    {\r
+      scan_something_internal(mu_val, false);\r
+\r
+      if (cur_val_level >= glue_val)\r
+      {\r
+        v = width(cur_val);\r
+        delete_glue_ref(cur_val);\r
+        cur_val = v;\r
+      }\r
+\r
+      if (cur_val_level != mu_val)\r
+      {\r
+        mu_error();\r
+      }\r
+    }\r
+    else\r
+    {\r
+      scan_something_internal(dimen_val, false);\r
+    }\r
+\r
+    v = cur_val;\r
+    goto found;\r
+  }\r
+\r
+  if (mu)\r
+    goto not_found;\r
+\r
+  if (scan_keyword("em"))\r
+    v = quad(cur_font);\r
+  else if (scan_keyword("ex"))\r
+    v = x_height(cur_font);\r
+  else\r
+    goto not_found;\r
+\r
+  {\r
+    get_x_token();\r
+\r
+    if (cur_cmd != spacer)\r
+      back_input();\r
+  }\r
+\r
+found:\r
+  cur_val = nx_plus_y(save_cur_val, v, xn_over_d(v, f, 65536L));\r
+  goto attach_sign;\r
+\r
+not_found:\r
+  if (mu)\r
+  {\r
+    if (scan_keyword("mu"))\r
+      goto attach_fraction;\r
+    else\r
+    {\r
+      print_err("Illegal unit of measure (");\r
+      prints("mu inserted)");\r
+      help4("The unit of measurement in math glue must be mu.",\r
+          "To recover gracefully from this error, it's best to",\r
+          "delete the erroneous units; e.g., type `2' to delete",\r
+          "two letters. (See Chapter 27 of The TeXbook.)");\r
+      error();\r
+      goto attach_fraction;\r
+    }\r
+  }\r
+\r
+  if (scan_keyword("true"))\r
+  {\r
+    prepare_mag();\r
+\r
+    if (mag != 1000)\r
+    {\r
+      cur_val = xn_over_d(cur_val, 1000, mag);\r
+      f = (1000 * f + 65536L * tex_remainder) / mag;\r
+      cur_val = cur_val + (f / 65536L);\r
+      f = f % 65536L;\r
+    }\r
+  }\r
+\r
+  if (scan_keyword("pt"))\r
+    goto attach_fraction;\r
+\r
+  if (scan_keyword("in"))\r
+    set_conversion(7227, 100);\r
+  else if (scan_keyword("pc"))\r
+    set_conversion(12, 1);\r
+  else if (scan_keyword("cm"))\r
+    set_conversion(7227, 254);\r
+  else if (scan_keyword("mm"))\r
+    set_conversion(7227, 2540);\r
+  else if (scan_keyword("bp"))\r
+    set_conversion(7227, 7200);\r
+  else if (scan_keyword("dd"))\r
+    set_conversion(1238, 1157);\r
+  else if (scan_keyword("cc"))\r
+    set_conversion(14856, 1157);\r
+  else if (scan_keyword("Q"))\r
+    set_conversion(7227, 10160);\r
+  else if (scan_keyword("H"))\r
+    set_conversion(7227, 10160);\r
+  else if (scan_keyword("twip"))\r
+    set_conversion(1, 20);\r
+  else if (scan_keyword("sp"))\r
+    goto done;\r
+  else\r
+  {\r
+    print_err("Illegal unit of measure (");\r
+    prints("pt inserted)");\r
+    help6("Dimensions can be in units of em, ex, in, pt, pc,",\r
+      "cm, mm, dd, cc, bp, or sp; but yours is a new one!",\r
+      "I'll assume that you meant to say pt, for printer's points.",\r
+      "To recover gracefully from this error, it's best to",\r
+      "delete the erroneous units; e.g., type `2' to delete",\r
+      "two letters. (See Chapter 27 of The TeXbook.)");\r
+    error();\r
+    goto done2;\r
+  }\r
+\r
+  cur_val = xn_over_d(cur_val, num, denom);\r
+  f = (num * f + 65536L * tex_remainder) / denom;\r
+  cur_val = cur_val +(f / 65536L);\r
+  f = f % 65536L;\r
+\r
+done2:\r
+attach_fraction:\r
+  if (cur_val >= 16384)     /* 2^14 */\r
+    arith_error = true;\r
+  else\r
+    cur_val = cur_val * unity + f;\r
+\r
+done:\r
+  {\r
+    get_x_token();\r
+\r
+    if (cur_cmd != spacer)\r
+      back_input();\r
+  }\r
+\r
+attach_sign:\r
+  if (arith_error || (abs(cur_val) >= 1073741824L)) /* 2^30 */\r
+  {\r
+    print_err("Dimension too large");\r
+    help2("I can't work with sizes bigger than about 19 feet.",\r
+        "Continue and I'll use the largest value I can.");\r
+    error();\r
+    cur_val = max_dimen;\r
+    arith_error = false;\r
+  }\r
+\r
+  if (negative)\r
+    cur_val = - (integer) cur_val;\r
+}\r
+/* sec 0461 */\r
+void scan_glue (small_number level)\r
+{\r
+  boolean negative;\r
+  pointer q;\r
+  boolean mu;\r
+\r
+  mu = (level == mu_val);\r
+  negative = false;\r
+\r
+  do\r
+    {\r
+      do\r
+        {\r
+          get_x_token();\r
+        }\r
+      while (!(cur_cmd != spacer));\r
+\r
+      if (cur_tok == other_token + '-')\r
+      {\r
+        negative = !negative;\r
+        cur_tok = other_token + '+';\r
+      }\r
+    }\r
+  while (!(cur_tok != other_token + '+'));\r
+\r
+  if ((cur_cmd >= min_internal) && (cur_cmd <= max_internal))\r
+  {\r
+    scan_something_internal(level, negative);\r
+\r
+    if (cur_val_level >= glue_val)\r
+    {\r
+      if (cur_val_level != level)\r
+        mu_error();\r
+\r
+      return;\r
+    }\r
+\r
+    if (cur_val_level == int_val)\r
+      scan_dimen(mu, false, true);\r
+    else if (level == mu_val)\r
+      mu_error();\r
+  }\r
+  else\r
+  {\r
+    back_input();\r
+    scan_dimen(mu, false, false);\r
+\r
+    if (negative)\r
+      cur_val = - (integer) cur_val;\r
+  }\r
+\r
+  q = new_spec(zero_glue);\r
+  width(q) = cur_val;\r
+\r
+  if (scan_keyword("plus"))\r
+  {\r
+    scan_dimen(mu, true, false);\r
+    stretch(q) = cur_val;\r
+    stretch_order(q) = cur_order;\r
+  }\r
+\r
+  if (scan_keyword("minus"))\r
+  {\r
+    scan_dimen(mu, true, false);\r
+    shrink(q) = cur_val;\r
+    shrink_order(q) = cur_order;\r
+  }\r
+\r
+  cur_val = q;\r
+}\r
+/* sec 0463 */\r
+pointer scan_rule_spec (void)\r
+{\r
+  pointer q;\r
+\r
+  q = new_rule();\r
+\r
+  if (cur_cmd == vrule)\r
+    width(q) = default_rule;\r
+  else\r
+  {\r
+    height(q) = default_rule;\r
+    depth(q) = 0;\r
+  }\r
+\r
+reswitch:\r
+\r
+  if (scan_keyword("width"))\r
+  {\r
+    scan_dimen(false, false, false);\r
+    width(q) = cur_val;\r
+    goto reswitch;\r
+  }\r
+\r
+  if (scan_keyword("height"))\r
+  {\r
+    scan_dimen(false, false, false);\r
+    height(q) = cur_val;\r
+    goto reswitch;\r
+  }\r
+\r
+  if (scan_keyword("depth"))\r
+  {\r
+    scan_dimen(false, false, false);\r
+    depth(q) = cur_val;\r
+    goto reswitch;\r
+  }\r
+\r
+  return q;\r
+}\r
+/* sec 0464 */\r
+pointer str_toks (pool_pointer b)\r
+{\r
+  pointer p;\r
+  pointer q;\r
+  halfword t;\r
+  pool_pointer k;\r
+\r
+  str_room(1);\r
+  p = temp_head;\r
+  link(p) = 0;\r
+  k = b;\r
+\r
+  while (k < pool_ptr)\r
+  {\r
+    t = str_pool[k];\r
+\r
+    if (t == ' ')\r
+      t = space_token;\r
+    else\r
+      t = other_token + t;\r
+\r
+    fast_store_new_token(t);\r
+    incr(k);\r
+  }\r
+\r
+  pool_ptr = b;\r
+\r
+  return p;\r
+}\r
+/* sec 0465 */\r
+pointer the_toks (void)\r
+{\r
+  char old_setting;\r
+  pointer p, q, r;\r
+  pool_pointer b;\r
+\r
+  get_x_token();\r
+  scan_something_internal(tok_val, false);\r
+\r
+  if (cur_val_level >= ident_val)\r
+  {\r
+    p = temp_head;\r
+    link(p) = 0;\r
+\r
+    if (cur_val_level == ident_val)\r
+      store_new_token(cs_token_flag + cur_val);\r
+    else if (cur_val != 0)\r
+    {\r
+      r = link(cur_val);\r
+\r
+      while (r != 0)\r
+      {\r
+        fast_store_new_token(info(r));\r
+        r = link(r);\r
+      }\r
+    }\r
+\r
+    return p;\r
+  }\r
+  else\r
+  {\r
+    old_setting = selector;\r
+    selector = new_string;\r
+    b = pool_ptr;\r
+\r
+    switch (cur_val_level)\r
+    {\r
+      case int_val:\r
+        print_int(cur_val);\r
+        break;\r
+\r
+      case dimen_val:\r
+        {\r
+          print_scaled(cur_val);\r
+          prints("pt");\r
+        }\r
+        break;\r
+\r
+      case glue_val:\r
+        {\r
+          print_spec(cur_val, "pt");\r
+          delete_glue_ref(cur_val);\r
+        }\r
+        break;\r
+\r
+      case mu_val:\r
+        {\r
+          print_spec(cur_val, "mu");\r
+          delete_glue_ref(cur_val);\r
+        }\r
+        break;\r
+    }\r
+\r
+    selector = old_setting;\r
+    return str_toks(b);\r
+  }\r
+}\r
+/* sec 0467 */\r
+void ins_the_toks (void) \r
+{ \r
+  link(garbage) = the_toks();\r
+  ins_list(link(temp_head));\r
+}\r
+/* sec 0470 */\r
+void conv_toks (void)\r
+{\r
+  char old_setting;\r
+  char c;\r
+  small_number save_scanner_status;\r
+  pool_pointer b;\r
+\r
+  c = cur_chr;\r
+\r
+  switch (c)\r
+  {\r
+    case number_code:\r
+    case roman_numeral_code:\r
+      scan_int();\r
+      break;\r
+\r
+    case string_code:\r
+    case meaning_code:\r
+      save_scanner_status = scanner_status;\r
+      scanner_status = 0;\r
+      get_token();\r
+      scanner_status = save_scanner_status;\r
+      break;\r
+\r
+    case font_name_code:\r
+      scan_font_ident();\r
+      break;\r
+\r
+    case job_name_code:\r
+      if (job_name == 0)\r
+        open_log_file();\r
+      break;\r
+  }\r
+\r
+  old_setting = selector;\r
+  selector = new_string;\r
+  b = pool_ptr;\r
+\r
+  switch (c)\r
+  {\r
+    case number_code:\r
+      print_int(cur_val);\r
+      break;\r
+\r
+    case roman_numeral_code:\r
+      print_roman_int(cur_val);\r
+      break;\r
+\r
+    case string_code:\r
+      if (cur_cs != 0)\r
+        sprint_cs(cur_cs);\r
+      else\r
+        print_char(cur_chr);\r
+      break;\r
+\r
+    case meaning_code:\r
+      print_meaning();\r
+      break;\r
+\r
+    case font_name_code:\r
+      print(font_name[cur_val]);\r
+\r
+      if (font_size[cur_val] != font_dsize[cur_val])\r
+      {\r
+        prints(" at ");\r
+        print_scaled(font_size[cur_val]);\r
+        prints("pt");\r
+      }\r
+      break;\r
+\r
+    case job_name_code:\r
+      print(job_name);\r
+      break;\r
+  }\r
+\r
+  selector = old_setting;\r
+  link(garbage) = str_toks(b);\r
+  begin_token_list(link(temp_head), 4);\r
+}\r
+/* sec 0473 */\r
+pointer scan_toks (boolean macro_def, boolean xpand)\r
+{\r
+  halfword t;\r
+  halfword s;\r
+  pointer p;\r
+  pointer q;\r
+  halfword unbalance;\r
+  halfword hash_brace;\r
+\r
+  if (macro_def)\r
+    scanner_status = defining;\r
+  else\r
+    scanner_status = absorbing;\r
+\r
+  warning_index = cur_cs;\r
+  def_ref = get_avail();\r
+  token_ref_count(def_ref) = 0;\r
+  p = def_ref;\r
+  hash_brace = 0;\r
+  t = zero_token;\r
+\r
+  if (macro_def)\r
+  {\r
+    while (true)\r
+    {\r
+      get_token();\r
+\r
+      if (cur_tok < right_brace_limit)\r
+        goto done1;\r
+\r
+      if (cur_cmd == mac_param)\r
+      {\r
+        s = match_token + cur_chr;\r
+        get_token();\r
+\r
+        if (cur_cmd == left_brace)\r
+        {\r
+          hash_brace = cur_tok;\r
+          store_new_token(cur_tok);\r
+          store_new_token(end_match_token);\r
+          goto done;\r
+        }\r
+\r
+        if (t == zero_token + 9)\r
+        {\r
+          print_err("You already have nine parameters");\r
+          help1("I'm going to ignore the # sign you just used.");\r
+          error();\r
+        }\r
+        else\r
+        {\r
+          incr(t);\r
+\r
+          if (cur_tok != t)\r
+          {\r
+            print_err("Parameters must be numbered consecutively");\r
+            help2("I've inserted the digit you should have used after the #.",\r
+                "Type `1' to delete what you did use.");\r
+            back_error();\r
+          }\r
+\r
+          cur_tok = s;\r
+        }\r
+      }\r
+\r
+      store_new_token(cur_tok);\r
+    }\r
+\r
+done1:\r
+    store_new_token(end_match_token);\r
+\r
+    if (cur_cmd == right_brace)\r
+    {\r
+      print_err("Missing { inserted");\r
+      incr(align_state);\r
+      help2("Where was the left brace? You said something like `\\def\\a}',",\r
+          "which I'm going to interpret as `\\def\\a{}'.");\r
+      error();\r
+      goto found;\r
+    }\r
+done:;\r
+  }\r
+  else\r
+  {\r
+    scan_left_brace();\r
+  }\r
+\r
+  unbalance = 1;\r
+\r
+  while (true)\r
+  {\r
+    if (xpand)\r
+    {\r
+      while (true)\r
+      {\r
+        get_next();\r
+\r
+        if (cur_cmd <= max_command)\r
+          goto done2;\r
+\r
+        if (cur_cmd != the)\r
+        {\r
+          expand();\r
+        }\r
+        else\r
+        {\r
+          q = the_toks();\r
+\r
+          if (link(temp_head) != 0)\r
+          {\r
+            link(p) = link(temp_head);\r
+            p = q;\r
+          }\r
+        }\r
+      }\r
+done2:\r
+      x_token();\r
+    }\r
+    else\r
+      get_token();\r
+\r
+    if (cur_tok < right_brace_limit)\r
+      if (cur_cmd < right_brace)\r
+        incr(unbalance);\r
+      else\r
+      {\r
+        decr(unbalance);\r
+\r
+        if (unbalance == 0)\r
+          goto found;\r
+      }\r
+    else if (cur_cmd == mac_param)\r
+      if (macro_def)\r
+      {\r
+        s = cur_tok;\r
+\r
+        if (xpand)\r
+          get_x_token();\r
+        else\r
+          get_token();\r
+\r
+        if (cur_cmd != mac_param)\r
+          if ((cur_tok <= zero_token) || (cur_tok > t))\r
+          {\r
+            print_err("Illegal parameter number in definition of ");\r
+            sprint_cs(warning_index);\r
+            help3("You meant to type ## instead of #, right?",\r
+                "Or maybe a } was forgotten somewhere earlier, and things",\r
+                "are all screwed up? I'm going to assume that you meant ##.");\r
+            back_error();\r
+            cur_tok = s;\r
+          }\r
+          else\r
+            cur_tok = out_param_token - '0' + cur_chr;\r
+      }\r
+\r
+    store_new_token(cur_tok);\r
+  }\r
+\r
+found:\r
+  scanner_status = 0;\r
+\r
+  if (hash_brace != 0)\r
+    store_new_token(hash_brace);\r
+\r
+  return p;\r
+}\r
+/* sec 0482 */\r
+void read_toks (integer n, pointer r)\r
+{\r
+  pointer p;\r
+  pointer q;\r
+  integer s;\r
+  /* small_number m; */\r
+  int m;\r
+\r
+  scanner_status = defining;\r
+  warning_index = r;\r
+  def_ref = get_avail();\r
+  token_ref_count(def_ref) = 0;\r
+  p = def_ref;\r
+  store_new_token(end_match_token);\r
+\r
+  if ((n < 0) || (n > 15))\r
+    m = 16;\r
+  else\r
+    m = n;\r
+\r
+  s = align_state;\r
+  align_state = 1000000L;\r
+\r
+  do\r
+    {\r
+      begin_file_reading();\r
+      name = m + 1;\r
+\r
+      if (read_open[m] == closed)\r
+        if (interaction > nonstop_mode)\r
+          if (n < 0)\r
+            prompt_input("");\r
+          else\r
+          {\r
+            print_ln();\r
+            sprint_cs(r);\r
+            prompt_input("=");\r
+            n = -1;\r
+          }\r
+        else\r
+        {\r
+          fatal_error("*** (cannot \\read from terminal in nonstop modes)");\r
+          return;\r
+        }\r
+      else if (read_open[m] == just_open)\r
+        if (input_ln(read_file[m], false))\r
+          read_open[m] = normal;\r
+        else\r
+        {\r
+          a_close(read_file[m]);\r
+          read_open[m] = closed;\r
+        }\r
+      else\r
+      {\r
+        if (!input_ln(read_file[m], true))\r
+        {\r
+          a_close(read_file[m]);\r
+          read_open[m] = closed;\r
+\r
+          if (align_state != 1000000L)\r
+          {\r
+            runaway();\r
+            print_err("File ended within ");\r
+            print_esc("read");\r
+            help1("This \\read has unbalanced braces.");\r
+            align_state = 1000000L;\r
+            error();\r
+          }\r
+        }\r
+      }\r
+\r
+      limit = last;\r
+\r
+      if (end_line_char_inactive())\r
+        decr(limit);\r
+      else\r
+        buffer[limit] = end_line_char;\r
+\r
+      first = limit + 1;\r
+      loc = start;\r
+      state = new_line;\r
+\r
+      while (true)\r
+      {\r
+        get_token();\r
+\r
+        if (cur_tok == 0)\r
+          goto done;\r
+\r
+        if (align_state < 1000000L)\r
+        {\r
+          do\r
+            {\r
+              get_token();\r
+            }\r
+          while (!(cur_tok == 0));\r
+\r
+          align_state = 1000000L;\r
+          goto done;\r
+        }\r
+\r
+        store_new_token(cur_tok);\r
+      }\r
+\r
+done:\r
+      end_file_reading();\r
+    }\r
+  while (!(align_state == 1000000L));\r
+\r
+  cur_val = def_ref;\r
+  scanner_status = normal;\r
+  align_state = s;\r
+}\r
+/* sec 0494 */\r
+void pass_text (void)\r
+{\r
+  integer l;\r
+  small_number save_scanner_status;\r
+\r
+  save_scanner_status = scanner_status;\r
+  scanner_status = skipping;\r
+  l = 0;\r
+  skip_line = line;\r
+\r
+  while (true)\r
+  {\r
+    get_next();\r
+\r
+    if (cur_cmd == fi_or_else)\r
+    {\r
+      if (l == 0)\r
+        goto done;\r
+\r
+      if (cur_chr == fi_code)\r
+        decr(l);\r
+    }\r
+    else if (cur_cmd == if_test)\r
+      incr(l);\r
+  }\r
+\r
+done:\r
+  scanner_status = save_scanner_status;\r
+}\r
+/* sec 0497 */\r
+void change_if_limit (small_number l, pointer p)\r
+{\r
+  pointer q;\r
+\r
+  if (p == cond_ptr)\r
+    if_limit = l;\r
+  else\r
+  {\r
+    q = cond_ptr;\r
+\r
+    while (true)\r
+    {\r
+      if (q == 0)\r
+      {\r
+        confusion("if");\r
+        return;\r
+      }\r
+\r
+      if (link(q) == p)\r
+      {\r
+        type(p) = l;\r
+        return;\r
+      }\r
+\r
+      q = link(q);\r
+    }\r
+  }\r
+}\r
+/* sec 0498 */\r
+void conditional (void)\r
+{\r
+  boolean b;\r
+  char r;\r
+  integer m, n;\r
+  pointer p, q;\r
+  small_number save_scanner_status;\r
+  pointer save_cond_ptr;\r
+  small_number this_if;\r
+\r
+  {\r
+    p = get_node(if_node_size);\r
+    link(p) = cond_ptr;\r
+    type(p) = if_limit;\r
+    subtype(p) = cur_if;\r
+    if_line_field(p) = if_line;\r
+    cond_ptr = p;\r
+    cur_if = cur_chr;\r
+    if_limit = if_code;\r
+    if_line = line;\r
+  }\r
+\r
+  save_cond_ptr = cond_ptr;\r
+  this_if = cur_chr;\r
+\r
+  switch (this_if)\r
+  {\r
+    case if_char_code:\r
+    case if_cat_code:\r
+      {\r
+        get_x_token_or_active_char();\r
+\r
+        if ((cur_cmd > active_char) || (cur_chr > 255))\r
+        {\r
+          m = relax;\r
+          n = 256;\r
+        }\r
+        else\r
+        {\r
+          m = cur_cmd;\r
+          n = cur_chr;\r
+        }\r
+\r
+        get_x_token_or_active_char();\r
+\r
+        if ((cur_cmd > active_char) || (cur_chr > 255))\r
+        {\r
+          cur_cmd = relax;\r
+          cur_chr = 256;\r
+        }\r
+\r
+        if (this_if == if_char_code)\r
+          b = (n == cur_chr); \r
+        else\r
+          b = (m == cur_cmd);\r
+      }\r
+      break;\r
+\r
+    case if_int_code:\r
+    case if_dim_code:\r
+      {\r
+        if (this_if == if_int_code)\r
+          scan_int();\r
+        else\r
+          scan_dimen(false, false, false);\r
+\r
+        n = cur_val;\r
+        \r
+        do\r
+          {\r
+            get_x_token();\r
+          }\r
+        while (!(cur_cmd != spacer));\r
+\r
+        if ((cur_tok >= other_token + '<') && (cur_tok <= other_token + '>'))\r
+          r = cur_tok - other_token;\r
+        else\r
+        {\r
+          print_err("Missing = inserted for ");\r
+          print_cmd_chr(if_test, this_if);\r
+          help1("I was expecting to see `<', `=', or `>'. Didn't.");\r
+          back_error();\r
+          r = '=';\r
+        }\r
+\r
+        if (this_if == if_int_code)\r
+          scan_int();\r
+        else \r
+          scan_dimen(false, false, false);\r
+\r
+        switch (r)\r
+        {\r
+          case '<':\r
+            b = (n < cur_val);\r
+            break;\r
+\r
+          case '=':\r
+            b = (n == cur_val);\r
+            break;\r
+\r
+          case '>':\r
+            b = (n > cur_val);\r
+            break;\r
+        }\r
+      }\r
+      break;\r
+\r
+    case if_odd_code:\r
+      scan_int();\r
+      b = odd(cur_val);\r
+      break;\r
+\r
+    case if_vmode_code:\r
+      b = (abs(mode) == vmode);\r
+      break;\r
+\r
+    case if_hmode_code:\r
+      b = (abs(mode) == hmode);\r
+      break;\r
+\r
+    case if_mmode_code:\r
+      b = (abs(mode) == mmode);\r
+      break;\r
+\r
+    case if_inner_code:\r
+      b = (mode < 0);\r
+      break;\r
+\r
+    case if_void_code:\r
+    case if_hbox_code:\r
+    case if_vbox_code:\r
+      {\r
+        scan_eight_bit_int();\r
+        p = box(cur_val);\r
+\r
+        if (this_if == if_void_code)\r
+          b = (p == 0);\r
+        else if (p == 0)\r
+          b = false;\r
+        else if (this_if == if_hbox_code)\r
+          b = (type(p) == hlist_node);\r
+        else\r
+          b = (type(p) == vlist_node);\r
+      }\r
+      break;\r
+\r
+    case ifx_code:\r
+      {\r
+        save_scanner_status = scanner_status;\r
+        scanner_status = 0;\r
+        get_next();\r
+        n = cur_cs;\r
+        p = cur_cmd;\r
+        q = cur_chr;\r
+        get_next();\r
+\r
+        if (cur_cmd != p)\r
+          b = false;\r
+        else if (cur_cmd < call)\r
+          b = (cur_chr == q);\r
+        else\r
+        {\r
+          p = link(cur_chr);\r
+          q = link(equiv(n));\r
+\r
+          if (p == q)\r
+            b = true;\r
+          else\r
+          {\r
+            while ((p != 0) && (q != 0))\r
+              if (info(p) != info(q))\r
+                p = 0;\r
+              else\r
+              {\r
+                p = link(p);\r
+                q = link(q);\r
+              }\r
+\r
+            b = ((p == 0) && (q == 0));\r
+          }\r
+        }\r
+\r
+        scanner_status = save_scanner_status;\r
+      }\r
+      break;\r
+\r
+    case if_eof_code:\r
+      {\r
+        scan_four_bit_int();\r
+        b = (read_open[cur_val] == closed);\r
+      }\r
+      break;\r
+\r
+    case if_true_code:\r
+      b = true;\r
+      break;\r
+\r
+    case if_false_code:\r
+      b = false;\r
+      break;\r
+\r
+    case if_case_code:\r
+      {\r
+        scan_int();\r
+        n = cur_val;\r
+\r
+        if (tracing_commands > 1)\r
+        {\r
+          begin_diagnostic();\r
+          prints("{case ");\r
+          print_int(n); \r
+          print_char('}');\r
+          end_diagnostic(false);\r
+        }\r
+\r
+        while (n != 0)\r
+        {\r
+          pass_text();\r
+\r
+          if (cond_ptr == save_cond_ptr)\r
+            if (cur_chr == or_code)\r
+              decr(n);\r
+            else \r
+              goto common_ending;\r
+          else if (cur_chr == fi_code)\r
+          {\r
+            p = cond_ptr;\r
+            if_line = if_line_field(p);\r
+            cur_if = subtype(p);\r
+            if_limit = type(p);\r
+            cond_ptr = link(p);\r
+            free_node(p, if_node_size);\r
+          }\r
+        }\r
+\r
+        change_if_limit(or_code, save_cond_ptr);\r
+        return;\r
+      }\r
+      break;\r
+  }\r
+\r
+  if (tracing_commands > 1)\r
+  {\r
+    begin_diagnostic();\r
+\r
+    if (b)\r
+      prints("{true}");\r
+    else\r
+      prints("{false}");\r
+\r
+    end_diagnostic(false);\r
+  }\r
+\r
+  if (b)\r
+  {\r
+    change_if_limit(else_code, save_cond_ptr);\r
+    return;\r
+  }\r
+\r
+  while (true)\r
+  {\r
+    pass_text();\r
+\r
+    if (cond_ptr == save_cond_ptr)\r
+    {\r
+      if (cur_chr != or_code)\r
+        goto common_ending;\r
+\r
+      print_err("Extra ");\r
+      print_esc("or");\r
+      help1("I'm ignoring this; it doesn't match any \\if.");\r
+      error();\r
+    }\r
+    else if (cur_chr == fi_code)\r
+    {\r
+      p = cond_ptr;\r
+      if_line = if_line_field(p);\r
+      cur_if = subtype(p);\r
+      if_limit = type(p);\r
+      cond_ptr = link(p);\r
+      free_node(p, if_node_size);\r
+    }\r
+  }\r
+\r
+common_ending:\r
+  if (cur_chr == fi_code)\r
+  {\r
+    p = cond_ptr;\r
+    if_line = if_line_field(p);\r
+    cur_if = subtype(p);\r
+    if_limit = type(p);\r
+    cond_ptr = link(p);\r
+    free_node(p, if_node_size);\r
+  }\r
+  else\r
+    if_limit = fi_code;\r
+}\r
+/* sec 0515 */\r
+void begin_name (void)\r
+{\r
+  area_delimiter = 0;\r
+  ext_delimiter = 0;\r
+}\r
+/* sec 0516 */\r
+boolean more_name (ASCII_code c)\r
+{\r
+  if (quoted_file_name == false && c == ' ')\r
+    return false;\r
+  else if (quoted_file_name != false && c == '"')\r
+  {\r
+    quoted_file_name = false; /* catch next space character */\r
+    return true;     /* accept ending quote, but throw away */\r
+  }\r
+  else\r
+  {   \r
+    str_room(1);\r
+    append_char(c);\r
+\r
+    //  for DOS/Windows\r
+    if ((c == '/' || c == '\\' || c == ':')) \r
+    {\r
+      area_delimiter = cur_length;\r
+      ext_delimiter = 0;\r
+    } \r
+    else if (c == '.')\r
+      ext_delimiter = cur_length;\r
+\r
+    return true;\r
+  }\r
+}\r
+\r
+/* sec 0517 */\r
+void end_name (void) \r
+{\r
+#ifdef ALLOCATESTRING\r
+  if (str_ptr + 3 > current_max_strings)\r
+    str_start = realloc_str_start(increment_max_strings + 3);\r
+\r
+  if (str_ptr + 3 > current_max_strings)\r
+  {\r
+    overflow("number of strings", current_max_strings - init_str_ptr);\r
+    return;\r
+  }\r
+#else\r
+  if (str_ptr + 3 > max_strings)\r
+  {\r
+    overflow("number of strings", max_strings - init_str_ptr);\r
+    return;\r
+  }\r
+#endif\r
+\r
+  if (area_delimiter == 0) // no area delimiter ':' '/' or '\' found\r
+    cur_area = 335;        // "" default area \r
+  else\r
+  {\r
+    cur_area = str_ptr;\r
+    str_start[str_ptr + 1] = str_start[str_ptr] + area_delimiter;\r
+    incr(str_ptr);\r
+  }\r
+\r
+  if (ext_delimiter == 0) // no extension delimiter '.' found\r
+  {\r
+    cur_ext = 335;        // "" default extension \r
+    cur_name = make_string();\r
+  } \r
+  else\r
+  {\r
+    cur_name = str_ptr;\r
+    str_start[str_ptr + 1] = str_start[str_ptr] + ext_delimiter - area_delimiter - 1;\r
+    incr(str_ptr);\r
+    cur_ext = make_string();\r
+  }\r
+}\r
+/* sec 0519 */\r
+void pack_file_name (str_number n, str_number a, str_number e)\r
+{\r
+  integer k;\r
+  ASCII_code c;\r
+  pool_pointer j;\r
+\r
+  k = 0;\r
+\r
+  for (j = str_start[a]; j <= str_start[a + 1] - 1; j++)\r
+    append_to_name(str_pool[j]);\r
+\r
+  for (j = str_start[n]; j <= str_start[n + 1] - 1; j++)\r
+    append_to_name(str_pool[j]);\r
+\r
+  for (j = str_start[e]; j <= str_start[e + 1] - 1; j++)\r
+    append_to_name(str_pool[j]);\r
+\r
+  if (k < file_name_size)\r
+    name_length = k;\r
+  else\r
+    name_length = file_name_size - 1;\r
+\r
+  for (k = name_length + 1; k <= file_name_size; k++)\r
+    name_of_file[k] = ' ';\r
+\r
+  name_of_file[file_name_size] = '\0'; /* paranoia */\r
+\r
+  {\r
+    name_of_file [name_length + 1] = '\0';\r
+\r
+    if (trace_flag)\r
+      printf(" pack_file_name `%s' (%lld) ", name_of_file + 1, name_length);\r
+\r
+    name_of_file [name_length + 1] = ' ';\r
+  }\r
+}\r
+/* Called only from two places tex9.c for format name - specified and default */\r
+/* for specified format name args are 0, a, b name in buffer[a] --- buffer[b] */\r
+/* for default args are format_default_length-4, 1, 0 */\r
+/* sec 0523 */\r
+void pack_buffered_name_(small_number n, integer a, integer b)\r
+{\r
+  integer k;\r
+  ASCII_code c;\r
+  integer j;\r
+\r
+  if (n + b - a + 5 > file_name_size)\r
+    b = a + file_name_size - n - 5;\r
+\r
+  k = 0;\r
+\r
+  for (j = 1; j <= n; j++)\r
+    append_to_name(xord[TEX_format_default[j]]);\r
+\r
+  for (j = a; j <= b; j++)\r
+    append_to_name(buffer[j]);\r
+\r
+  for (j = format_default_length - 3; j <= format_default_length; j++)\r
+    append_to_name(xord[TEX_format_default[j]]);\r
+\r
+  if (k < file_name_size)\r
+    name_length = k;\r
+  else\r
+    name_length = file_name_size - 1;\r
+\r
+  for (k = name_length + 1; k <= file_name_size; k++)\r
+    name_of_file[k]= ' ';\r
+\r
+  name_of_file[file_name_size] = '\0';\r
+}\r
+/* sec 0525 */\r
+str_number make_name_string (void)\r
+{\r
+  integer k;\r
+\r
+#ifdef ALLOCATESTRING\r
+  if (pool_ptr + name_length > current_pool_size)\r
+    str_pool = realloc_str_pool(increment_pool_size + name_length);\r
+\r
+  if (str_ptr == current_max_strings)\r
+    str_start = realloc_str_start(increment_max_strings);\r
+\r
+  if ((pool_ptr + name_length > current_pool_size) || (str_ptr == current_max_strings) || (cur_length > 0))\r
+#else\r
+  if ((pool_ptr + name_length > pool_size) || (str_ptr == max_strings) || (cur_length > 0))\r
+#endif\r
+  {\r
+    return '?';\r
+  }\r
+  else\r
+  {\r
+    for (k = 1; k <= name_length; k++)\r
+      append_char(xord[name_of_file[k]]);\r
+\r
+    return make_string();\r
+  }\r
+}\r
+/* sec 0525 */\r
+//str_number a_make_name_string (alpha_file * f)\r
+str_number a_make_name_string_(void)\r
+{\r
+  return make_name_string();\r
+}\r
+/* sec 0525 */\r
+//str_number b_make_name_string_(byte_file * f)\r
+str_number b_make_name_string_(void)\r
+{\r
+  return make_name_string(); \r
+}\r
+/* sec 0525 */\r
+//str_number w_make_name_string_(word_file * f)\r
+str_number w_make_name_string_(void)\r
+{\r
+  return make_name_string();\r
+}\r
+/* sec 0526 */\r
+void scan_file_name (void)\r
+{\r
+  name_in_progress = true;\r
+  begin_name();\r
+\r
+  do\r
+    {\r
+      get_x_token(); \r
+    }\r
+  while (!(cur_cmd != spacer));\r
+\r
+  quoted_file_name = false;\r
+\r
+  if (allow_quoted_names)\r
+  {\r
+    if (cur_chr == '"')\r
+    {\r
+      quoted_file_name = true;\r
+      get_x_token();\r
+    }\r
+  }\r
+\r
+  while (true)\r
+  {\r
+    if ((cur_cmd > other_char) || (cur_chr > 255)) \r
+    {\r
+      back_input();\r
+      goto done; \r
+    } \r
+\r
+    if (!more_name(cur_chr))\r
+      goto done;\r
+\r
+    get_x_token();\r
+  }\r
+\r
+done:\r
+  end_name();\r
+  name_in_progress = false;\r
+}\r
+/* argument is string .fmt, .log, .pdf, or .dvi */\r
+/* sec 0529 */\r
+void pack_job_name_(str_number s)\r
+{\r
+  cur_area = 335; /* "" */\r
+  cur_ext  = s;\r
+  cur_name = job_name;\r
+  pack_file_name(cur_name, cur_area, cur_ext);\r
+}\r
+/* sec 0530 */\r
+void prompt_file_name_(const char * s, str_number e) \r
+{\r
+  integer k;\r
+\r
+  if (interaction == scroll_mode)\r
+    do_nothing();\r
+\r
+  if (!strcmp("input file name", s))\r
+    print_err("I can't find file `");\r
+  else\r
+    print_err("I can't write on file `");\r
+\r
+  print_file_name(cur_name, cur_area, cur_ext);\r
+  prints("'.");\r
+\r
+  if (e == 785)    /* .tex */\r
+    show_context();\r
+\r
+  print_nl("Please type another ");\r
+  prints(s); \r
+\r
+  if (interaction < scroll_mode)\r
+  {\r
+    fatal_error("*** (job aborted, file error in nonstop mode)");\r
+    return;\r
+  }\r
+\r
+  if (!knuth_flag)\r
+    show_line(" (or Ctrl-Z to exit)", 0);\r
+\r
+  prompt_input(": ");\r
+\r
+  {\r
+    begin_name();\r
+    k = first;\r
+\r
+    while ((buffer[k] == ' ') && (k < last))\r
+      incr(k);\r
+\r
+    quoted_file_name = false;\r
+\r
+    if (allow_quoted_names && k < last) /* check whether quoted name */\r
+    {\r
+      if (buffer[k]== '"')\r
+      {\r
+        quoted_file_name = true;\r
+        incr(k);\r
+      }\r
+    }\r
+\r
+    while (true)\r
+    {\r
+      if (k == last)\r
+        goto done;\r
+\r
+      /* convert tilde '~' to pseudo tilde */\r
+      if (pseudo_tilde != 0 && buffer[k]== '~')\r
+        buffer[k] = pseudo_tilde;\r
+\r
+      /* convert space ' ' to pseudo space */\r
+      if (pseudo_space != 0 && buffer[k]== ' ')\r
+        buffer[k] = pseudo_space;\r
+\r
+      if (!more_name(buffer[k]))\r
+        goto done;\r
+\r
+      incr(k);\r
+    }\r
+\r
+done:\r
+    end_name();\r
+  }\r
+\r
+  if (cur_ext == 335) /* "" */\r
+    cur_ext = e;      /* use default extension */\r
+\r
+  pack_file_name(cur_name, cur_area, cur_ext);\r
+}\r
+/* sec 0534 */\r
+void open_log_file (void)\r
+{\r
+  char old_setting;\r
+  integer k;\r
+  integer l;\r
+  char * months;\r
+\r
+  old_setting = selector;\r
+\r
+  if (job_name == 0)\r
+    job_name = get_job_name(790);\r
+    //job_name = 790;\r
+\r
+  pack_job_name(".log");\r
+\r
+  while (!a_open_out(log_file))\r
+  {\r
+    selector = term_only;\r
+    prompt_file_name("transcript file name", ".log");\r
+  }\r
+\r
+  log_name = a_make_name_string(log_file);\r
+  selector = log_only;\r
+  log_opened = true;\r
+\r
+  {\r
+    fprintf(log_file, "%s (%s %s)", banner, application, yandyversion);\r
+\r
+    if (format_ident > 0)\r
+      slow_print(format_ident);\r
+\r
+    prints("  ");\r
+\r
+    if (civilize_flag)\r
+      print_int(year);\r
+    else\r
+      print_int(day);\r
+\r
+    print_char(' ');\r
+    months = " JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";\r
+\r
+    for (k = 3 * month - 2; k <= 3 * month; k++)\r
+      putc(months[k], log_file);\r
+\r
+    print_char(' ');\r
+\r
+    if (civilize_flag)\r
+      print_int(day);\r
+    else\r
+      print_int(year);\r
+\r
+    print_char(' ');\r
+    print_two(tex_time / 60);\r
+    print_char(':');\r
+    print_two(tex_time % 60);\r
+  }\r
+\r
+  input_stack[input_ptr] = cur_input;\r
+  print_nl("**");\r
+  l = input_stack[0].limit_field;\r
+\r
+  if (buffer[l] == end_line_char)\r
+    decr(l);\r
+\r
+  for (k = 1; k <= l; k++)\r
+    print(buffer[k]);\r
+\r
+  print_ln(); \r
+\r
+  if (show_fmt_flag)\r
+  {\r
+    if (format_file != NULL)\r
+    {\r
+      fprintf(log_file, "(%s)\n", format_file);\r
+      free(format_file);\r
+      format_file = NULL;\r
+    }\r
+  }\r
+\r
+  selector = old_setting + 2;\r
+}\r
+/* sec 0537 */\r
+void start_input (void)\r
+{\r
+  scan_file_name();\r
+  pack_file_name(cur_name, cur_area, cur_ext); \r
+\r
+  while (true)\r
+  {\r
+    begin_file_reading();\r
+    \r
+    if (a_open_in(cur_file, kpse_tex_format))\r
+      goto done;\r
+\r
+    end_file_reading();\r
+    prompt_file_name("input file name", ".tex");\r
+  }\r
+\r
+done: \r
+  name = a_make_name_string(cur_file);\r
+\r
+  if (job_name == 0)\r
+  {\r
+    job_name = get_job_name(cur_name);\r
+    //job_name = cur_name;\r
+    open_log_file();\r
+  }\r
+\r
+  if (term_offset + length(name) > max_print_line - 2)\r
+    print_ln();\r
+  else if ((term_offset > 0) || (file_offset > 0))\r
+    print_char(' ');\r
+\r
+  print_char('(');\r
+  incr(open_parens);\r
+\r
+  if (open_parens > max_open_parens)\r
+    max_open_parens = open_parens;\r
+\r
+  slow_print(name);\r
+  update_terminal();\r
+  state = new_line;\r
+\r
+  {\r
+    line = 1;\r
+\r
+    if (input_ln(cur_file, false))\r
+      do_nothing();\r
+\r
+    firm_up_the_line();\r
+\r
+    if (end_line_char_inactive())\r
+      decr(limit);\r
+    else\r
+      buffer[limit] = end_line_char;\r
+\r
+    first = limit + 1;\r
+    loc = start;\r
+  }\r
+}\r
+/* sec 0560 */\r
+internal_font_number read_font_info (pointer u, str_number nom, str_number aire, scaled s)\r
+{\r
+  font_index k;\r
+  boolean file_opened;\r
+  halfword lf, lh, nw, nh, nd, ni, nl, nk, ne, np;\r
+  int bc, ec;\r
+  internal_font_number f;\r
+  internal_font_number g;\r
+  eight_bits a, b, c, d;\r
+  four_quarters qw;\r
+  scaled sw;\r
+  integer bch_label;\r
+  short bchar;\r
+  scaled z;\r
+  integer alpha;\r
+  char beta;\r
+\r
+  g = 0;\r
+  file_opened = false;\r
+  pack_file_name(nom, aire, 805); /* .tfm */\r
+\r
+  if (!b_open_in(tfm_file))\r
+    goto bad_tfm;\r
+\r
+  file_opened = true;\r
+\r
+  {\r
+    read_sixteen(lf);\r
+    fget();\r
+    read_sixteen(lh);\r
+    fget();\r
+    read_sixteen(bc);\r
+    fget();\r
+    read_sixteen(ec);\r
+\r
+    if ((bc > ec + 1) || (ec > 255))\r
+      goto bad_tfm;\r
+\r
+    if (bc > 255)\r
+    {\r
+      bc = 1;\r
+      ec = 0;\r
+    }\r
+\r
+    fget();\r
+    read_sixteen(nw);\r
+    fget();\r
+    read_sixteen(nh);\r
+    fget();\r
+    read_sixteen(nd);\r
+    fget();\r
+    read_sixteen(ni);\r
+    fget();\r
+    read_sixteen(nl);\r
+    fget();\r
+    read_sixteen(nk);\r
+    fget();\r
+    read_sixteen(ne);\r
+    fget();\r
+    read_sixteen(np);\r
+\r
+    if (lf != 6 + lh + (ec - bc + 1) + nw + nh + nd + ni + nl + nk + ne + np)\r
+      goto bad_tfm;\r
+\r
+    if ((nw == 0) || (nh == 0) || (nd == 0) || (ni == 0))\r
+      goto bad_tfm;\r
+  }\r
+\r
+  lf = lf - 6 - lh;\r
+\r
+  if (np < 7)\r
+    lf = lf + 7 - np;\r
+\r
+#ifdef ALLOCATEFONT\r
+  if ((fmem_ptr + lf > current_font_mem_size))\r
+    font_info = realloc_font_info (increment_font_mem_size + lf);\r
+\r
+  if ((font_ptr == font_max) || (fmem_ptr + lf > current_font_mem_size))\r
+#else\r
+  if ((font_ptr == font_max) || (fmem_ptr + lf > font_mem_size))\r
+#endif\r
+  {\r
+    if (trace_flag)\r
+      printf("font_ptr %lld font_max %d fmem_ptr %lld lf %d font_mem_size %ld\n",\r
+          font_ptr, font_max, fmem_ptr, lf, font_mem_size);\r
+\r
+    start_font_error_message();\r
+    prints(" not loaded: Not enough room left");\r
+    help4("I'm afraid I won't be able to make use of this font,",\r
+        "because my memory for character-size data is too small.",\r
+        "If you're really stuck, ask a wizard to enlarge me.",\r
+        "Or maybe try `I\\font<same font id>=<name of loaded font>'.");\r
+    error();\r
+    goto done;\r
+  }\r
+\r
+  f = font_ptr + 1;\r
+  char_base[f] = fmem_ptr - bc;\r
+  width_base[f] = char_base[f] + ec + 1;\r
+  height_base[f] = width_base[f] + nw;\r
+  depth_base[f] = height_base[f] + nh;\r
+  italic_base[f] = depth_base[f] + nd;\r
+  lig_kern_base[f] = italic_base[f] + ni;\r
+  kern_base[f] = lig_kern_base[f] + nl - kern_base_offset;\r
+  exten_base[f] = kern_base[f] + kern_base_offset + nk;\r
+  param_base[f] = exten_base[f] + ne;\r
+\r
+  {\r
+    if (lh < 2)\r
+      goto bad_tfm;\r
+    \r
+    store_four_quarters(font_check[f]);\r
+    fget();\r
+    read_sixteen(z);\r
+    fget();\r
+    z = z * 256 + fbyte;\r
+    fget();\r
+    z = (z * 16) + (fbyte / 16);\r
+\r
+    if (z < unity)\r
+      goto bad_tfm; \r
+\r
+    while (lh > 2)\r
+    {\r
+      fget();\r
+      fget();\r
+      fget();\r
+      fget();\r
+      decr(lh);\r
+    }\r
+\r
+    font_dsize[f] = z;\r
+\r
+    if (s != -1000)\r
+      if (s >= 0)\r
+        z = s;\r
+      else\r
+        z = xn_over_d(z, - (integer) s, 1000);\r
+\r
+    font_size[f] = z;\r
+  }\r
+\r
+  for (k = fmem_ptr; k <= width_base[f] - 1; k++)\r
+  {\r
+    store_four_quarters(font_info[k].qqqq);\r
+\r
+    if ((a >= nw) || (b / 16 >= nh) || (b % 16 >= nd) || (c / 4 >= ni))\r
+      goto bad_tfm;\r
+\r
+    switch (c % 4)\r
+    {\r
+      case lig_tag:\r
+        if (d >= nl)\r
+          goto bad_tfm;\r
+        break;\r
+\r
+      case ext_tag:\r
+        if (d >= ne)\r
+          goto bad_tfm;\r
+        break;\r
+\r
+      case list_tag:\r
+        {\r
+          check_byte_range(d);\r
+\r
+          while (d < k + bc - fmem_ptr)\r
+          {\r
+            qw = char_info(f, d);\r
\r
+            if (char_tag(qw) != list_tag)\r
+              goto not_found;\r
+\r
+            d = rem_byte(qw);\r
+          }\r
+\r
+          if (d == k + bc - fmem_ptr)\r
+            goto bad_tfm;\r
+not_found:;\r
+        }\r
+        break;\r
+\r
+      default:\r
+        break;\r
+    }\r
+  }\r
+\r
+  {\r
+    {\r
+      alpha = 16;\r
+\r
+      while (z >= 8388608L)   /* 2^23 */\r
+      {\r
+        z = z / 2;\r
+        alpha = alpha + alpha;\r
+      }\r
+\r
+      beta = (char) (256 / alpha);\r
+      alpha = alpha * z;\r
+    }\r
+\r
+    for (k = width_base[f]; k <= lig_kern_base[f] - 1; k++)\r
+      store_scaled(font_info[k].cint);\r
+\r
+    if (font_info[width_base[f]].cint != 0)\r
+      goto bad_tfm;\r
+\r
+    if (font_info[height_base[f]].cint != 0)\r
+      goto bad_tfm;\r
+\r
+    if (font_info[depth_base[f]].cint != 0)\r
+      goto bad_tfm;\r
+\r
+    if (font_info[italic_base[f]].cint != 0)\r
+      goto bad_tfm;\r
+  }\r
+\r
+  bch_label = 32767;     /* '77777 */\r
+  bchar = 256;\r
+\r
+  if (nl > 0)\r
+  {\r
+    for (k = lig_kern_base[f]; k <= kern_base[f] + kern_base_offset - 1; k++)\r
+    {\r
+      store_four_quarters(font_info[k].qqqq);\r
+\r
+      if (a > 128)\r
+      {\r
+        if (256 * c + d >= nl)\r
+          goto bad_tfm;\r
+\r
+        if (a == 255)\r
+          if (k == lig_kern_base[f])\r
+            bchar = b;\r
+      }\r
+      else\r
+      {\r
+        if (b != bchar)\r
+          check_existence(b);\r
+\r
+        if (c < 128)\r
+          check_existence(d);\r
+        else if (256 * (c - 128) + d >= nk)\r
+          goto bad_tfm;\r
+\r
+        if (a < 128)\r
+          if (k - lig_kern_base[f] + a + 1 >= nl)\r
+            goto bad_tfm;\r
+      }\r
+    }\r
+\r
+    if (a == 255)\r
+      bch_label = 256 * c + d;\r
+  }\r
+\r
+  for (k = kern_base[f] + kern_base_offset; k <= exten_base[f] - 1; k++)\r
+    store_scaled(font_info[k].cint);\r
+\r
+  for (k = exten_base[f]; k <= param_base[f] - 1; k++)\r
+  {\r
+    store_four_quarters(font_info[k].qqqq);\r
+\r
+    if (a != 0)\r
+      check_existence(a);\r
+\r
+    if (b != 0)\r
+      check_existence(b);\r
+\r
+    if (c != 0)\r
+      check_existence(c);\r
+\r
+    check_existence(d);\r
+  }\r
+\r
+  {\r
+    for (k = 1; k <= np; k++)\r
+      if (k == 1)\r
+      {\r
+        fget();\r
+        sw = fbyte;\r
+\r
+        if (sw > 127)\r
+          sw = sw - 256;\r
+\r
+        fget();\r
+        sw = sw * 256 + fbyte;\r
+        fget();\r
+        sw = sw * 256 + fbyte;\r
+        fget();\r
+        font_info[param_base[f]].cint = (sw * 16) + (fbyte / 16);\r
+      }\r
+      else\r
+        store_scaled(font_info[param_base[f] + k - 1].cint);\r
+\r
+    if (feof(tfm_file))\r
+      goto bad_tfm;\r
+\r
+    for (k = np + 1; k <= 7; k++)\r
+      font_info[param_base[f] + k - 1].cint = 0;\r
+  }\r
+\r
+  if (np >= 7)\r
+    font_params[f] = np;\r
+  else\r
+    font_params[f] = 7;\r
+\r
+  hyphen_char[f] = default_hyphen_char;\r
+  skew_char[f] = default_skew_char;\r
+\r
+  if (bch_label < nl)\r
+    bchar_label[f] = bch_label + lig_kern_base[f];\r
+  else\r
+    bchar_label[f] = non_address;\r
+\r
+  font_bchar[f] = bchar;\r
+  font_false_bchar[f] = bchar;\r
+\r
+  if (bchar <= ec)\r
+    if (bchar >= bc)\r
+    {\r
+      qw = char_info(f, bchar);\r
+\r
+      if (char_exists(qw))\r
+        font_false_bchar[f] = 256;\r
+    }\r
+\r
+  font_name[f] = nom;\r
+  font_area[f] = aire;\r
+  font_bc[f] = bc;\r
+  font_ec[f] = ec;\r
+  font_glue[f] = 0;\r
+  adjust(char_base);\r
+  adjust(width_base);\r
+  adjust(lig_kern_base);\r
+  adjust(kern_base);\r
+  adjust(exten_base);\r
+  decr(param_base[f]);\r
+  fmem_ptr = fmem_ptr + lf;\r
+  font_ptr = f;\r
+  g = f;\r
+  goto done;\r
+\r
+bad_tfm:\r
+  start_font_error_message();\r
+\r
+  if (file_opened)\r
+    prints(" not loadable: Bad metric (TFM) file");\r
+  else\r
+    prints(" not loadable: Metric (TFM) file not found");\r
+\r
+  help5("I wasn't able to read the size data for this font,",\r
+      "so I will ignore the font specification.",\r
+      "[Wizards can fix TFM files using TFtoPL/PLtoTF.]",\r
+      "You might try inserting a different font spec;",\r
+      "e.g., type `I\\font<same font id>=<substitute font name>'.");\r
+  error();\r
+\r
+done:\r
+  if (file_opened)\r
+    b_close(tfm_file);\r
+\r
+  return g;\r
 }
\ No newline at end of file