#include "externs.h"

void F156_expand ()
/***********/
{
#ifdef M_XENIX
  T37_memoryword huge *memptr;
#else
  register T37_memoryword *memptr;
#endif
  register int /* was T32_halfword */ p;
  register int   j;
  register int /* was T32_halfword */ backupbackup;
  register long int   cvbackup;
  register T29_smallnumber cvlbackup;
  register int /* was T32_halfword */ q;
  register int /* was T32_halfword */ r;
  register T29_smallnumber radixbackup;
  register T29_smallnumber savescannerstatus;
  register int /* was T32_halfword */ t;
  register T37_memoryword memhelp;

  cvbackup = curval;
  cvlbackup = curvallevel;
  radixbackup = radix;
  backupbackup = m29987->_TAG._TAG3.hh.rh;
  if (curcmd < 110)
  {
    if (eqtb[5303]._TAG._TAG1._int > 1L)
      F139_showcurcmdchr ();
    switch (curcmd)
    {
      case 109: 
	if (curmark[curchr] != -32768)
	  F140_begintokenlist (curmark[curchr], (char)14);
	break;
      case 101: 
	F29_gettoken (null);
	t = curtok;
	F29_gettoken (null);
	if (curcmd > 99)
	  F156_expand ();
	else
	  F134_backinput ();
	curtok = t;
	F134_backinput ();
	break;
      case 102: 
	savescannerstatus = scannerstatus;
	scannerstatus = 0;
	F29_gettoken (null);
	scannerstatus = savescannerstatus;
	t = curtok;
	F134_backinput ();
	if (t >= 4096)
	{
	  p = F75_getavail ();
	  memhelp._TAG._TAG3.hh._TAG._TAG1.lh = 7363;
	  memhelp._TAG._TAG3.hh.rh = curinput.locfield;
	  mem[p - C2_memmin] = memhelp;
	  curinput.startfield = p;
	  curinput.locfield = p;
	}
	break;
      case 106: 
	r = F75_getavail ();
	p = r;
	do
	{
	  F153_getxtoken (null);
	  if (curcs == 0)
	  {
	    q = F75_getavail ();
	    mem[p - C2_memmin]._TAG._TAG3.hh.rh = q;
	    mem[q - C2_memmin]._TAG._TAG3.hh._TAG._TAG1.lh = curtok;
	    p = q;
	  }
	}
	while (curcs == 0);
	if (curcmd != 66)
	{
	  F19_printnl (134);
	  F17_print (483);
	  F20_printesc (365);
	  F17_print (484);
	  helpptr = 2;
	  helpline[1] = 485;
	  helpline[0] = 486;
	  F142_backerror ();
	}
	j = first;
	p = mem[r - C2_memmin]._TAG._TAG3.hh.rh;
	while (p != -32768)
	{
	  if (j >= maxbufstack)
	  {
	    maxbufstack = j + 1;
	    if (maxbufstack == C3_bufsize)
	      F41_overflow (128, (long)C3_bufsize);
	  }
	  memhelp = mem[p - C2_memmin];
	  buffer[j++] = memhelp._TAG._TAG3.hh._TAG._TAG1.lh & 255;
	  p = memhelp._TAG._TAG3.hh.rh;
	}
	if (j > (first + 1))
	{
	  nonewcontrolsequence = FALSE;
	  curcs = F123_idlookup (first, j - first);
	  nonewcontrolsequence = TRUE;
	}
	else
	  if (j == first)
	    curcs = 257;
	  else
	    curcs = 129 + buffer[first];
	F76_flushlist (r);
	if (eqtb[curcs]._TAG._TAG3.hh._TAG._TAG2.b0 == 100)
	  eqtb[curcs]=eqtb[3265];
	curtok = curcs + 4096;
	F134_backinput ();
	break;
      case 107: 
	F154_convtoks ();
	break;
      case 108: 
	F155_insthetoks ();
	break;
      case 104: 
	F152_conditional ();
	break;
      case 105: 
	if (curchr > iflimit)
	  if (iflimit == 1)
	  {
	    curtok = 4096 + curcs;
	    F134_backinput ();
	    curtok = 7361;
	    F134_backinput ();
	    curinput.indexfield = 4;
	  }
	  else
	  {
	    F19_printnl (134);
	    F17_print (633);
	    F121_printcmdchr ((char)105, curchr);
	    helpptr = 1;
	    helpline[0] = 634;
	    F39_error ();
	  }
	else
	{
	  while (curchr != 2)
	    F150_passtext ();
	  p = condptr;
	  memptr = &mem[p - C2_memmin];
	  curif = memptr->_TAG._TAG3.hh._TAG._TAG2.b1;
	  iflimit = memptr->_TAG._TAG3.hh._TAG._TAG2.b0;
	  condptr = memptr->_TAG._TAG3.hh.rh;
	  ifline = (memptr+1)->_TAG._TAG1._int;
	  F78_freenode (p, 2);
	}
	break;
      case 103: 
	if (curchr > 0)
	  forceeof = TRUE;
	else
	  if (nameinprogress)
	  {
	    curtok = 4096 + curcs;
	    F134_backinput ();
	    curtok = 7361;
	    F134_backinput ();
	    curinput.indexfield = 4;
	  }
	  else
	    F151_startinput ();
	break;
      default: 
	F19_printnl (134);
	F17_print (477);
	helpptr = 5;
	helpline[4] = 478;
	helpline[3] = 479;
	helpline[2] = 480;
	helpline[1] = 481;
	helpline[0] = 482;
	F39_error ();
	break;
    }
  }
  else
    if (curcmd < 114)
      F148_macrocall ();
    else
    {
      curtok = 7360;
      F134_backinput ();
    }
  curval = cvbackup;
  curvallevel = cvlbackup;
  radix = radixbackup;
  m29987->_TAG._TAG3.hh.rh = backupbackup;
}

