home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / texmf / source / TeX / tex / tex4.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-14  |  20.8 KB  |  942 lines

  1. #define EXTERN extern
  2. #include "texd.h"
  3.  
  4. void charwarning ( internalfontnumber f, eightbits c )
  5. { charwarning_regmem
  6.  
  7.   if ( tracinglostchars > 0 ) {
  8.     begindiagnostic();
  9.     c_printnl("Missing character: There is no ");  print( c );
  10.     c_print(" in font ");
  11. #if 0  /* TeX 3.141 */
  12.     print( fontname(f) );
  13. #else
  14.     slowprint( fontname(f) );
  15. #endif
  16.     printchar( 33 );
  17.     enddiagnostic( false );
  18.   }
  19. }
  20.  
  21.   long_halfword
  22. newcharacter( internalfontnumber f, eightbits c )
  23. { newcharacter_regmem 
  24.  
  25.   if ( fontbc(f) <= c && fontec(f) >= effective_char(c) ) {
  26.     if ( charexists ( zcharinfo ( f ,  c ) ) ) {
  27.       register long_halfword p;
  28.  
  29.       p = getavail();
  30.       font( p ) = f;
  31.       character( p ) = c;
  32.       return(p);
  33.     }
  34.   }
  35.   charwarning( f, c );
  36.   return (long_halfword) 0;
  37. }
  38.  
  39.  
  40.  
  41. void scanspec ( groupcode c, boolean threecodes )
  42. { scanspec_regmem 
  43.   register integer s;
  44.   register schar speccode;
  45.  
  46.   if ( threecodes ) 
  47.     s = saved ( 0 );
  48.  
  49.   if ( scankeyword( STR_TO ) )
  50.     speccode = 0 ; 
  51.   else if ( scankeyword( STR_SPREAD ) )
  52.     speccode = 1 ; 
  53.   else {
  54.     speccode = 1 ; 
  55.     curval = 0 ; 
  56.     goto lab40 ; 
  57.   } 
  58.   scandimen ( false , false , false ) ; 
  59.  
  60. lab40:
  61.   if ( threecodes ) {
  62.     saved ( 0 ) = s ; 
  63.     incr ( saveptr ) ; 
  64.   } 
  65.   saved ( 0 ) = speccode ; 
  66.   saved ( 1 ) = curval ; 
  67.   saveptr = saveptr + 2 ; 
  68.   newsavelevel ( c ) ; 
  69.   scanleftbrace ();
  70. }
  71.  
  72.  
  73.   long_halfword
  74. hpack( halfword p, scaled w, smallnumber m )
  75. { long_halfword r; 
  76.  
  77.   r = getnode( boxnodesize );
  78.  
  79.   { hpack_regmem 
  80.   halfword q;
  81.   register scaled h, d, x;
  82.   glueord o;
  83.  
  84. #ifdef TEXXET
  85.   halfword LR_Ptr = 0;
  86.   integer LR_problems = 0;
  87. #endif
  88.  
  89.  
  90. /* ztype ( r ) = hlistnode ;  subtype ( r ) = 0 ; */
  91.   set_type_subtype( r, hlistnode, 0);
  92.  
  93.   shiftamount ( r ) = 0;
  94.   q = r + listoffset;
  95.   link ( q ) = p;
  96.  
  97.   lastbadness = 0;
  98.   h = 0;
  99.   d = 0;
  100.   x = 0;
  101.   totalstretch [ normal ] = 0 ; 
  102.   totalstretch [ fil ] = 0 ; 
  103.   totalstretch [ fill ] = 0 ; 
  104.   totalstretch [ filll ] = 0 ; 
  105.   totalshrink [ normal ] = 0 ; 
  106.   totalshrink [ fil ] = 0 ; 
  107.   totalshrink [ fill ] = 0 ; 
  108.   totalshrink [ filll ] = 0 ; 
  109.  
  110.   while ( p != 0 ) {
  111.       /* 651. examine node p in the hlist ... */
  112. lab21:
  113.     while ( ischarnode ( p ) ) {
  114.       register internalfontnumber f;
  115.       register eightbits hd;
  116.       fourquarters i;
  117.  
  118.       f = font ( p ) ; 
  119.       i = zcharinfo ( f ,  character ( p ) ) ; 
  120.       x = x + zcharwidth( f, i );
  121.       hd = heightdepth( i );
  122.       { register scaled s;
  123.       s = zcharheight ( f, hd ) ; 
  124.       if ( s > h ) 
  125.     h = s ; 
  126.       s = zchardepth ( f, hd ) ; 
  127.       if ( s > d ) 
  128.     d = s;
  129.       }
  130.       p = link ( p );
  131.     }
  132.     if ( p != 0 ) {
  133.       switch ( ztype ( p ) ) {
  134.       case hlistnode : 
  135.       case vlistnode : 
  136.       case rulenode : 
  137.       case unsetnode : 
  138.     { register scaled s;
  139.  
  140.       x = x + width ( p ) ; 
  141.       if ( ztype ( p ) >= rulenode ) 
  142.         s = 0 ; 
  143.       else
  144.         s = shiftamount ( p ) ; 
  145.       if ( height ( p ) - s > h ) 
  146.         h = height ( p ) - s ; 
  147.       if ( depth ( p ) + s > d ) 
  148.         d = depth ( p ) + s;
  149.     }
  150.     break ; 
  151.       case insnode : 
  152.       case marknode : 
  153.       case adjustnode :
  154.     { register halfword r_adjusttail = adjusttail;
  155.  
  156.       if ( r_adjusttail != 0 ) {
  157.         while ( link ( q ) != p )
  158.           q = link ( q ) ;
  159.         if ( ztype ( p ) == adjustnode ) {
  160.           link ( r_adjusttail ) = adjustptr ( p ) ; 
  161.           while ( link ( r_adjusttail ) != 0 )
  162.         r_adjusttail = link ( r_adjusttail );
  163.           p = link ( p ) ; 
  164.           freenode ( link ( q ) , smallnodesize ) ; 
  165.         } else {
  166.           link ( r_adjusttail ) = p ; 
  167.           r_adjusttail = p;
  168.           p = link ( p ) ; 
  169.         } 
  170.         link ( q ) = p ; 
  171.         p = q ;
  172.  
  173.             adjusttail = r_adjusttail;
  174.       }
  175.       break ;
  176.     }
  177.       case whatsitnode :
  178.     break;
  179.  
  180.       case gluenode:
  181.     { halfword g;
  182.  
  183.       g = glueptr ( p ) ; 
  184.       x = x + width ( g ) ; 
  185.       o = stretchorder ( g ) ; 
  186.       totalstretch [ o ] +=  stretch( g );
  187.       o = shrinkorder ( g ) ; 
  188.       totalshrink [ o ] +=  shrink( g );
  189.       if ( subtype ( p ) >= aleaders ) {
  190.         g = leaderptr ( p ) ; 
  191.         if ( height ( g ) > h ) 
  192.         h = height ( g ) ; 
  193.         if ( depth ( g ) > d ) 
  194.         d = depth ( g ) ; 
  195.       }
  196.     }
  197.     break ; 
  198. #ifdef TEXXET
  199.       case kernnode : 
  200.     x = x + width ( p ) ; 
  201.     break ; 
  202.       case mathnode : 
  203.     x = x + width ( p ) ; 
  204.     /* 1384. Adjust the LR stack for the hpack routine. */
  205.     if( end_LR(p) ) {
  206.       if( saveinfo(LR_ptr) == subtype(p) ) {
  207.         pop_LR;
  208.       } else {
  209.         incr(LR_problems);
  210.         while( link(q) != p )
  211.         q = link(q);
  212.         link(q) = link(p);
  213.         freenode(p, smallnodesize);
  214.         p = q;
  215.       }
  216.     } else {
  217.       push_LR(p);
  218.     }
  219.     break;
  220. #else
  221.       case kernnode : 
  222.       case mathnode : 
  223.     x = x + width ( p ) ; 
  224.     break ; 
  225. #endif
  226.       case ligaturenode : 
  227.     {
  228.       mem [ ligtrick ] = mem [ ligchar ( p ) ] ; 
  229.       link ( ligtrick ) = link ( p ) ; 
  230.       p = ligtrick ; 
  231.       goto lab21 ; 
  232.     } 
  233.     break ; 
  234.       default: 
  235.     break ; 
  236.       } 
  237.       p = link ( p ) ; 
  238.     } 
  239.   }
  240.  
  241.   if ( adjusttail != 0 ) 
  242.     link ( adjusttail ) = 0 ; 
  243.   height ( r ) = h ; 
  244.   depth ( r ) = d ; 
  245.   if ( m == 1 ) 
  246.     w = x + w ; 
  247.   width ( r ) = w ; 
  248.   x = w - x ; 
  249.   if ( x == 0 ) {
  250.     gluesign ( r ) = normal ; 
  251.     glueorder ( r ) = normal ; 
  252.     glueset ( r ) = 0.0 ; 
  253.     goto lab10 ; 
  254.   } else if ( x > 0 ) {
  255.     if ( totalstretch [ filll ] != 0 ) 
  256.       o = filll ; 
  257.     else if ( totalstretch [ fill ] != 0 ) 
  258.       o = fill ; 
  259.     else if ( totalstretch [ fil ] != 0 ) 
  260.       o = fil ; 
  261.     else
  262.       o = normal ; 
  263.     glueorder ( r ) = o ; 
  264.     gluesign ( r ) = stretching ; 
  265.     if ( totalstretch [ o ] != 0 ) 
  266.       glueset ( r ) = x / ((double) totalstretch [ o ] ) ; 
  267.     else {
  268.       gluesign ( r ) = normal ; 
  269.       glueset ( r ) = 0.0 ; 
  270.     } 
  271.     if ( o == normal ) 
  272.     if ( listptr ( r ) != 0 ) {
  273.       lastbadness = badness ( x , totalstretch [ normal ] ) ; 
  274.       if ( lastbadness > hbadness ) {
  275.     println () ; 
  276.     if ( lastbadness > 100 ) 
  277.       c_printnl("Underfull");
  278.     else
  279.       c_printnl("Loose");
  280.     c_print(" \\hbox (badness ");
  281.     printint ( lastbadness ) ; 
  282.     goto lab50 ; 
  283.       } 
  284.     } 
  285.     goto lab10 ; 
  286.   } else {
  287.     if ( totalshrink [ filll ] != 0 ) 
  288.       o = filll ; 
  289.     else if ( totalshrink [ fill ] != 0 ) 
  290.       o = fill ; 
  291.     else if ( totalshrink [ fil ] != 0 ) 
  292.       o = fil ; 
  293.     else
  294.       o = normal ; 
  295.     glueorder ( r ) = o ; 
  296.     gluesign ( r ) = shrinking ; 
  297.     if ( totalshrink [ o ] != 0 ) 
  298.       glueset ( r ) = ( - (integer) x ) / ((double) totalshrink [ o ] ) ; 
  299.     else {
  300.       gluesign ( r ) = normal ; 
  301.       glueset ( r ) = 0.0 ; 
  302.     }
  303.     if( (totalshrink[o] < - (integer) x) && (o == normal)
  304.                      && (listptr(r) != 0) ) {
  305.       lastbadness = 1000000L ; 
  306.       glueset ( r ) = 1.0 ; 
  307.       if( (- (integer) x - totalshrink[normal] > hfuzz) || (hbadness < 100) ) {
  308.     if( (overfullrule > 0)
  309.         && (- (integer)x - totalshrink[normal] > hfuzz) ) {
  310.       while ( link ( q ) != 0 )
  311.         q = link( q );
  312.       link ( q ) = newrule () ; 
  313.       width ( link ( q ) ) = overfullrule;
  314.     }
  315.     println () ; 
  316.     c_printnl("Overfull \\hbox (");
  317.     printscaled ( - (integer) x - totalshrink [ normal ] ) ; 
  318.     c_print("pt too wide");
  319.     goto lab50 ; 
  320.       }
  321.     } else if ( o == normal ) {
  322.       if ( listptr ( r ) != 0 ) {
  323.     lastbadness = badness ( - (integer) x, totalshrink[normal] );
  324.     if ( lastbadness > hbadness ) {
  325.       println ();
  326.       c_printnl("Tight \\hbox (badness ");
  327.       printint ( lastbadness );
  328.       goto lab50;
  329.     }
  330.       }
  331.     }
  332.     goto lab10;
  333.   }
  334.  
  335. lab50:    /* common_ending: */
  336.   if ( outputactive ) 
  337.     c_print(") has occurred while \\output is active");
  338.   else {
  339.     if ( packbeginline != 0 ) {
  340.       if ( packbeginline > 0 ) 
  341.     c_print(") in paragraph at lines ");
  342.       else
  343.     c_print(") in alignment at lines ");
  344.       printint ( abs ( packbeginline ) ) ; 
  345.       c_print("--");
  346.     } else
  347.       c_print(") detected at line ");
  348.     printint ( line ) ; 
  349.   }
  350.   println () ; 
  351.   fontinshortdisplay = nullfont ; 
  352.   shortdisplay ( listptr ( r ) ) ; 
  353.   println () ; 
  354.   begindiagnostic () ; 
  355.   showbox ( r ) ; 
  356.   enddiagnostic ( true ) ; 
  357.  
  358. lab10:
  359. #ifdef TEXXET
  360.   /* 1385. Check for LR anomalies at the end of hpack. */
  361.   if( LR_ptr != 0 ) {
  362.     while( link(q) != 0 )
  363.       q = link(q);
  364.     do {
  365.       tempptr = q;  q = newmath(0, info(LR_ptr));  link(tempptr) = q;
  366.       LR_problems += 10000;  pop_LR;
  367.     } while( LR_ptr != 0 );
  368.   }
  369.   if( LR_problems > 0 ) {
  370.     println;  c_printnl("\\endL or \\endR problem (");
  371.     printint(LR_problems / 10000); c_print(" missing, ");
  372.     printint(LR_problems % 10000); c_print(" extra");
  373.     LR_problems = 0;
  374.     goto lab50;
  375.   }
  376. #endif
  377.  
  378.   return(r);
  379.   }
  380. }
  381.  
  382.  
  383. long_halfword vpackage ( halfword p, scaled h, smallnumber m, scaled l )
  384. { vpackage_regmem
  385.   register long_halfword r;
  386.   register scaled w, d, x  ; 
  387.   register halfword g  ; 
  388.   register glueord o  ; 
  389.  
  390.   lastbadness = 0 ; 
  391.   r = getnode ( boxnodesize ) ; 
  392.   ztype ( r ) = vlistnode ; 
  393.   subtype ( r ) = 0 ; 
  394.   shiftamount ( r ) = 0 ; 
  395.   listptr ( r ) = p ; 
  396.   w = 0 ; 
  397.   d = 0 ; 
  398.   x = 0 ; 
  399.   totalstretch [ normal ] = 0 ; 
  400.   totalshrink [ normal ] = 0 ; 
  401.   totalstretch [ fil ] = 0 ; 
  402.   totalshrink [ fil ] = 0 ; 
  403.   totalstretch [ fill ] = 0 ; 
  404.   totalshrink [ fill ] = 0 ; 
  405.   totalstretch [ filll ] = 0 ; 
  406.   totalshrink [ filll ] = 0 ; 
  407.  
  408.   while ( p != 0 ) {
  409.     if ( ischarnode ( p ) ) 
  410.       confusion("vpack");
  411.     else switch ( ztype ( p ) ) {
  412.     case hlistnode : 
  413.     case vlistnode : 
  414.     case rulenode : 
  415.     case unsetnode : 
  416.       { register scaled s;
  417.  
  418.     x = x + d + height ( p ) ; 
  419.     d = depth ( p ) ; 
  420.     if ( ztype ( p ) >= rulenode ) 
  421.       s = 0 ; 
  422.     else
  423.       s = shiftamount ( p ) ; 
  424.     if ( width ( p ) + s > w ) 
  425.       w = width ( p ) + s ; 
  426.       }
  427.       break ; 
  428.     case whatsitnode : 
  429.       break ; 
  430.     case gluenode : 
  431.       {
  432.     x = x + d ; 
  433.     d = 0 ; 
  434.     g = glueptr ( p ) ; 
  435.     x = x + width ( g ) ; 
  436.     o = stretchorder ( g ) ; 
  437.     totalstretch [ o ] = totalstretch [ o ] + stretch ( g ) ; 
  438.     o = shrinkorder ( g ) ; 
  439.     totalshrink [ o ] = totalshrink [ o ] + shrink ( g ) ; 
  440.     if ( subtype ( p ) >= aleaders ) {
  441.       g = leaderptr ( p ) ; 
  442.       if ( width ( g ) > w ) 
  443.       w = width ( g ) ; 
  444.     } 
  445.       } 
  446.       break ; 
  447.     case kernnode : 
  448.       {
  449.     x = x + d + width ( p ) ; 
  450.     d = 0 ; 
  451.       } 
  452.       break ; 
  453.     default: 
  454.       break ; 
  455.     } 
  456.     p = link ( p ) ; 
  457.   } 
  458.   width ( r ) = w ; 
  459.   if ( d > l ) {
  460.     x = x + d - l ; 
  461.     depth ( r ) = l ; 
  462.   } else
  463.     depth ( r ) = d ; 
  464.   if ( m == 1 ) 
  465.   h = x + h ; 
  466.   height ( r ) = h ; 
  467.   x = h - x ; 
  468.   if ( x == 0 ) {
  469.     gluesign ( r ) = normal ; 
  470.     glueorder ( r ) = normal ; 
  471.     glueset ( r ) = 0.0 ; 
  472.     goto lab10 ; 
  473.   } else if ( x > 0 ) {
  474.     if ( totalstretch [ filll ] != 0 ) 
  475.     o = filll ; 
  476.     else if ( totalstretch [ fill ] != 0 ) 
  477.     o = fill ; 
  478.     else if ( totalstretch [ fil ] != 0 ) 
  479.     o = fil ; 
  480.     else o = normal ; 
  481.     glueorder ( r ) = o ; 
  482.     gluesign ( r ) = stretching ; 
  483.     if ( totalstretch [ o ] != 0 ) 
  484.       glueset ( r ) = x / ((double) totalstretch [ o ] ) ; 
  485.     else {
  486.       gluesign ( r ) = normal ; 
  487.       glueset ( r ) = 0.0 ; 
  488.     } 
  489.     if ( o == normal ) 
  490.     if ( listptr ( r ) != 0 ) {
  491.       lastbadness = badness ( x , totalstretch [ normal ] ) ; 
  492.       if ( lastbadness > vbadness ) {
  493.     println () ; 
  494.     if ( lastbadness > 100 ) 
  495.       c_printnl("Underfull");
  496.     else
  497.       c_printnl("Loose");
  498.     c_print(" \\vbox (badness ");
  499.     printint ( lastbadness ) ; 
  500.     goto lab50 ; 
  501.       } 
  502.     } 
  503.     goto lab10 ; 
  504.   } else {
  505.     if ( totalshrink [ filll ] != 0 ) 
  506.     o = filll ; 
  507.     else if ( totalshrink [ fill ] != 0 ) 
  508.     o = fill ; 
  509.     else if ( totalshrink [ fil ] != 0 ) 
  510.     o = fil ; 
  511.     else o = normal ; 
  512.     glueorder ( r ) = o ; 
  513.     gluesign ( r ) = shrinking ; 
  514.     if ( totalshrink [ o ] != 0 ) 
  515.       glueset ( r ) = ( - (integer) x ) / ((double) totalshrink [ o ] ) ; 
  516.     else {
  517.       gluesign ( r ) = normal ; 
  518.       glueset ( r ) = 0.0 ; 
  519.     } 
  520.     if ( ( totalshrink [ o ] < - (integer) x ) && ( o == normal ) && ( listptr 
  521.     ( r ) != 0 ) ) 
  522.     {
  523.       lastbadness = 1000000L ; 
  524.       glueset ( r ) = 1.0 ; 
  525.       if ( (-(integer)x - totalshrink[normal] > vfuzz) || (vbadness < 100) ) {
  526.     println();
  527.     c_printnl("Overfull \\vbox (");
  528.     printscaled ( - (integer) x - totalshrink[normal] );
  529.     c_print("pt too high");
  530.     goto lab50;
  531.       }
  532.     }
  533.     else if ( o == normal ) 
  534.     if ( listptr ( r ) != 0 ) {
  535.       lastbadness = badness ( - (integer) x , totalshrink [ normal ] ) ; 
  536.       if ( lastbadness > vbadness ) {
  537.     println () ; 
  538.     c_printnl("Tight \\vbox (badness ");
  539.     printint ( lastbadness ) ; 
  540.     goto lab50 ; 
  541.       } 
  542.     } 
  543.     goto lab10 ; 
  544.   } 
  545.  
  546. lab50:
  547.   if ( outputactive ) 
  548.     c_print(") has occurred while \\output is active");
  549.   else {
  550.     if ( packbeginline != 0 ) {
  551.       c_print(") in alignment at lines ");
  552.       printint ( abs ( packbeginline ) ) ; 
  553.       c_print("--");
  554.     } else
  555.       c_print(") detected at line ");
  556.     printint ( line ) ; 
  557.     println () ; 
  558.   }
  559.   begindiagnostic () ; 
  560.   showbox ( r ) ; 
  561.   enddiagnostic ( true ) ; 
  562.  
  563. lab10:
  564.   return(r) ; 
  565. }
  566.  
  567.  
  568. void appendtovlist ( halfword b )
  569. { appendtovlist_regmem
  570.   register scaled d;
  571.   register halfword p;
  572.  
  573.   if ( curlist .auxfield .cint > ignoredepth ) {
  574.     d = width ( baselineskip ) - curlist .auxfield .cint - height ( b ) ; 
  575.     if ( d < lineskiplimit ) 
  576.       p = newparamglue ( lineskipcode ) ; 
  577.     else {
  578.       p = newskipparam ( baselineskipcode ) ; 
  579.       width ( tempptr ) = d ; 
  580.     } 
  581.     link ( curlist .tailfield ) = p ; 
  582.     curlist .tailfield = p ; 
  583.   } 
  584.   link ( curlist .tailfield ) = b ; 
  585.   curlist .tailfield = b ; 
  586.   curlist .auxfield .cint = depth ( b ) ; 
  587. }
  588.  
  589.  
  590. long_halfword newnoad ( void )
  591. { register long_halfword p ;
  592.  
  593.   p = getnode ( noadsize ) ; 
  594.  
  595.   { newnoad_regmem 
  596.  
  597. /* ztype ( p ) = ordnoad ;  subtype ( p ) = normal ; */
  598.   set_type_subtype(p, ordnoad, normal);
  599.  
  600.   mem [ nucleus ( p ) ] .hh = emptyfield ;
  601.   mem [ subscr ( p ) ] .hh = emptyfield ;
  602.   mem [ supscr ( p ) ] .hh = emptyfield ;
  603.   }
  604.   return(p) ; 
  605.  
  606.  
  607. long_halfword newstyle ( smallnumber s )
  608. { register long_halfword p  ; 
  609.  
  610.   p = getnode ( stylenodesize ) ;
  611.  
  612.   { newstyle_regmem 
  613.  
  614. /* ztype ( p ) = stylenode ;  subtype ( p ) = s ; */
  615.   set_type_subtype(p, stylenode, s);
  616.   width ( p ) = 0 ; 
  617.   depth ( p ) = 0 ; 
  618.   }
  619.   return(p);
  620. }
  621.  
  622.  
  623. long_halfword newchoice ( void )
  624. { register long_halfword p ;
  625.  
  626.   p = getnode ( stylenodesize ) ; 
  627.  
  628.   { newchoice_regmem 
  629.  
  630. /* ztype ( p ) = choicenode ;  subtype ( p ) = 0 ; */
  631.   set_type_subtype(p, choicenode, 0);
  632.   textmlist ( p ) = 0 ;
  633.   displaymlist ( p ) = 0 ;
  634.   scriptscriptmlist ( p ) = 0 ;
  635.   scriptmlist ( p ) = 0 ;
  636.   }
  637.   return(p);
  638. }
  639.  
  640.  
  641. #if 0    /* (br) unnoetig, nur wegen PASCAL eingefuehrt */
  642. void showinfo ( void )
  643. { showinfo_regmem
  644.  
  645.   shownodelist ( info ( tempptr ) ) ; 
  646. }
  647. #endif
  648.  
  649.  
  650. long_halfword fractionrule ( scaled t )
  651. { register long_halfword p ;
  652.  
  653.   p = newrule () ; 
  654.  
  655.   { fractionrule_regmem
  656.  
  657.   height ( p ) = t ; 
  658.   depth ( p ) = 0 ;
  659.   }
  660.   return(p);
  661.  
  662.  
  663. long_halfword overbar ( halfword b, scaled k, scaled t )
  664. { overbar_regmem 
  665.   register halfword p, q  ; 
  666.  
  667.   p = newkern ( k ) ; 
  668.   link ( p ) = b ; 
  669.   q = fractionrule ( t ) ; 
  670.   link ( q ) = p ; 
  671.   p = newkern ( t ) ; 
  672.   link ( p ) = q ; 
  673.  
  674.   return( vpackage ( p , 0 , 1 , maxdimen ) );
  675.  
  676.  
  677. long_halfword charbox ( internalfontnumber f, quarterword c )
  678. { register long_halfword b;
  679.  
  680.   b = newnullbox ();
  681.  
  682.  { charbox_regmem
  683.   { fourquarters q;
  684.     register eightbits hd;
  685.  
  686.     q = zcharinfo (f, c);
  687.     hd = heightdepth ( q ) ; 
  688.     width ( b ) = zcharwidth ( f ,  q ) + zcharitalic ( f ,  q ) ; 
  689.     height ( b ) = zcharheight ( f ,  hd ) ; 
  690.     depth ( b ) = zchardepth ( f ,  hd );
  691.   }
  692.   { register long_halfword p;
  693.  
  694.     p = getavail ();
  695.     character ( p ) = c;
  696.     font ( p ) = f;
  697.     listptr ( b ) = p;
  698.   }
  699.  }
  700.   return(b);
  701. }
  702.  
  703.  
  704. void stackintobox ( halfword b, internalfontnumber f, quarterword c )
  705. { register halfword p;
  706.  
  707.   p = charbox( f, c );
  708.  
  709.   { stackintobox_regmem
  710.  
  711.   link ( p ) = listptr( b );
  712.   listptr ( b ) = p ; 
  713.   height ( b ) = height ( p ) ;
  714.   }
  715. }
  716.  
  717.  
  718. scaled heightplusdepth ( internalfontnumber f, quarterword c )
  719. { heightplusdepth_regmem 
  720.   fourquarters q  ; 
  721.   register eightbits hd  ; 
  722.  
  723.   q = zcharinfo ( f ,  c ) ; 
  724.   hd = heightdepth ( q ) ; 
  725.   return( zcharheight ( f ,  hd ) + zchardepth ( f ,  hd ) );
  726.  
  727.  
  728. long_halfword vardelimiter ( halfword d, smallnumber s, scaled v )
  729. { vardelimiter_regmem 
  730.   register long_halfword b  ; 
  731.   register internalfontnumber f, g  ; 
  732.   register quarterword c, x, y  ; 
  733.   register integer n;
  734.   register int m;
  735.   register scaled u  ; 
  736.   register scaled w  ; 
  737.   fourquarters q  ; 
  738.   register eightbits hd  ; 
  739.   fourquarters r  ; 
  740.   register smallnumber z  ; 
  741.   boolean largeattempt  ; 
  742.  
  743.   f = nullfont ; 
  744.   w = 0 ; 
  745.   largeattempt = false ; 
  746.   z = smallfam ( d ) ; 
  747.   x = smallchar ( d ) ; 
  748.  
  749.   while ( true ) {
  750.     if ( ( z != 0 ) || ( x != 0 ) ) {
  751.       z = z + s + 16 ; 
  752.       do {
  753.     z = z - 16 ; 
  754.     g = famfnt ( z ) ; 
  755.     if ( g != nullfont ) {
  756.       y = x ;
  757.       if ( y >= fontbc(g) && effective_char(y) <= fontec(g) ) {
  758. lab22:
  759.         q = zcharinfo ( g ,  y ) ; 
  760.         if ( charexists ( q ) ) {
  761.           if ( chartag ( q ) == exttag ) {
  762.         f = g ; 
  763.         c = y ; 
  764.         goto lab40 ; 
  765.           } 
  766.           hd = heightdepth ( q ) ; 
  767.           u = zcharheight ( g ,  hd ) + zchardepth ( g ,  hd ) ; 
  768.           if ( u > w ) {
  769.         f = g ; 
  770.         c = y ; 
  771.         w = u ; 
  772.         if ( u >= v ) 
  773.         goto lab40 ; 
  774.           } 
  775.           if ( chartag ( q ) == listtag ) {
  776.         y = rembyte ( q ) ; 
  777.         goto lab22 ; 
  778.           } 
  779.         } 
  780.       } 
  781.     } 
  782.       } while ( ! ( z < 16 ) ) ; 
  783.     }
  784.     if ( largeattempt ) 
  785.       goto lab40 ; 
  786.     largeattempt = true ; 
  787.     z = largefam ( d ) ; 
  788.     x = largechar ( d ) ; 
  789.   } 
  790.  
  791. lab40:
  792.   if ( f != nullfont ) 
  793.   if ( chartag ( q ) == exttag ) {
  794.     b = newnullbox () ; 
  795.     ztype ( b ) = vlistnode ; 
  796.     r = fontinfo [ extenbase(f) + rembyte ( q ) ] .qqqq ; 
  797.     c = extrep ( r ) ; 
  798.     u = heightplusdepth ( f , c ) ; 
  799.     w = 0 ; 
  800.     q = zcharinfo ( f ,  c ) ; 
  801.     width ( b ) = zcharwidth ( f ,  q ) + zcharitalic ( f ,  q ) ; 
  802.     c = extbot ( r ) ; 
  803.     if ( c != 0 ) 
  804.       w = w + heightplusdepth ( f , c ) ; 
  805.     c = extmid ( r ) ; 
  806.     if ( c != 0 ) 
  807.       w = w + heightplusdepth ( f , c ) ; 
  808.     c = exttop ( r ) ; 
  809.     if ( c != 0 ) 
  810.       w = w + heightplusdepth ( f , c ) ; 
  811.     n = 0 ; 
  812.     if ( u > 0 ) 
  813.     while ( w < v ) {
  814.       w = w + u ; 
  815.       incr ( n ) ; 
  816.       if ( extmid ( r ) != 0 ) 
  817.         w = w + u ; 
  818.     }
  819.     c = extbot ( r ) ; 
  820.     if ( c != 0 ) 
  821.       stackintobox ( b , f , c ) ; 
  822.     c = extrep ( r ) ;
  823.     for( m = n; m > 0; --m )
  824.       stackintobox ( b , f , c );
  825.     c = extmid ( r ) ; 
  826.     if ( c != 0 ) {
  827.       stackintobox ( b , f , c ) ; 
  828.       c = extrep ( r ) ; 
  829.       for( m = n; m > 0; --m )
  830.     stackintobox ( b , f , c );
  831.     }
  832.     c = exttop ( r ) ; 
  833.     if ( c != 0 ) 
  834.       stackintobox ( b , f , c ) ; 
  835.     depth ( b ) = w - height ( b ) ; 
  836.   } else
  837.     b = charbox ( f , c ) ; 
  838.   else {
  839.     b = newnullbox () ; 
  840.     width ( b ) = nulldelimiterspace ; 
  841.   } 
  842.   shiftamount ( b ) = half ( height ( b ) - depth ( b ) ) - axisheight ( s ) ; 
  843.  
  844.   return(b);
  845. }
  846.  
  847.  
  848. long_halfword rebox ( long_halfword b, scaled w )
  849. { rebox_regmem 
  850.   register halfword p  ; 
  851.   register internalfontnumber f  ; 
  852.   register scaled v  ; 
  853.  
  854.   if ( ( width ( b ) != w ) && ( listptr ( b ) != 0 ) ) {
  855.     if ( ztype ( b ) == vlistnode ) 
  856.       b = hpack ( b , 0 , 1 ) ; 
  857.     p = listptr ( b ) ; 
  858.     if ( ( ischarnode ( p ) ) && ( link ( p ) == 0 ) ) {
  859.       f = font ( p ) ; 
  860.       v = zcharwidth ( f ,  zcharinfo ( f ,  character ( p ) ) ) ; 
  861.       if ( v != width ( b ) ) 
  862.         link ( p ) = newkern ( width ( b ) - v ) ; 
  863.     } 
  864.     freenode ( b , boxnodesize ) ; 
  865.     b = newglue ( ssglue ) ; 
  866.     link ( b ) = p ; 
  867.     while ( link ( p ) != 0 )
  868.     p = link ( p ) ; 
  869.     link ( p ) = newglue ( ssglue ) ; 
  870.     return( hpack ( b , w , 0 ) );
  871.   } else {
  872.     width ( b ) = w ; 
  873.     return(b);
  874.   }
  875.  
  876.  
  877. long_halfword mathglue ( halfword g, scaled m )
  878. { mathglue_regmem 
  879.   register long_halfword p  ; 
  880.   register integer n  ; 
  881.   register scaled f  ; 
  882.  
  883.   n = xovern ( m , 65536L ) ; 
  884.   f = remainder ;
  885.   if ( f < 0 ) {  /* TeX 3.141 */
  886.     decr(n); f += 65536L;
  887.   }
  888.   p = getnode ( gluespecsize ) ; 
  889.   width(p) = multandadd ( n, width(g), xnoverd( width(g), f, 65536L ),
  890.                 1073741823L );
  891.   stretchorder(p) = stretchorder(g);
  892.   if ( stretchorder(p) == normal )
  893.     stretch(p) = multandadd ( n, stretch(g),
  894.             xnoverd ( stretch(g), f, 65536L ), 1073741823L );
  895.   else
  896.     stretch(p) = stretch(g);
  897.   shrinkorder(p) = shrinkorder(g);
  898.   if ( shrinkorder(p) == normal ) 
  899.     shrink(p) = multandadd ( n, shrink(g), xnoverd ( shrink(g), f, 65536L ),
  900.                 1073741823L );
  901.   else
  902.     shrink(p) = shrink(g);
  903.  
  904.   return(p);
  905.  
  906.  
  907. void mathkern ( halfword p, scaled m )
  908. { mathkern_regmem 
  909.   register integer n  ; 
  910.   register scaled f  ; 
  911.  
  912.   if ( subtype ( p ) == muglue ) {
  913.     n = xovern ( m , 65536L ) ; 
  914.     f = remainder ;
  915.     if ( f < 0 ) {  /* TeX 3.141 */
  916.       decr(n);  f += 65536L;
  917.     }
  918.     width(p) = multandadd ( n, width(p), xnoverd ( width(p), f, 65536L ),
  919.                 1073741823L );
  920.     subtype ( p ) = normal ;
  921.   }
  922. }
  923.  
  924.  
  925. void flushmath ( void )
  926. { flushmath_regmem 
  927.  
  928.   flushnodelist ( link ( curlist .headfield ) ) ; 
  929.   flushnodelist ( curlist .auxfield .cint ) ; 
  930.   link ( curlist .headfield ) = 0 ; 
  931.   curlist .tailfield = curlist .headfield ; 
  932.   curlist .auxfield .cint = 0 ; 
  933.  
  934. /* -- end -- */
  935.