home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / texmf / source / TeX / tex / tex8.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-12  |  21.9 KB  |  958 lines

  1. #define EXTERN extern
  2. #include "texd.h"
  3.  
  4. void newwhatsit ( smallnumber s, smallnumber w )
  5. {  register long_halfword p;
  6.  
  7.   p = getnode ( w );
  8.   { newwhatsit_regmem
  9.  
  10.     /* ztype ( p ) = whatsitnode; subtype ( p ) = s ; */
  11.     set_type_subtype(p, whatsitnode, s);
  12.     link ( curlist.tailfield ) = p;
  13.     curlist.tailfield = p;
  14.   }
  15. }
  16.  
  17. void newwritewhatsit ( smallnumber w )
  18. { newwritewhatsit_regmem
  19.  
  20.   newwhatsit ( curchr , w );
  21.  {register integer r_curval;
  22.  
  23.   if ( w != writenodesize ) 
  24.     r_curval = scanfourbitint ();
  25.   else {
  26.     r_curval = scanint ();
  27.     if ( r_curval < 0 )
  28.       r_curval = 17;
  29.     else if ( r_curval > 15 )
  30.       r_curval = 16;
  31.   }
  32.   writestream ( curlist .tailfield ) = r_curval;
  33.  }
  34. }
  35.  
  36.  
  37. void doextension ( void )
  38. { doextension_regmem 
  39.   register halfword p;
  40.  
  41.   switch ( curchr ) {
  42.   case opennode : 
  43.     {
  44.       newwritewhatsit ( opennodesize ) ; 
  45.       scanoptionalequals () ; 
  46.       scanfilename () ; 
  47.       openname ( curlist .tailfield ) = curname ; 
  48.       openarea ( curlist .tailfield ) = curarea ; 
  49.       openext ( curlist .tailfield ) = curext ; 
  50.     } 
  51.     break ; 
  52.   case writenode : 
  53.     { register integer k;
  54.  
  55.       k = curcs ; 
  56.       newwritewhatsit ( writenodesize ) ; 
  57.       curcs = k ; 
  58.       p = scantoks ( false , false ) ; 
  59.       writetokens ( curlist .tailfield ) = defref ; 
  60.     } 
  61.     break ; 
  62.   case closenode : 
  63.     {
  64.       newwritewhatsit ( writenodesize ) ; 
  65.       writetokens ( curlist .tailfield ) = 0 ; 
  66.     } 
  67.     break ; 
  68.   case specialnode : 
  69.     {
  70.       newwhatsit ( specialnode , writenodesize ) ; 
  71.       writestream ( curlist .tailfield ) = 0 ; 
  72.       p = scantoks ( false , true ) ; 
  73.       writetokens ( curlist .tailfield ) = defref ; 
  74.     } 
  75.     break ; 
  76.   case 4 : 
  77.     {
  78.       getxtoken () ; 
  79.       if ( ( curcmd == 59 ) && ( curchr <= closenode ) ) {
  80.     p = curlist .tailfield ; 
  81.     doextension () ; 
  82.     outwhat ( curlist .tailfield ) ; 
  83.     flushnodelist ( curlist .tailfield ) ; 
  84.     curlist .tailfield = p ; 
  85.     link ( p ) = 0 ; 
  86.       } else
  87.     backinput () ; 
  88.     } 
  89.     break ; 
  90.   case 5 : 
  91.     if ( abs ( curlist .modefield ) != hmode ) 
  92.       reportillegalcase () ; 
  93.     else {
  94.       newwhatsit ( languagenode , smallnodesize ) ; 
  95.       {register integer r_curval;
  96.  
  97.       r_curval = scanint ();
  98.       if ( r_curval <= 0 )
  99.     curlist .auxfield .hh .v.RH = 0 ; 
  100.       else if ( r_curval > 255 ) 
  101.     curlist .auxfield .hh .v.RH = 0 ; 
  102.       else
  103.     curlist .auxfield .hh .v.RH = r_curval;
  104.       }
  105.       whatlang ( curlist .tailfield ) = curlist.auxfield.hh.v.RH;
  106.       whatlhm ( curlist .tailfield ) = normmin ( lefthyphenmin );
  107.       whatrhm ( curlist .tailfield ) = normmin ( righthyphenmin );
  108.     }
  109.     break ; 
  110.   default: 
  111.     confusion("ext1");
  112.     break;
  113.   }
  114. }
  115.  
  116.  
  117. void fixlanguage ( void )
  118. { fixlanguage_regmem 
  119.   register /*ASCIIcode*/ integer l;
  120.  
  121.   l = language;
  122.   if ( l <= 0 || l > 255 )
  123.     l = 0;
  124.  
  125.   if ( (ASCIIcode)l != curlist .auxfield .hh .v.RH ) {
  126.     newwhatsit ( languagenode , smallnodesize ) ; 
  127.     whatlang ( curlist .tailfield ) = l ; 
  128.     curlist .auxfield .hh .v.RH = l ; 
  129.     whatlhm ( curlist .tailfield ) = normmin ( lefthyphenmin ) ; 
  130.     whatrhm ( curlist .tailfield ) = normmin ( righthyphenmin ) ; 
  131.   }
  132. }
  133.  
  134.  
  135. void handlerightbrace ( void )
  136. { handlerightbrace_regmem 
  137.   register halfword p, q  ; 
  138.   register scaled d  ; 
  139.   register integer f  ; 
  140.  
  141.   switch ( curgroup ) {
  142.   case simplegroup : 
  143.     unsave () ; 
  144.     break ; 
  145.   case bottomlevel : 
  146.     {
  147.       print_err("Too many }'s");
  148.       zhelp1( STR_H_YOUVE_CLOSED_MORE );
  149.       error();
  150.     } 
  151.     break ; 
  152.   case semisimplegroup : 
  153.   case mathshiftgroup : 
  154.   case mathleftgroup : 
  155.     extrarightbrace () ; 
  156.     break ; 
  157.   case adjustedhboxgroup : 
  158.     adjusttail = adjusthead ; 
  159.     /* Fall through */
  160.   case hboxgroup : 
  161.     package ( 0 ) ; 
  162.     break ;
  163.   case vboxgroup : 
  164.     {
  165.       endgraf () ; 
  166.       package ( 0 ) ; 
  167.     } 
  168.     break ; 
  169.   case vtopgroup : 
  170.     {
  171.       endgraf () ; 
  172.       package ( 4 ) ; 
  173.     } 
  174.     break ; 
  175.   case insertgroup : 
  176.     {
  177.       endgraf () ; 
  178.       q = splittopskip ; 
  179.       addglueref ( q ) ; 
  180.       d = splitmaxdepth ; 
  181.       f = floatingpenalty ; 
  182.       unsave () ; 
  183.       decr ( saveptr ) ; 
  184.       p = vpackage ( link ( curlist .headfield ) , 0 , 1 , maxdimen ) ; 
  185.       popnest () ; 
  186.       if ( saved ( 0 ) < 255 ) {
  187.     tailappend ( getnode ( insnodesize ) ) ; 
  188.     ztype ( curlist .tailfield ) = insnode ; 
  189.     subtype ( curlist .tailfield ) = saved ( 0 ) ; 
  190.     height ( curlist .tailfield ) = height ( p ) + depth ( p ) ; 
  191.     insptr ( curlist .tailfield ) = listptr ( p ) ; 
  192.     splittopptr ( curlist .tailfield ) = q ; 
  193.     depth ( curlist .tailfield ) = d ; 
  194.     floatcost ( curlist .tailfield ) = f ; 
  195.       } else {
  196.     tailappend ( getnode ( smallnodesize ) ) ; 
  197.     ztype ( curlist .tailfield ) = adjustnode ; 
  198.     subtype ( curlist .tailfield ) = 0 ; 
  199.     adjustptr ( curlist .tailfield ) = listptr ( p ) ; 
  200.     deleteglueref ( q ) ; 
  201.       } 
  202.       freenode ( p , boxnodesize ) ; 
  203.       if ( nestptr == 0 ) 
  204.     buildpage () ; 
  205.     } 
  206.     break ; 
  207.   case outputgroup : 
  208.     {
  209.       if ( curinput .locfield != 0
  210.     || ( tokentype != outputtext && tokentype != backedup ) )
  211.       {
  212.     print_err("Unbalanced output routine");
  213.     zhelp2( STR_H_YOUR_SNEAKY_OUTPUT, STR_H_ICANT_HANDLE_THAT );
  214.     error () ; 
  215.     do {
  216.       gettoken ();
  217.     } while ( ! ( curinput .locfield == 0 ) ) ; 
  218.       }
  219.       endtokenlist () ; 
  220.       endgraf () ; 
  221.       unsave () ; 
  222.       outputactive = false ; 
  223.       insertpenalties = 0 ; 
  224.       if ( box ( 255 ) != 0 ) {
  225.     print_err("Output routine didn't use all of ");
  226.     printesc( STR_BOX );
  227.     printint( 255 );
  228.     zhelp1( STR_H_YOUR_OUTPUT_COMMANDS );
  229.     boxerror( 255 );
  230.       } 
  231.       if ( curlist .tailfield != curlist .headfield ) {
  232.     link ( pagetail ) = link ( curlist .headfield ) ; 
  233.     pagetail = curlist .tailfield ; 
  234.       } 
  235.       if ( link ( pagehead ) != 0 ) {
  236.     if ( link ( contribhead ) == 0 ) 
  237.       nest [ 0 ] .tailfield = pagetail ; 
  238.     link ( pagetail ) = link ( contribhead ) ; 
  239.     link ( contribhead ) = link ( pagehead ) ; 
  240.     link ( pagehead ) = 0 ; 
  241.     pagetail = pagehead ; 
  242.       }
  243.       popnest () ; 
  244.       buildpage () ; 
  245.     } 
  246.     break ; 
  247.   case discgroup : 
  248.     builddiscretionary () ; 
  249.     break ; 
  250.   case aligngroup : 
  251.     {
  252.       backinput () ; 
  253.       curtok = cstokenflag + frozencr ; 
  254.       print_err("Missing ");
  255.       printesc( STR_CR );
  256.       c_print(" inserted");
  257.       zhelp1( STR_H_IM_GUESSING_ENDALIGN );
  258.       inserror () ; 
  259.     } 
  260.     break ; 
  261.   case noaligngroup : 
  262.     {
  263.       endgraf () ; 
  264.       unsave () ; 
  265.       alignpeek () ; 
  266.     } 
  267.     break ; 
  268.   case vcentergroup : 
  269.     {
  270.       endgraf () ; 
  271.       unsave () ; 
  272.       saveptr = saveptr - 2 ; 
  273.       p = vpackage ( link ( curlist .headfield ) , saved ( 1 ) , saved ( 0 ) , 
  274.             maxdimen ) ; 
  275.       popnest () ; 
  276.       tailappend ( newnoad () ) ; 
  277.       ztype ( curlist .tailfield ) = vcenternoad ; 
  278.       mathtype ( nucleus ( curlist .tailfield ) ) = subbox ; 
  279.       info ( nucleus ( curlist .tailfield ) ) = p ; 
  280.     } 
  281.     break ; 
  282.   case mathchoicegroup : 
  283.     buildchoices () ; 
  284.     break ; 
  285.   case mathgroup : 
  286.     {
  287.       unsave () ; 
  288.       decr ( saveptr ) ; 
  289.       mathtype ( saved ( 0 ) ) = submlist ; 
  290.       p = finmlist ( 0 ) ; 
  291.       info ( saved ( 0 ) ) = p ; 
  292.       if ( p != 0 ) 
  293.       if ( link ( p ) == 0 ) 
  294.       if ( ztype ( p ) == ordnoad ) {
  295.     if ( mathtype ( subscr ( p ) ) == 0 ) 
  296.     if ( mathtype ( supscr ( p ) ) == 0 ) {
  297.       mem [ saved ( 0 ) ] .hh = mem [ nucleus ( p ) ] .hh ; 
  298.       freenode ( p , noadsize ) ; 
  299.     } 
  300.       }
  301.       else if ( ztype ( p ) == accentnoad ) 
  302.       if ( saved ( 0 ) == nucleus ( curlist .tailfield ) ) 
  303.       if ( ztype ( curlist .tailfield ) == ordnoad ) {
  304.     q = curlist .headfield ; 
  305.     while ( link ( q ) != curlist .tailfield ) q = link ( q ) ; 
  306.     link ( q ) = p ; 
  307.     freenode ( curlist .tailfield , noadsize ) ; 
  308.     curlist .tailfield = p ; 
  309.       } 
  310.     } 
  311.     break ; 
  312.   default: 
  313.     confusion("rightbrace");
  314.     break ; 
  315.   } 
  316. }
  317.  
  318.  
  319. void prefixedcommand ( void )
  320. { prefixedcommand_regmem 
  321.   register smallnumber a  ; 
  322.   register internalfontnumber f  ; 
  323.   register halfword j  ; 
  324.   fontindex k  ; 
  325.   register halfword p, q  ; 
  326.   register integer n  ; 
  327.   boolean e  ; 
  328.   register /* eightbits */ long_halfword r_curcmd = curcmd;
  329.  
  330.   a = 0 ;
  331.   while ( (eightbits)r_curcmd == prefix ) {
  332.     if ( ! odd ( a / curchr ) ) 
  333.       a = a + curchr ;
  334.     r_curcmd = getxnbtoken(1);
  335.     if ( (eightbits)r_curcmd <= max_non_prefixed_command ) {
  336.       print_err("You can't use a prefix with `");
  337.       printcmdchr ( r_curcmd , curchr ) ; 
  338.       printchar ( 39 ) ; 
  339.       zhelp1( STR_H_ILLPRETENDGLOBAL );
  340.       backerror () ; 
  341.       return ; 
  342.     }
  343.   }
  344.  
  345.   if ( (eightbits)r_curcmd != def && (a % 4) != 0 ) {
  346.     p_print_err( STR_H_YOUCANTUSE );
  347.     printesc ( STR_LONG );
  348.     c_print("' or `");
  349.     printesc ( STR_OUTER );
  350.     c_print("' with `");
  351.     printcmdchr( r_curcmd, curchr ); 
  352.     printchar( 39 );
  353.     zhelp1( STR_H_ILLPRETENDLONG );
  354.     error();
  355.  
  356.     r_curcmd = curcmd;
  357.   }
  358.  
  359.   if ( globaldefs != 0 ) 
  360.   if ( globaldefs < 0 ) {
  361.     if ( ( a >= 4 ) ) 
  362.     a = a - 4 ; 
  363.   } else {
  364.     if ( ! ( a >= 4 ) ) 
  365.     a = a + 4 ; 
  366.   }
  367.  
  368.   switch ( r_curcmd ) {
  369.   case set_font :
  370.     if ( ( a >= 4 ) ) 
  371.     geqdefine ( curfontloc , data , curchr ) ; 
  372.     else
  373.     eqdefine ( curfontloc , data , curchr ) ; 
  374.     break; 
  375.  
  376. #ifdef MLTEX
  377.   case char_sub_def:
  378.     {   integer chs_accent, chs_char, chs_replace;
  379.     MEDmemoryword chs_value;
  380.  
  381.     if( !is_ML_TeX ) {
  382.       fprintf(stderr, "\nInternal error: \\charsubdef in normal TeX!\n");
  383.       exit(1);
  384.     }
  385.     chs_replace = scancharnum();
  386.     scanoptionalequals();
  387.     chs_accent = scancharnum();
  388.     chs_char = scancharnum();
  389.     chs_value.qqqq.b0 = chs_accent;
  390.     chs_value.qqqq.b1 = chs_char;
  391.  
  392.     /* Note: In original ML-TeX the following test is ommitted, instead
  393.        the warning message is printed when using the replacement.
  394.        I think it is better to inform the user where (s)he makes the error.
  395.      */
  396.     if( chs_accent == chs_replace || char_list_exists(chs_accent)
  397.         || chs_char == chs_replace || char_list_exists(chs_char) ) {
  398.       begindiagnostic();
  399.       c_printnl("Character Substitution list rejected: ");
  400.       print(chs_replace); c_print(" = ");
  401.       print(chs_accent); printchar(' ');
  402.       print(chs_char); printchar('!');
  403.       enddiagnostic(false);
  404.     } else {
  405.  
  406.     if( chs_replace > char_sub_def_max ) {
  407.       if( a >= 4 )
  408.         geqworddefine(intbase + char_sub_def_max_code, chs_replace);
  409.       else
  410.         eqworddefine(intbase + char_sub_def_max_code, chs_replace);
  411.     }
  412.     if( a >= 4 )
  413.       geqdefine(char_sub_base + chs_replace,
  414.         char_sub_def, chs_value.hh.v.RH);
  415.     else
  416.       eqdefine(char_sub_base + chs_replace,
  417.         char_sub_def, chs_value.hh.v.RH);
  418.  
  419.     if( tracing_char_sub_def > 0 ) {
  420.       begindiagnostic();
  421.       c_printnl("New char_sub_def: ");
  422.       print(chs_replace); c_print(" = ");
  423.       print(chs_accent); printchar(' ');
  424.       print(chs_char);
  425.       enddiagnostic(false);
  426.     }
  427.  
  428.     }
  429.     }
  430.     break;
  431. #endif
  432.  
  433.   case def :
  434.     {
  435.       if ( odd ( curchr ) && ! ( a >= 4 ) && ( globaldefs >= 0 ) )
  436.     a = a + 4 ; 
  437.       e = ( curchr >= 2 ) ; 
  438.       getrtoken () ; 
  439.       p = curcs ; 
  440.       q = scantoks ( true , e ) ; 
  441.       if ( ( a >= 4 ) ) 
  442.     geqdefine ( p , call + ( a % 4 ) , defref ) ; 
  443.       else
  444.     eqdefine ( p , call + ( a % 4 ) , defref ) ; 
  445.     } 
  446.     break ; 
  447.   case let : 
  448.     {
  449.       n = curchr ; 
  450.       getrtoken () ; 
  451.       p = curcs ; 
  452.       if ( n == normal ) {
  453.     do {
  454.       /* nothing */
  455.     } while ( (eightbits)gettoken() == spacer );
  456.     if ( curtok == othertoken + 61 ) {
  457.       if ( (eightbits)gettoken() == spacer )
  458.         gettoken();
  459.     }
  460.       } else {
  461.     gettoken () ; 
  462.     q = curtok ; 
  463.     gettoken () ; 
  464.     backinput () ; 
  465.     curtok = q ; 
  466.     backinput () ; 
  467.       } 
  468.       if ( curcmd >= call ) 
  469.     addtokenref ( curchr ) ; 
  470.       if ( ( a >= 4 ) ) 
  471.     geqdefine ( p , curcmd , curchr ) ; 
  472.       else
  473.     eqdefine ( p , curcmd , curchr ) ; 
  474.     } 
  475.     break ; 
  476.   case shorthand_def :
  477.     {
  478.       n = curchr ; 
  479.       getrtoken () ; 
  480.       p = curcs ; 
  481.       if ( ( a >= 4 ) ) 
  482.      geqdefine ( p , 0 , 256 ) ; 
  483.       else
  484.     eqdefine ( p , 0 , 256 ) ; 
  485.       scanoptionalequals();
  486.       switch ( n ) {
  487.       case 0 : 
  488.     { register integer r_curval;
  489.       r_curval = scancharnum ();
  490.       if ( ( a >= 4 ) ) 
  491.         geqdefine ( p, chargiven, r_curval );
  492.       else
  493.         eqdefine ( p, chargiven, r_curval );
  494.     }
  495.     break ; 
  496.       case 1 : 
  497.     { register integer r_curval;
  498.       r_curval = scanfifteenbitint ();
  499.       if ( ( a >= 4 ) ) 
  500.         geqdefine ( p, math_given, r_curval ) ; 
  501.       else
  502.         eqdefine ( p, math_given, r_curval ) ; 
  503.     } 
  504.     break ; 
  505.       default: 
  506.     { register integer r_curval;
  507.       r_curval = scaneightbitint ();
  508.       switch ( n ) {
  509.       case 2 : 
  510.         if ( ( a >= 4 ) ) 
  511.           geqdefine ( p, assign_int, countbase + r_curval ) ; 
  512.         else
  513.           eqdefine ( p, assign_int, countbase + r_curval ) ; 
  514.         break ; 
  515.       case 3 : 
  516.         if ( ( a >= 4 ) ) 
  517.           geqdefine ( p, assign_dimen, scaledbase + r_curval ) ; 
  518.         else
  519.           eqdefine ( p, assign_dimen, scaledbase + r_curval ) ; 
  520.         break ; 
  521.       case 4 : 
  522.         if ( ( a >= 4 ) ) 
  523.         geqdefine ( p, assign_glue, skipbase + r_curval ) ; 
  524.         else eqdefine ( p, assign_glue, skipbase + r_curval ) ; 
  525.         break ; 
  526.       case 5 : 
  527.         if ( ( a >= 4 ) ) 
  528.         geqdefine ( p, assign_mu_glue, muskipbase + r_curval ) ; 
  529.         else eqdefine ( p, assign_mu_glue, muskipbase + r_curval ) ; 
  530.         break ; 
  531.       case 6 : 
  532.         if ( ( a >= 4 ) ) 
  533.         geqdefine ( p, assign_toks, toksbase + r_curval ) ; 
  534.         else eqdefine ( p, assign_toks, toksbase + r_curval ) ; 
  535.         break ;
  536.       }
  537.     }
  538.     break;
  539.       }
  540.     }
  541.     break ; 
  542.   case read_to_cs :
  543.     {
  544.       n = scanint ();
  545.       if ( ! scankeyword( STR_TO ) ) {
  546.     print_err("Missing `to' inserted");
  547.     zhelp1( STR_H_YOUSHOULDREAD );
  548.     error();
  549.       } 
  550.       getrtoken();
  551.       p = curcs;
  552.       readtoks( n, p );
  553.       if ( ( a >= 4 ) )
  554.     geqdefine ( p , call , curval );
  555.       else
  556.     eqdefine ( p , call , curval );
  557.     }
  558.     break;
  559.   case toks_register :
  560.   case assign_toks :
  561.     {
  562.       q = curcs ; 
  563.       if ( (eightbits)r_curcmd == toks_register ) {
  564.     p = toksbase + scaneightbitint();
  565.       } else
  566.     p = curchr;
  567.       scanoptionalequals ();
  568.       r_curcmd = getxnbtoken (1);
  569.       if ( (eightbits)r_curcmd != left_brace ) {
  570.     if ( (eightbits)r_curcmd == toks_register ) {
  571.       curchr = toksbase + scaneightbitint();
  572.       curcmd = r_curcmd = assign_toks;
  573.     }
  574.     if ( (eightbits)r_curcmd == assign_toks ) {
  575.       q = equiv ( curchr ) ; 
  576.       if ( q == 0 ) 
  577.       if ( ( a >= 4 ) ) 
  578.       geqdefine ( p , undefinedcs , 0 ) ; 
  579.       else eqdefine ( p , undefinedcs , 0 ) ; 
  580.       else {
  581.         addtokenref ( q ) ; 
  582.         if ( ( a >= 4 ) ) 
  583.         geqdefine ( p , call , q ) ; 
  584.         else eqdefine ( p , call , q ) ; 
  585.       } 
  586.       goto lab30 ; 
  587.     }
  588.       } 
  589.       backinput () ; 
  590.       curcs = q ; 
  591.       q = scantoks ( false , false ) ; 
  592.       if ( link ( defref ) == 0 ) {
  593.     if ( ( a >= 4 ) ) 
  594.     geqdefine ( p , undefinedcs , 0 ) ; 
  595.     else eqdefine ( p , undefinedcs , 0 ) ; 
  596.     freeavail ( defref ) ; 
  597.       } else {
  598.     if ( p == outputroutineloc ) {
  599.       link ( q ) = getavail () ; 
  600.       q = link ( q ) ; 
  601.       info ( q ) = rightbracetoken + 125 ; 
  602.       q = getavail () ; 
  603.       info ( q ) = leftbracetoken + 123 ; 
  604.       link ( q ) = link ( defref ) ; 
  605.       link ( defref ) = q ; 
  606.     } 
  607.     if ( ( a >= 4 ) ) 
  608.     geqdefine ( p , call , defref ) ; 
  609.     else eqdefine ( p , call , defref ) ; 
  610.       } 
  611.     } 
  612.     break ; 
  613.   case assign_int :
  614.     {
  615.       p = curchr ; 
  616.       scanoptionalequals () ; 
  617.       { register integer r_curval;
  618.     r_curval = scanint (); 
  619.     if ( a >= 4 )
  620.       geqworddefine ( p , r_curval );
  621.     else
  622.       eqworddefine ( p , r_curval ); 
  623.       }
  624.     }
  625.     break ; 
  626.   case assign_dimen : 
  627.     {
  628.       p = curchr ; 
  629.       scanoptionalequals ();
  630.       { register integer r_curval;
  631.     r_curval = scandimen ( false , false , false );
  632.     if ( ( a >= 4 ) )
  633.       geqworddefine ( p , r_curval );
  634.     else
  635.       eqworddefine ( p , r_curval );
  636.       }
  637.     }
  638.     break ; 
  639.   case assign_glue : 
  640.   case assign_mu_glue :
  641.     {
  642.       p = curchr ; 
  643.       n = r_curcmd ; 
  644.       scanoptionalequals () ;
  645.       { register integer r_curval;
  646.     if ( (eightbits)n == assign_mu_glue )
  647.       r_curval = scanglue ( muval );
  648.     else
  649.       r_curval = scanglue ( glueval );
  650.     r_curval = trapzeroglue(r_curval);
  651.     if ( a >= 4 )
  652.       geqdefine ( p , glueref , r_curval );
  653.     else
  654.       eqdefine ( p , glueref , r_curval );
  655.       }
  656.     }
  657.     break ; 
  658.   case def_code :
  659.     {
  660.       if ( curchr == catcodebase )
  661.       n = 15 ;
  662.       else if ( curchr == mathcodebase )
  663.       n = 32768L ;
  664.       else if ( curchr == sfcodebase )
  665.       n = 32767 ;
  666.       else if ( curchr == delcodebase )
  667.       n = 16777215L ;
  668.       else n = 255 ;
  669.       p = curchr ; 
  670.       p += scancharnum();    /* p = p + curval; */
  671.       scanoptionalequals () ;
  672.      {register integer r_curval;
  673.       r_curval = scanint ();
  674.       if ( ( r_curval < 0 && p < delcodebase ) || r_curval > n ) {
  675.     print_err("Invalid code (");
  676.     printint ( r_curval );
  677.     if ( p < delcodebase ) 
  678.       c_print("), should be in the range 0..");
  679.     else
  680.       c_print("), should be at most ");
  681.     printint ( n ) ; 
  682.     zhelp1( STR_H_IMGOINGTOUSENULL );
  683.     error () ; 
  684.     curval = r_curval = 0;
  685.       }
  686.       if ( p < mathcodebase ) 
  687.     if ( ( a >= 4 ) ) 
  688.     geqdefine ( p , data , r_curval ) ; 
  689.     else eqdefine ( p , data , r_curval ) ; 
  690.       else if ( p < delcodebase ) 
  691.     if ( ( a >= 4 ) ) 
  692.     geqdefine ( p , data , r_curval ) ; 
  693.     else eqdefine ( p , data , r_curval ) ; 
  694.       else {
  695.     if ( ( a >= 4 ) )
  696.     geqworddefine ( p , r_curval ) ; 
  697.     else eqworddefine ( p , r_curval ) ; 
  698.       }
  699.      }
  700.     }
  701.     break ; 
  702.   case def_family :
  703.     {
  704.       p = curchr ; 
  705.       p += scanfourbitint ();    /* p = p + curval; */
  706.       scanoptionalequals ();
  707.       { register integer r_curval;
  708.     r_curval = scanfontident ();
  709.     if ( ( a >= 4 ) )
  710.       geqdefine ( p , data , r_curval );
  711.     else
  712.       eqdefine ( p , data , r_curval ); 
  713.       }
  714.     }
  715.     break ; 
  716.   case register_cmd : 
  717.   case advance : 
  718.   case multiply : 
  719.   case divide : 
  720.     doregistercommand ( a );
  721.     break;
  722.   case set_box : 
  723.     {
  724.       n = scaneightbitint ();
  725.       if ( a >= 4 )
  726.     n += 256;
  727.       scanoptionalequals ();
  728.       if ( setboxallowed ) {  /* TeX 3.141 */
  729.     scanbox ( 1073741824L + n );
  730.       } else {
  731.     p_print_err(STR_H_IMPROPER);  printesc(532);
  732.     zhelp1( STR_H_SORRY_SETBOXNOTALLOW );
  733.     error();
  734.       }
  735.     }
  736.     break ; 
  737.   case set_aux :
  738.     alteraux();
  739.     break;
  740.   case set_prev_graf :
  741.     alterprevgraf();
  742.     break ; 
  743.   case set_page_dimen :
  744.     alterpagesofar();
  745.     break ; 
  746.   case set_page_int :
  747.     alterinteger();
  748.     break ; 
  749.   case set_box_dimen :
  750.     alterboxdimen();
  751.     break ; 
  752.   case set_shape :
  753.     {
  754.       scanoptionalequals () ; 
  755.       n = scanint ();
  756.       if ( n <= 0 ) 
  757.         p = 0 ; 
  758.       else {
  759.     p = getnode ( 2 * n + 1 ) ; 
  760.     info ( p ) = n ; 
  761.     {register integer for_end; j = 1 ; for_end = n ; if ( j <= for_end) 
  762.     do {
  763.         mem[ p + 2 * j - 1 ].cint = scandimen( false, false, false );
  764.         mem[ p + 2 * j ].cint = scandimen( false, false, false );
  765.     } while ( j++ < for_end ) ; }
  766.       }
  767.       if ( ( a >= 4 ) ) 
  768.     geqdefine ( parshapeloc , shaperef , p ) ; 
  769.       else
  770.     eqdefine ( parshapeloc , shaperef , p ) ; 
  771.     }
  772.     break ; 
  773.   case hyph_data :
  774.     if ( curchr == 1 ) {
  775.       if( call_new_patterns() )        /* virtex returns != 0 */
  776.     return;
  777.     } else {
  778.       newhyphexceptions () ; 
  779.     } 
  780.     goto lab30 ; 
  781.     break ; 
  782.   case assign_font_dimen :
  783.     {
  784.       k = findfontdimen ( true );
  785.       scanoptionalequals () ; 
  786.       fontinfo [ k ] .cint = scandimen ( false , false , false );
  787.     } 
  788.     break ; 
  789.   case assign_font_int :
  790.     {
  791.       n = curchr ; 
  792.       f = scanfontident ();
  793.       scanoptionalequals () ; 
  794.       if ( n == 0 ) 
  795.     hyphenchar(f) = scanint ();
  796.       else
  797.     skewchar(f) = scanint();
  798.     }
  799.     break ; 
  800.   case def_font :
  801.     newfont( a );
  802.     break ; 
  803.   case set_interaction :
  804.     newinteraction();
  805.     break ; 
  806.   default: 
  807.     confusion("prefix");
  808.     break ; 
  809.   }
  810.  
  811. lab30:
  812.   if ( aftertoken != 0 ) {
  813.     curtok = aftertoken;
  814.     backinput();
  815.     aftertoken = 0;
  816.   }
  817. }
  818.  
  819.  
  820. #if 0
  821.  
  822. void maincontrol ( ) 
  823.  
  824. #endif
  825.  
  826. void giveerrhelp ( void )
  827. { giveerrhelp_regmem
  828.  
  829.   tokenshow ( errhelp );
  830. }
  831.  
  832.  
  833. boolean openfmtfile ( void )
  834. {/* 40 10 */ openfmtfile_regmem 
  835.   register integer j  ; 
  836.  
  837.   j = curinput .locfield ; 
  838.   if ( buffer [ curinput .locfield ] == 38 ) {
  839.     incr ( curinput .locfield ) ; 
  840.     j = curinput .locfield ; 
  841.     buffer [ last ] = 32 ;
  842.     while ( buffer [ j ] != 32 )
  843.       incr( j );
  844.     packbufferedname ( 0, curinput .locfield, j - 1 );
  845.     if ( wopenin ( fmtfile ) ) 
  846.       goto lab40;
  847.     wakeupterminal ();
  848.     (void) printf("Sorry, I can't find that format; will try the default.\n");
  849.     flush ( stdout );
  850.   } 
  851.   packbufferedname ( formatdefaultlength - 4 , 1 , 0 ) ; 
  852.   if ( ! wopenin ( fmtfile ) ) {
  853.     wakeupterminal ();
  854.     (void) printf("I can't find the default format file!\n");
  855.     return(false);
  856.   }
  857.  
  858. lab40:
  859.   curinput .locfield = j;
  860.   return(true);
  861. }
  862.  
  863.  
  864. #if 0        /* nach shipout.c */
  865. void closefilesandterminate ( void )
  866. #endif
  867.  
  868. #ifdef DEBUG
  869. void debughelp ( void )
  870. {/* 888 10 */ debughelp_regmem 
  871.   register integer k, l, m, n  ; 
  872.  
  873.   while ( true ) {
  874.     wakeupterminal () ; 
  875.     c_printnl("debug # (-1 to exit):");
  876.     flush ( stdout ) ; 
  877.     read ( stdin , m ) ; 
  878.     if ( m < 0 ) 
  879.       return ; 
  880.     else if ( m == 0 ) 
  881.       dumpcore () ; 
  882.     else {
  883.       read ( stdin , n ) ; 
  884.       switch ( m ) {
  885.       case 1 : 
  886.     printword ( mem [ n ] ) ; 
  887.     break ; 
  888.       case 2 : 
  889.     printint ( info ( n ) ) ; 
  890.     break ; 
  891.       case 3 : 
  892.     printint ( link ( n ) ) ; 
  893.     break ; 
  894.       case 4 : 
  895.     printword ( eqtb [ n ] ) ; 
  896.     break ; 
  897.       case 5 : 
  898.     printword ( fontinfo [ n ] ) ; 
  899.     break ; 
  900.       case 6 : 
  901.     printword ( savestack [ n ] ) ; 
  902.     break ; 
  903.       case 7 : 
  904.     showbox ( n ) ; 
  905.     break ; 
  906.       case 8 : 
  907.     {
  908.       breadthmax = 10000 ; 
  909.       depththreshold = poolsize - poolptr - 10 ; 
  910.       shownodelist ( n ) ; 
  911.     } 
  912.     break ; 
  913.       case 9 : 
  914.     showtokenlist ( n , 0 , 1000 ) ; 
  915.     break ; 
  916.       case 10 : 
  917. #if 0  /* TeX 3.141 */
  918.     print ( n );
  919. #else
  920.     slowprint ( n );
  921. #endif
  922.     break ; 
  923.       case 11 : 
  924.     checkmem ( n > 0 ) ; 
  925.     break ; 
  926.       case 12 : 
  927.     searchmem ( n ) ; 
  928.     break ; 
  929.       case 13 : 
  930.     {
  931.       read ( stdin , l ) ; 
  932.       printcmdchr ( n , l ) ; 
  933.     } 
  934.     break ; 
  935.       case 14 : 
  936.     {register integer for_end; k = 0 ; for_end = n ; if ( k <= for_end) 
  937.     do 
  938.       print ( buffer [ k ] ) ; 
  939.     while ( k++ < for_end ) ; } 
  940.     break ; 
  941.       case 15 : 
  942.     {
  943.       fontinshortdisplay = nullfont ; 
  944.       shortdisplay ( n ) ; 
  945.     } 
  946.     break ; 
  947.       case 16 : 
  948.     panicking = ! panicking ; 
  949.     break ; 
  950.       default: 
  951.     print ( 63 ) ; 
  952.     break ; 
  953.       } 
  954.     } 
  955.   } 
  956. #endif /* DEBUG */
  957.