void F158_scanleftbrace ()
/******************/
{
  do
    F153_getxtoken (null)
  while ((curcmd == 10) || (curcmd == 0));
  if (curcmd != 1)
  {
    F19_printnl (134);
    F17_print (515);
    helpptr = 4;
    helpline[3] = 516;
    helpline[2] = 517;
    helpline[1] = 518;
    helpline[0] = 519;
    F142_backerror ();
    curtok = 379;
    curcmd = 1;
    curchr = 123;
    alignstate++;
  }
}

void F159_scanoptionalequals ()
/***********************/
{
  do
    F153_getxtoken (null)
  while (curcmd == 10);
  if (curtok != 3133)
    F134_backinput ();
}

BOOLEAN F160_scankeyword (s)
/*************************/
T26_strnumber s;
{
#ifdef VAX
register int k;
#else
  register T25_poolpointer k;
#endif
  register int /* was T32_halfword */ p;
  register int /* was T32_halfword */ q;

#ifdef TRIPTEX
  p = 2987;
#else
  p = 29987;
#endif
  mem[p - C2_memmin]._TAG._TAG3.hh.rh = (int)(-32768);
  k = strstart[s];
  while (k < strstart[s + 1])
  {
    F153_getxtoken (null);
    if ((curcs == 0) && ((curchr == strpool[k]) || (curchr == (strpool[k] - 32))))
    {
      q = F75_getavail ();
      mem[p - C2_memmin]._TAG._TAG3.hh.rh = q;
      mem[q - C2_memmin]._TAG._TAG3.hh._TAG._TAG1.lh = curtok;
      p = q;
      k++;
    }
    else
#ifdef TRIPTEX
      if ((curcmd != 10) || (p != 2987))
      {
	F134_backinput ();
	if (p != 2987)
#else
      if ((curcmd != 10) || (p != 29987))
      {
	F134_backinput ();
	if (p != 29987)
#endif
	  F140_begintokenlist (m29987->_TAG._TAG3.hh.rh, (char)3);
	return(FALSE);
      }
  }
  F76_flushlist (m29987->_TAG._TAG3.hh.rh);
  return(TRUE);
}

void F161_muerror ()
/************/
{
  F19_printnl (134);
  F17_print (520);
  helpptr = 1;
  helpline[0] = 521;
  F39_error ();
}

void F163_scansevenbitint ()
/********************/
{
  F162_scanint ();
  if (curval & 0xFFFFFF80)
  {
    F19_printnl (134);
    F17_print (543);
    helpptr = 2;
    helpline[1] = 544;
    helpline[0] = 545;
    F63_interror (curval);
    curval = 0;
  }
}

void F164_scaneightbitint ()
/********************/
{
  F162_scanint ();
  if (curval & 0xFFFFFF00)
  {
    F19_printnl (134);
    F17_print (546);
    helpptr = 2;
    helpline[1] = 547;
    helpline[0] = 545;
    F63_interror (curval);
    curval = 0;
  }
}

void F165_scanfourbitint ()
/*******************/
{
  F162_scanint ();
  if (curval & 0xFFFFFFF0)
  {
    F19_printnl (134);
    F17_print (548);
    helpptr = 2;
    helpline[1] = 549;
    helpline[0] = 545;
    F63_interror (curval);
    curval = 0;
  }
}

void F166_scancharnum ()
/****************/
{
  F162_scanint ();
  if (curval & 0xFFFFFF00)
  {
    F19_printnl (134);
    F17_print (543);
    helpptr = 2;
    helpline[1] = 550;
    helpline[0] = 545;
    F63_interror (curval);
    curval = 0;
  }
}

void F167_scanfifteenbitint ()
/**********************/
{
  F162_scanint ();
  if (curval & 0xFFFF8000)
  {
    F19_printnl (134);
    F17_print (551);
    helpptr = 2;
    helpline[1] = 552;
    helpline[0] = 545;
    F63_interror (curval);
    curval = 0;
  }
}

void F168_scantwentysevenbitin ()
/*************************/
{
  F162_scanint ();
  if (curval & 0xF8000000)
  {
    F19_printnl (134);
    F17_print (553);
    helpptr = 2;
    helpline[1] = 554;
    helpline[0] = 545;
    F63_interror (curval);
    curval = 0;
  }
}

void F169_scanfontident ()
/******************/
{
#ifdef VAX
register int f;
#else
  register T43_internalfontnumber f;
#endif
  register int /* was T32_halfword */ m;

  do
    F153_getxtoken (null)
  while (curcmd == 10);
  if (curcmd == 87)
    f = eqtb[4578]._TAG._TAG3.hh.rh;
  else
    if (curcmd == 86)
      f = curchr;
    else
      if (curcmd == 85)
      {
	m = curchr;
	F165_scanfourbitint ();
	f = eqtb[m + curval]._TAG._TAG3.hh.rh;
      }
      else
      {
	F19_printnl (134);
	F17_print (670);
	helpptr = 2;
	helpline[1] = 671;
	helpline[0] = 672;
	F142_backerror ();
	f = 0;
      }
  curval = f;
}

void F170_findfontdimen (writing)
/*************************/
BOOLEAN writing;
{
#ifdef VAX
register int f;
#else
  register T43_internalfontnumber f;
#endif
  register long int   n;

  F162_scanint ();
  n = curval;
  F169_scanfontident ();
  f = curval;
  if (n <= 0)
    curval = fmemptr;
  else
  {
    if (writing && (n <= 4L) && (n >= 2L) && (fontglue[f] != ((int)(-32768))))
    {
      F108_deleteglueref (fontglue[f]);
      fontglue[f] = (int)(-32768);
    }
    if (n > fontparams[f])
      if (f < fontptr)
	curval = fmemptr;
      else
      {
	do
	{
	  if (fmemptr == C10_fontmemsize)
	    F41_overflow (677, (long)C10_fontmemsize);
	  fontinfo[fmemptr++]._TAG._TAG1._int = 0;
	  fontparams[f]++;
	}
	while (n != fontparams[f]);
	curval = fmemptr - 1;
      }
    else
      curval = n + parambase[f];
  }
  if (curval == fmemptr)
  {
    F19_printnl (134);
    F17_print (655);
    F20_printesc (hash[3010 + f].rh);
    F17_print (673);
    F22_printint ((long)fontparams[f]);
    F17_print (674);
    helpptr = 2;
    helpline[1] = 675;
    helpline[0] = 676;
    F39_error ();
  }
}

void F171_scansomethinginterna (level, negative)
/***************************************/
#ifdef VAX
register int level;
#else
register T29_smallnumber level;
#endif
BOOLEAN negative;
{
  register int shelp;
#ifdef M_XENIX
  T37_memoryword huge *memptr;
#else
  register T37_memoryword *memptr;
#endif
  register int /* was T32_halfword */ m;
  register int   p;

  m = curchr;
  switch (curcmd)
  {
    case 84: 
      F163_scansevenbitint ();
      if (m == 5139)
      {
	curval = eqtb[5139 + curval]._TAG._TAG3.hh.rh + 32768L;
	curvallevel = 0;
      }
      else
	if (m < 5139)
	{
	  curval = eqtb[m + curval]._TAG._TAG3.hh.rh;
	  curvallevel = 0;
	}
	else
	{
	  curval = eqtb[m + curval]._TAG._TAG1._int;
	  curvallevel = 0;
	}
      break;
    case 70: 
    case 71: 
    case 85: 
    case 86: 
    case 87: 
      if (level != 5)
      {
	F19_printnl (134);
	F17_print (522);
	helpptr = 3;
	helpline[2] = 523;
	helpline[1] = 524;
	helpline[0] = 525;
	F142_backerror ();
	curval = 0;
	curvallevel = 1;
      }
      else
	if (curcmd <= 71)
	{
	  if (curcmd < 71)
	  {
	    F164_scaneightbitint ();
	    m = 4066 + curval;
	  }
	  curval = eqtb[m]._TAG._TAG3.hh.rh;
	  curvallevel = 5;
	}
	else
	{
	  F134_backinput ();
	  F169_scanfontident ();
	  curval += 3268;
	  curvallevel = 4;
	}
      break;
    case 72: 
      curval = eqtb[m]._TAG._TAG1._int;
      curvallevel = 0;
      break;
    case 73: 
      curval = eqtb[m]._TAG._TAG1._int;
      curvallevel = 1;
      break;
    case 74: 
      curval = eqtb[m]._TAG._TAG3.hh.rh;
      curvallevel = 2;
      break;
    case 75: 
      curval = eqtb[m]._TAG._TAG3.hh.rh;
      curvallevel = 3;
      break;
    case 78: 
      if ((curlist.modefield != m)&&(curlist.modefield != -m))
      {
	F19_printnl (134);
	F17_print (536);
	F121_printcmdchr ((char)78, m);
	helpptr = 4;
	helpline[3] = 537;
	helpline[2] = 538;
	helpline[1] = 539;
	helpline[0] = 540;
	F39_error ();
	curval = 0;
	if (level != 5)
	  curvallevel = 1;
	else
	  curvallevel = 0;
      }
      else
      {
	curval = curlist.auxfield;
	if (m == 1)
	  curvallevel = 1;
	else
	  curvallevel = 0;
      }
      break;
    case 79:
      nest[nestptr]=curlist;
      p = nestptr;
      {
	register int shelp;
	while (((shelp = nest[p].modefield) != 1)&&(shelp != -1))
	  p--;
      }
      curval = nest[p].pgfield;
      curvallevel = 0;
      break;
    case 81: 
      if (m == 0)
	curval = deadcycles;
      else
	curval = insertpenalties;
      curvallevel = 0;
      break;
    case 80: 
      if (pagecontents == 0)
	if (m == 0)
	  curval = 1073741823;
	else
	  curval = 0;
      else
	curval = pagesofar[m];
      curvallevel = 1;
      break;
    case 83: 
      if (eqtb[4056]._TAG._TAG3.hh.rh == ((int)(-32768)))
	curval = 0;
      else
	curval = mem[eqtb[4056]._TAG._TAG3.hh.rh - C2_memmin]._TAG._TAG3.hh._TAG._TAG1.lh;
      curvallevel = 0;
      break;
    case 82: 
      F164_scaneightbitint ();
      {
	register int shelp;
	if ((shelp = eqtb[4322 + curval]._TAG._TAG3.hh.rh) == ((int)(-32768)))
	  curval = 0;
	else
	  curval = mem[shelp + m - C2_memmin]._TAG._TAG1._int;
      }
      curvallevel = 1;
      break;
    case 67: 
    case 68: 
      curval = curchr;
      curvallevel = 0;
      break;
    case 76: 
      F170_findfontdimen (FALSE);
      fontinfo[fmemptr]._TAG._TAG1._int = 0;
      curval = fontinfo[curval]._TAG._TAG1._int;
      curvallevel = 1;
      break;
    case 77: 
      F169_scanfontident ();
      if (m == 0)
	curval = hyphenchar[curval];
      else
	curval = skewchar[curval];
      curvallevel = 0;
      break;
    case 88: 
      F164_scaneightbitint ();
      switch (m)
      {
	case 0: 
	  curval = eqtb[5317 + curval]._TAG._TAG1._int;
	  break;
	case 1: 
	  curval = eqtb[5721 + curval]._TAG._TAG1._int;
	  break;
	case 2: 
	  curval = eqtb[3544 + curval]._TAG._TAG3.hh.rh;
	  break;
	case 3: 
	  curval = eqtb[3800 + curval]._TAG._TAG3.hh.rh;
	  break;
      }
      curvallevel = m;
      break;
    case 69: 
      if (curchr == 2)
#ifdef TRIPTEX
	curval = 1;
#else
	curval = -30000;
#endif
      else
	curval = 0;
      curvallevel = curchr;
      if ((curlist.tailfield < himemmin) && (curlist.modefield != 0))
	switch (curchr)
	{
	  case 0: 
	    if (mem[curlist.tailfield - C2_memmin]._TAG._TAG3.hh._TAG._TAG2.b0 == 12)
	      curval = mem[curlist.tailfield + 1 - C2_memmin]._TAG._TAG1._int;
	    break;
	  case 1: 
	    if (mem[curlist.tailfield - C2_memmin]._TAG._TAG3.hh._TAG._TAG2.b0 == 11)
	      curval = mem[curlist.tailfield + 1 - C2_memmin]._TAG._TAG1._int;
	    break;
	  case 2: 
	    if (mem[curlist.tailfield - C2_memmin]._TAG._TAG3.hh._TAG._TAG2.b0 == 10)
	    {
	      curval = mem[curlist.tailfield + 1 - C2_memmin]._TAG._TAG3.hh._TAG._TAG1.lh;
	      if (mem[curlist.tailfield - C2_memmin]._TAG._TAG3.hh._TAG._TAG2.b1 == 99)
		curvallevel = 3;
	    }
	    break;
	}
      else
	if ((curlist.modefield == 1) && (curlist.tailfield == curlist.headfield))
	  switch (curchr)
	  {
	    case 0: 
	      curval = lastpenalty;
	      break;
	    case 1: 
	      curval = lastkern;
	      break;
	    case 2: 
	      if (lastglue != 32767)
		curval = lastglue;
	      break;
	  }
      break;
    default: 
      F19_printnl (134);
      F17_print (541);
      F121_printcmdchr (curcmd, curchr);
      F17_print (542);
      F20_printesc (396);
      helpptr = 1;
      helpline[0] = 540;
      F39_error ();
      curval = 0;
      if (level != 5)
	curvallevel = 1;
      else
	curvallevel = 0;
      break;
  }
  while (curvallevel > level)
  {
    if (curvallevel == 2)
      curval = mem[curval + 1 - C2_memmin]._TAG._TAG1._int;
    else
      if (curvallevel == 3)
	F161_muerror ();
    curvallevel--;
  }
  if (negative)
    if (curvallevel >= 2)
    {
      curval = F85_newspec ((int)curval);
      memptr = &mem[curval + 1 - C2_memmin];
      memptr->_TAG._TAG1._int = -(memptr->_TAG._TAG1._int);
      (memptr+1)->_TAG._TAG1._int = -((memptr+1)->_TAG._TAG1._int);
      (memptr+2)->_TAG._TAG1._int = -((memptr+2)->_TAG._TAG1._int);
    }
    else
      curval = -curval;
  else
    if ((curvallevel >= 2) && (curvallevel <= 3))
      mem[curval - C2_memmin]._TAG._TAG3.hh.rh++;
}

void F162_scanint ()
/************/
{
#ifdef VAX
register int d;
#else
  register T29_smallnumber d;
#endif
  register long int   m;
  register BOOLEAN negative;
  register BOOLEAN oksofar;
  register BOOLEAN vacuous;

  radix = 0;
  oksofar = TRUE;
  negative = FALSE;
  do
  {
    do
      F153_getxtoken (null)
    while (curcmd == 10);
    if (curtok == 3117)
    {
      negative = !negative;
      curtok = 3115;
    }
  }
  while (curtok == 3115);
  if (curtok == 3168)
  {
    F29_gettoken (null);
    if (curtok < 4096)
    {
      curval = curchr;
      if (curcmd <= 2)
	if (curcmd == 2)
	  alignstate++;
	else
	  alignstate--;
    }
    else
      if (curtok < 4225)
	curval = curtok - 4097;
      else
	curval = curtok - 4225;
    if (curval > 127L)
    {
      F19_printnl (134);
      F17_print (555);
      helpptr = 2;
      helpline[1] = 556;
      helpline[0] = 557;
      curval = 48;
      F142_backerror ();
    }
    else
    {
      F153_twogetxtoken (null);
      if (curcmd != 10)
	F134_backinput ();
    }
  }
  else
    if ((curcmd >= 67) && (curcmd <= 88))
      F171_scansomethinginterna (0, FALSE);
    else
    {
      radix = 10;
      m = 214748364;
      if (curtok == 3111)
      {
	radix = 8;
	m = 268435456;
	F153_threegetxtoken (null);
      }
      else
	if (curtok == 3106)
	{
	  radix = 16;
	  m = 134217728;
	  F153_fourgetxtoken (null);
	}
      vacuous = TRUE;
      curval = 0;
      while (TRUE)
      {
	if (((curtok < (3120 + radix)) && (curtok >= 3120)) && (curtok <= 3129))
	  d = curtok - 3120;
	else
	  if (radix == 16)
	    if ((curtok <= 2886) && (curtok >= 2881))
	      d = curtok - 2871;
	    else
	      if ((curtok <= 3142) && (curtok >= 3137))
		d = curtok - 3127;
	      else
		goto _30;
	  else
	    goto _30;
	vacuous = FALSE;
	if ((curval >= m) && ((curval > m) || (d > 7) || (radix != 10)))
	{
	  if (oksofar)
	  {
	    F19_printnl (134);
	    F17_print (558);
	    helpptr = 2;
	    helpline[1] = 559;
	    helpline[0] = 560;
	    F39_error ();
	    curval = 2147483647;
	    oksofar = FALSE;
	  }
	}
	else
	  curval = (curval * radix) + d;
	F153_fivegetxtoken (null);
      }
  _30: 
      if (vacuous)
      {
	F19_printnl (134);
	F17_print (522);
	helpptr = 3;
	helpline[2] = 523;
	helpline[1] = 524;
	helpline[0] = 525;
	F142_backerror ();
      }
      else
	if (curcmd != 10)
	  F134_backinput ();
    }
  if (negative)
    curval = -curval;
}

void F172_scandimen (mu, inf, shortcut)
/*****************************/
#ifdef VAX
register int mu;
#else
register BOOLEAN mu;
#endif
BOOLEAN inf;
BOOLEAN shortcut;
{
  register long int   f;
  register int   denom;
#ifdef VAX
register int k;
#else
  register T29_smallnumber k;
#endif
#ifdef VAX
register int negative;
#else
  register BOOLEAN negative;
#endif
  register int   num;
  register long int   savecurval;
  register long int   v;

  f = 0;
  aritherror = FALSE;
  curorder = 0;
  negative = FALSE;
  if (!shortcut)
  {
    do
    {
      do
	F153_getxtoken (null)
      while (curcmd == 10);
      if (curtok == 3117)
      {
	negative = !negative;
	curtok = 3115;
      }
    }
    while (curtok == 3115);
    if ((curcmd >= 67) && (curcmd <= 88))
      if (mu)
      {
	F171_scansomethinginterna (3, FALSE);
	if (curvallevel >= 2)
	{
	  v = mem[curval + 1 - C2_memmin]._TAG._TAG1._int;
	  F108_deleteglueref ((int)curval);
	  curval = v;
	}
	if (curvallevel == 3)
	  goto _89;
	if (curvallevel != 0)
	  F161_muerror ();
      }
      else
      {
	F171_scansomethinginterna (1, FALSE);
	if (curvallevel == 1)
	  goto _89;
      }
    else
    {
      F134_backinput ();
      if (curtok == 3116)
	curtok = 3118;
      if (curtok != 3118)
	F162_scanint ();
      else
      {
	radix = 10;
	curval = 0;
      }
      if (curtok == 3116)
	curtok = 3118;
      if ((radix == 10) && (curtok == 3118))
      {
	k = 0;
	F29_gettoken (null);
	while (TRUE)
	{
	  F153_twogetxtoken (null);
	  if ((curtok > 3129) || (curtok < 3120))
	    goto _31;
	  if (k < 17)
	    dig[k++] = curtok - 3120;
	}
    _31: 
	f = F66_rounddecimals (k);
	if (curcmd != 10)
	  F134_backinput ();
      }
    }
  }
  if (curval < 0L)
  {
    negative = !negative;
    curval = -curval;
  }
  if (inf)
    if (F160_scankeyword (181))
    {
      curorder = 1;
      while (F160_scankeyword (108))
      {
	if (curorder == 3)
	{
	  F19_printnl (134);
	  F17_print (562);
	  F17_print (563);
	  helpptr = 1;
	  helpline[0] = 564;
	  F39_error ();
	}
	else
	  curorder++;
      }
      goto _88;
    }
  savecurval = curval;
  do
    F153_threegetxtoken (null)
  while (curcmd == 10);
  if ((curcmd < 67) || (curcmd > 88))
    F134_backinput ();
  else
  {
    if (mu)
    {
      F171_scansomethinginterna (3, FALSE);
      if (curvallevel >= 2)
      {
	v = mem[curval + 1 - C2_memmin]._TAG._TAG1._int;
	F108_deleteglueref ((int)curval);
	curval = v;
      }
      if (curvallevel != 3)
	F161_muerror ();
    }
    else
      F171_scansomethinginterna (1, FALSE);
    v = curval;
    goto _40;
  }
  if (mu)
    goto _45;
  if (F160_scankeyword (565))
    v = fontinfo[6 + parambase[eqtb[4578]._TAG._TAG3.hh.rh]]._TAG._TAG1._int;
  else
    if (F160_scankeyword (566))
      v = fontinfo[5 + parambase[eqtb[4578]._TAG._TAG3.hh.rh]]._TAG._TAG1._int;
    else
      goto _45;
  F153_fourgetxtoken (null);
  if (curcmd != 10)
    F134_backinput ();
_40: 
  curval = F68_nxplusy (savecurval, v, F70_xnoverd (v, f, 65536L));
  goto _89;
_45: 
  if (mu)
    if (F160_scankeyword (206))
      goto _88;
    else
    {
      F19_printnl (134);
      F17_print (562);
      F17_print (567);
      helpptr = 4;
      helpline[3] = 568;
      helpline[2] = 569;
      helpline[1] = 570;
      helpline[0] = 571;
      F39_error ();
      goto _88;
    }
  if (F160_scankeyword (561))
  {
    F136_preparemag ();
    if (eqtb[5284]._TAG._TAG1._int != 1000)
    {
      curval = F70_xnoverd (curval, 1000L, eqtb[5284]._TAG._TAG1._int);
      f = ((1000L * f) + (remainder << 16)) / eqtb[5284]._TAG._TAG1._int;
      curval += (f >> 16);
      f &= 65535L;
    }
  }
  if (F160_scankeyword (263))
    goto _88;
  if (F160_scankeyword (572))
  {
    num = 7227;
    denom = 100;
  }
  else
    if (F160_scankeyword (573))
    {
      num = 12;
      denom = 1;
    }
    else
      if (F160_scankeyword (574))
      {
	num = 7227;
	denom = 254;
      }
      else
	if (F160_scankeyword (575))
	{
	  num = 7227;
	  denom = 2540;
	}
	else
	  if (F160_scankeyword (576))
	  {
	    num = 7227;
	    denom = 7200;
	  }
	  else
	    if (F160_scankeyword (577))
	    {
	      num = 1238;
	      denom = 1157;
	    }
	    else
	      if (F160_scankeyword (578))
	      {
		num = 14856;
		denom = 1157;
	      }
	      else
		if (F160_scankeyword (579))
		  goto _30;
		else
		{
		  F19_printnl (134);
		  F17_print (562);
		  F17_print (580);
		  helpptr = 6;
		  helpline[5] = 581;
		  helpline[4] = 582;
		  helpline[3] = 583;
		  helpline[2] = 569;
		  helpline[1] = 570;
		  helpline[0] = 571;
		  F39_error ();
		  goto _32;
		}
  curval = F70_xnoverd (curval, (long)num, (long)denom);
  f = (((long)num * f) + (remainder << 16)) / denom;
  curval += (f >> 16);
  f &= 65535L;
_32: ;
_88: 
  if (curval >= 16384L)
    aritherror = TRUE;
  else
    curval = (curval << 16) + f;
_30: 
  F153_fivegetxtoken (null);
  if (curcmd != 10)
    F134_backinput ();
_89: 
  if (aritherror || (curval >= 1073741824) || (curval <= -1073741824))
  {
    F19_printnl (134);
    F17_print (584);
    helpptr = 2;
    helpline[1] = 585;
    helpline[0] = 586;
    F39_error ();
    curval = 1073741823;
    aritherror = FALSE;
  }
  if (negative)
    curval = -curval;
}

void F173_scanglue (level)
/******************/
#ifdef VAX
register int level;
#else
register T29_smallnumber level;
#endif
{
#ifdef M_XENIX
  T37_memoryword huge *memptr;
#else
  register T37_memoryword *memptr;
#endif
#ifdef VAX
register int mu,negative;
#else
  register BOOLEAN mu;
  register BOOLEAN negative;
#endif
  register int /* was T32_halfword */ q;

  mu = (level == 3);
  negative = FALSE;
  do
  {
    do
      F153_getxtoken (null)
    while (curcmd == 10);
    if (curtok == 3117)
    {
      negative = !negative;
      curtok = 3115;
    }
  }
  while (curtok == 3115);
  if ((curcmd >= 67) && (curcmd <= 88))
  {
    F171_scansomethinginterna (level, negative);
    if (curvallevel >= 2)
    {
      if (curvallevel != level)
	F161_muerror ();
      return;
    }
    if (curvallevel == 0)
      F172_scandimen (mu, FALSE, TRUE);
    else
      if (level == 3)
	F161_muerror ();
  }
  else
  {
    F134_backinput ();
    F172_scandimen (mu, FALSE, FALSE);
    if (negative)
      curval = -curval;
  }
#ifdef TRIPTEX
  q = F85_newspec (1);
#else
  q = F85_newspec (-30000);
#endif
  memptr= &mem[q + 1 - C2_memmin];
  memptr->_TAG._TAG1._int = curval;
  if (F160_scankeyword (587))
  {
    F172_scandimen (mu, TRUE, FALSE);
    (memptr+1)->_TAG._TAG1._int = curval;
    (memptr-1)->_TAG._TAG3.hh._TAG._TAG2.b0 = curorder;
  }
  if (F160_scankeyword (588))
  {
    F172_scandimen (mu, TRUE, FALSE);
    (memptr+2)->_TAG._TAG1._int = curval;
    (memptr-1)->_TAG._TAG3.hh._TAG._TAG2.b1 = curorder;
  }
  curval = q;
}

int /* was T32_halfword */ F174_scanrulespec ()
/******************************/
{
  register int /* was T32_halfword */ q;
#ifdef M_XENIX
  T37_memoryword huge *memptr;
#else
  register T37_memoryword *memptr;
#endif

  q = F81_newrule ();
  memptr = &mem[q + 1 - C2_memmin];
  if (curcmd == 35)
    memptr->_TAG._TAG1._int = 26214;
  else
  {
    (memptr+2)->_TAG._TAG1._int = 26214;
    (memptr+1)->_TAG._TAG1._int = 0;
  }
_21: 
  if (F160_scankeyword (589))
  {
    F172_scandimen (FALSE, FALSE, FALSE);
    memptr->_TAG._TAG1._int = curval;
    goto _21;
  }
  if (F160_scankeyword (590))
  {
    F172_scandimen (FALSE, FALSE, FALSE);
    (memptr+2)->_TAG._TAG1._int = curval;
    goto _21;
  }
  if (F160_scankeyword (591))
  {
    F172_scandimen (FALSE, FALSE, FALSE);
    (memptr+1)->_TAG._TAG1._int = curval;
    goto _21;
  }
  return(q);
}

int /* was T32_halfword */ F175_strtoks ()
/*************************/
{
#ifdef M_XENIX
  T37_memoryword huge *memptr;
#else
  register T37_memoryword *memptr;
#endif
#ifdef VAX
register int k;
#else
  register T25_poolpointer k;
#endif
  register int /* was T32_halfword */ p;
  register int /* was T32_halfword */ q;
  register int /* was T32_halfword */ t;

  if (poolptr >= C15_poolsize)
    F41_overflow (129, (long)C15_poolsize - initpoolptr);
#ifdef TRIPTEX
  p = 2997;
#else
  p = 29997;
#endif
  mem[p - C2_memmin]._TAG._TAG3.hh.rh = (int)(-32768);
  k = strstart[strptr];
  while (k < poolptr)
  {
    t = strpool[k];
    if (t == 32)
      t = 2592;
    else
      t += 3072;
    q = avail;
    if (q == ((int)(-32768)))
      q = F75_getavail ();
    else
    {
      memptr = &mem[q - C2_memmin];
      avail = memptr->_TAG._TAG3.hh.rh;
      memptr->_TAG._TAG3.hh.rh = (int)(-32768);
# if defined(INITEX) || defined(TRIPTEX)
      dynused++;
# endif
    }
    mem[p - C2_memmin]._TAG._TAG3.hh.rh = q;
    mem[q - C2_memmin]._TAG._TAG3.hh._TAG._TAG1.lh = t;
    p = q;
    k++;
  }
  poolptr = strstart[strptr];
  return(p);
}

int /* was T32_halfword */ F176_thetoks ()
/*************************/
{
#ifdef M_XENIX
  T37_memoryword huge *memptr;
#else
  register T37_memoryword *memptr;
#endif
  register int /* was T32_halfword */ q;
  register int /* was T32_halfword */ p;
  register int /* was T32_halfword */ r;
  register int   oldsetting;
  register T37_memoryword memhelp;

  F153_getxtoken (null);
  F171_scansomethinginterna (5, FALSE);
  if (curvallevel >= 4)
  {
#ifdef TRIPTEX
    p = 2997;
#else
    p = 29997;
#endif
    mem[p - C2_memmin]._TAG._TAG3.hh.rh = (int)(-32768);
    if (curvallevel == 4)
    {
      q = F75_getavail ();
      mem[p - C2_memmin]._TAG._TAG3.hh.rh = q;
      mem[q - C2_memmin]._TAG._TAG3.hh._TAG._TAG1.lh = 4096 + curval;
      p = q;
    }
    else
      if (curval != ((int)(-32768)))
      {
	r = mem[curval - C2_memmin]._TAG._TAG3.hh.rh;
	while (r != ((int)(-32768)))
	{
	  q = avail;
	  if (q == ((int)(-32768)))
	    q = F75_getavail ();
	  else
	  {
	    memptr = &mem[q - C2_memmin];
	    avail = memptr->_TAG._TAG3.hh.rh;
	    memptr->_TAG._TAG3.hh.rh = (int)(-32768);
# if defined(INITEX) || defined(TRIPTEX)
	    dynused++;
# endif
	  }
	  mem[p - C2_memmin]._TAG._TAG3.hh.rh = q;
	  memhelp = mem[r - C2_memmin];
	  mem[q - C2_memmin]._TAG._TAG3.hh._TAG._TAG1.lh = memhelp._TAG._TAG3.hh._TAG._TAG1.lh;
	  p = q;
	  r = memhelp._TAG._TAG3.hh.rh;
	}
      }
    return(p);
  }
  else
  {
    oldsetting = selector;
    selector = 21;
    switch (curvallevel)
    {
      case 0: 
	F22_printint (curval);
	break;
      case 1: 
	F67_printscaled (curval);
	F17_print (263);
	break;
      case 2: 
	F98_printspec (curval, 263);
	F108_deleteglueref ((int)curval);
	break;
      case 3: 
	F98_printspec (curval, 206);
	F108_deleteglueref ((int)curval);
	break;
    }
    selector = oldsetting;
    return(F175_strtoks ());
  }
}

void F155_insthetoks ()
/***************/
{
  m29988->_TAG._TAG3.hh.rh = F176_thetoks ();
  F140_begintokenlist (m29997->_TAG._TAG3.hh.rh, (char)4);
}

void F154_convtoks ()
/*************/
{
  register int   c;
  register int   oldsetting;
#ifdef VAX
register int savescannerstatus;
#else
  register T29_smallnumber savescannerstatus;
#endif

  c = curchr;
  switch (c)
  {
    case 0: 
    case 1: 
      F162_scanint ();
      break;
    case 2: 
    case 3: 
      savescannerstatus = scannerstatus;
      scannerstatus = 0;
      F29_gettoken (null);
      scannerstatus = savescannerstatus;
      break;
    case 4: 
      F169_scanfontident ();
      break;
    case 5: 
      if (jobname == 0)
	F33_openlogfile ();
      break;
  }
  oldsetting = selector;
  selector = 21;
  switch (c)
  {
    case 0: 
      F22_printint (curval);
      break;
    case 1: 
      F61_printromanint (curval);
      break;
    case 2: 
      if (curcs != 0)
	F24_sprintcs (curcs);
      else
	F16_printchar ((char)curchr);
      break;
    case 3: 
      F138_printmeaning ();
      break;
    case 4: 
      F17_print (fontname[curval]);
      if (fontsize[curval] != fontdsize[curval])
      {
	F17_print (598);
	F67_printscaled (fontsize[curval]);
	F17_print (263);
      }
      break;
    case 5: 
      F17_print (jobname);
      break;
  }
  selector = oldsetting;
  m29988->_TAG._TAG3.hh.rh = F175_strtoks ();
  F140_begintokenlist (m29997->_TAG._TAG3.hh.rh, (char)4);
}
