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

  1. #define EXTERN extern
  2. #include "texd.h"
  3.  
  4.    static void
  5. boxend( integer boxcontext, long_halfword curbox )
  6. { boxend_regmem
  7.  
  8.   if ( boxcontext < 1073741824L ) {
  9.     if ( curbox != 0 ) {
  10.       shiftamount ( curbox ) = boxcontext; 
  11.       if ( abs ( curlist.modefield ) == vmode ) {
  12.     appendtovlist( curbox );
  13.     if ( adjusttail != 0 ) {
  14.       if ( adjusthead != adjusttail ) {
  15.         link ( curlist .tailfield ) = link ( adjusthead );
  16.         curlist .tailfield = adjusttail;
  17.       }
  18.       adjusttail = 0;
  19.     }
  20.     if ( curlist .modefield > 0 )
  21.       buildpage ();
  22.       } else {
  23.     if ( abs ( curlist .modefield ) == hmode ) 
  24.       curlist .auxfield .hh .v.LH = 1000 ; 
  25.     else {
  26.       register long_halfword p;
  27.  
  28.       p = newnoad();
  29.       mathtype ( nucleus ( p ) ) = subbox;
  30.       info ( nucleus ( p ) ) = curbox;
  31.       curbox = p;
  32.     }
  33.     link ( curlist .tailfield ) = curbox;
  34.     curlist .tailfield = curbox;
  35.       }
  36.     }
  37.   } else if ( boxcontext < 1073742336L ) {
  38.     if ( boxcontext < 1073742080L ) 
  39.       eqdefine( boxbase - 1073741824L + boxcontext, boxref, curbox );
  40.     else
  41.       geqdefine( boxbase - 1073742080L + boxcontext, boxref, curbox );
  42.   } else if ( curbox != 0 ) {
  43.     if ( boxcontext > 1073742336L ) {
  44.       register eightbits r_curcmd;
  45.  
  46.       r_curcmd = getxnbtoken(1);
  47.       if ( ( r_curcmd == hskip && abs( curlist .modefield ) != vmode )
  48.        || ( r_curcmd == vskip && abs( curlist .modefield ) == vmode )
  49.        || ( r_curcmd == mskip && abs( curlist .modefield ) == mmode ) ) {
  50.     appendglue();
  51.     subtype( curlist .tailfield ) = boxcontext - (1073742337L - aleaders);
  52.     leaderptr( curlist .tailfield ) = curbox;
  53.       } else {
  54.     print_err("Leaders not followed by proper glue");
  55.     zhelp1( STR_H_YOU_SHOULD_LEADERS );
  56.     backerror();
  57.     flushnodelist( curbox );
  58.       }
  59.     } else {
  60.       shipout( curbox );
  61.     }
  62.   }
  63. }
  64.  
  65.  
  66. void beginbox ( integer boxcontext )
  67. { beginbox_regmem
  68.   register halfword curbox;    /* (br) made local */
  69.  
  70.   switch ( curchr ) {
  71.   case 0 : 
  72.    { register integer r_curval;
  73.  
  74.      r_curval = scaneightbitint ();
  75.      curbox = box ( r_curval );
  76.      box ( r_curval ) = 0;
  77.      break ;
  78.    }
  79.   case 1 :
  80.     curbox = copynodelist( box( scaneightbitint() ) );
  81.     break;
  82.   case 2 : 
  83.     curbox = 0;
  84.     if ( abs(curlist.modefield) == mmode ) {
  85.     youcant();
  86.     zhelp1( STR_H_SORRY_LASTBOX_VOID );
  87.     error();
  88.     } else if ( ( curlist .modefield == vmode )
  89.         && ( curlist .headfield == curlist .tailfield ) ) {
  90.     youcant();
  91.     zhelp2( STR_H_SORRY_CANTTAKETHINGS, STR_H_THIS_LASTBOX_VOID );
  92.     error();
  93.     } else {
  94.     if ( ! ischarnode ( curlist .tailfield ) ) 
  95.     if ( ( ztype ( curlist .tailfield ) == hlistnode )
  96.       || ( ztype ( curlist .tailfield ) == vlistnode ) ) 
  97.     {
  98.       register halfword p, q ;
  99.  
  100.       q = curlist .headfield ; 
  101.       do {
  102.         p = q ;
  103.         if ( ! ischarnode ( q ) ) 
  104.         if ( ztype ( q ) == discnode ) {
  105.           register quarterword m;
  106.  
  107.           for( m = replacecount ( q ) ; m >= 1 ; --m ) {
  108.         p = link ( p ) ; 
  109.           }
  110.           if ( p == curlist .tailfield ) 
  111.             goto lab30 ; 
  112.         }
  113.         q = link ( p ) ; 
  114.       } while ( q != curlist .tailfield );
  115.       curbox = curlist .tailfield ; 
  116.       shiftamount ( curbox ) = 0 ; 
  117.       curlist .tailfield = p ; 
  118.       link ( p ) = 0 ; 
  119. lab30: ; 
  120.     }
  121.     }
  122.     break ; 
  123.   case 3 : 
  124.     { register /*eightbits*/ integer n;
  125.  
  126.       n = scaneightbitint ();    /* n = curval ; */
  127.       if ( ! scankeyword ( STR_TO ) ) {
  128.     print_err("Missing `to' inserted");
  129.     zhelp1( STR_H_IM_WORKING_VSPLIT );
  130.     error();
  131.       }
  132.       curbox = vsplit( n, scandimen( false, false, false ) );
  133.     }
  134.     break;
  135.   default: 
  136.     { register /*halfword*/ short k;
  137.  
  138.       k = curchr - 4;    /* curchr in [0,vmode,hmode] */
  139.       saved(0) = boxcontext;
  140.       if ( k == hmode ) {
  141.         if ( boxcontext < 1073741824L && ( abs(curlist.modefield) == vmode ) )
  142.       scanspec( adjustedhboxgroup, true );
  143.         else
  144.       scanspec( hboxgroup, true );
  145. #ifdef ERW_LANGUAGE
  146.         curlist .lhmfield = normmin(lefthyphenmin);
  147.         curlist .rhmfield = normmin(righthyphenmin);
  148. #endif
  149.       } else {
  150.     if ( k == vmode ) 
  151.       scanspec( vboxgroup, true );
  152.     else {
  153.       scanspec( vtopgroup, true );
  154.       k = vmode;
  155.     }
  156.     normalparagraph();
  157.       }
  158.       pushnest();
  159.       curlist.modefield = - k;
  160.       if ( k == vmode ) {
  161.     curlist .auxfield .cint = ignoredepth;
  162.     if ( everyvbox != 0 )
  163.       begintokenlist( everyvbox, everyvboxtext );
  164.       } else {
  165.     curlist .auxfield .hh .v.LH = 1000;
  166. #ifdef ERW_LANGUAGE
  167.         curlist .auxfield .hh .v.RH = 0;  /* clang */
  168. #endif
  169.     if ( everyhbox != 0 )
  170.       begintokenlist( everyhbox, everyhboxtext );
  171.       }
  172.       return;
  173.     }
  174.     break;
  175.   }
  176.   boxend( boxcontext, curbox ) ;  /* (br) */
  177. }
  178.  
  179.  
  180. void scanbox ( integer boxcontext )
  181. { scanbox_regmem
  182.   register eightbits r_curcmd;
  183.  
  184.   r_curcmd = getxnbtoken(1);
  185.   if ( r_curcmd == make_box )
  186.     beginbox ( boxcontext );
  187.   else if ( boxcontext >= 1073742337L
  188.         && (r_curcmd == hrule || r_curcmd == vrule) ) {
  189.     /* curbox = scanrulespec () ; */ /* (br) */
  190.     boxend ( boxcontext, scanrulespec() );
  191.   } else {
  192.     print_err("A <box> was supposed to be here");
  193.     zhelp1( STR_H_IWAS_EXPECT_HVBOX );
  194.     backerror();
  195.   }
  196. }
  197.  
  198.  
  199. void package ( smallnumber c )
  200. { package_regmem
  201.   scaled d;
  202.  
  203.   d = boxmaxdepth;
  204.   unsave();
  205.   saveptr -= 3;
  206.  
  207.   { register long_halfword curbox;    /* (br) made local */
  208.  
  209.     if( curlist.modefield == -hmode )
  210.       curbox = hpack( link(curlist.headfield ), saved(2), saved(1) );
  211.     else {
  212.       curbox = vpackage( link(curlist.headfield), saved(2), saved(1), d );
  213.       if ( c == 4 ) {
  214.     register scaled h;
  215.     register halfword p;
  216.  
  217.     p = listptr ( curbox ) ; 
  218.     if ( p != 0 && ztype(p) <= rulenode ) 
  219.       h = height(p);
  220.     else
  221.       h = 0;
  222.     depth(curbox) = depth(curbox) - h + height(curbox);
  223.     height(curbox) = h;
  224.       }
  225.     }
  226.     popnest();
  227.     boxend( saved(0), curbox ); /* (br) */
  228.   }
  229. }
  230.  
  231. /* -- end -- */
  232.