1: #ifndef lint
   2: static char sccsid[] = "@(#)shift.c	4.3 8/11/83";
   3: #endif
   4: 
   5: # include "e.h"
   6: #include "e.def"
   7: 
   8: bshiftb(p1, dir, p2) int p1, dir, p2; {
   9:     int shval, d1, h1, b1, h2, b2;
  10: #ifndef NEQN
  11:     int diffps, effps, effps2;
  12:     char *sh1, *sh2;
  13: #endif NEQN
  14: 
  15:     yyval = p1;
  16:     h1 = eht[p1];
  17:     b1 = ebase[p1];
  18:     h2 = eht[p2];
  19:     b2 = ebase[p2];
  20: #ifndef NEQN
  21:     effps = EFFPS(ps);
  22:     effps2 = EFFPS(ps+deltaps);
  23:     diffps = deltaps;
  24:     sh1 = sh2 = "";
  25: #endif NEQN
  26:     if( dir == SUB ) {  /* subscript */
  27: #ifndef NEQN
  28:         /* top 1/2m above bottom of main box */
  29:         d1 = VERT( (effps2*6)/2 );
  30: #else NEQN
  31:         d1 = VERT(1);
  32: #endif NEQN
  33:         shval = - d1 + h2 - b2;
  34:         if( d1+b1 > h2 ) /* move little sub down */
  35:             shval = b1-b2;
  36:         ebase[yyval] = b1 + max(0, h2-b1-d1);
  37:         eht[yyval] = h1 + max(0, h2-b1-d1);
  38: #ifndef NEQN
  39:         if (rfont[p1] == ITAL && lfont[p2] == ROM)
  40:             sh1 = "\\|";
  41:         if (rfont[p2] == ITAL)
  42:             sh2 = "\\|";
  43: #endif NEQN
  44:     } else {    /* superscript */
  45: #ifndef NEQN
  46:         /* 4/10 up main box */
  47:         d1 = VERT( (effps*6*2)/10 );
  48: #else NEQN
  49:         d1 = VERT(1);
  50: #endif NEQN
  51:         ebase[yyval] = b1;
  52: #ifndef NEQN
  53:         shval = -VERT( (4 * (h1-b1)) / 10 ) - b2;
  54:         if( VERT(4*(h1-b1)/10) + h2 < h1-b1 )   /* raise little super */
  55: #else NEQN
  56:         shval = -VERT(1) - b2;
  57:         if( VERT(1) + h2 < h1-b1 )  /* raise little super */
  58: #endif NEQN
  59:             shval = -(h1-b1) + h2-b2 - d1;
  60: #ifndef NEQN
  61:         eht[yyval] = h1 + max(0, h2-VERT((6*(h1-b1))/10));
  62:         if (rfont[p1] == ITAL)
  63:             sh1 = "\\|";
  64:         if (rfont[p2] == ITAL)
  65:             sh2 = "\\|";
  66: #else NEQN
  67:         eht[yyval] = h1 + max(0, h2 - VERT(1));
  68: #endif NEQN
  69:     }
  70:     if(dbg)printf(".\tb:b shift b: S%d <- S%d vert %d S%d vert %d; b=%d, h=%d\n",
  71:         yyval, p1, shval, p2, -shval, ebase[yyval], eht[yyval]);
  72: #ifndef NEQN
  73:     printf(".as %d \\v'%du'\\s-%d%s\\*(%d\\s+%d%s\\v'%du'\n",
  74:         yyval, shval, diffps, sh1, p2, diffps, sh2, -shval);
  75:     ps += deltaps;
  76:     if (rfont[p2] == ITAL)
  77:         rfont[p1] = 0;
  78:     else
  79:         rfont[p1] = rfont[p2];
  80: #else NEQN
  81:     printf(".as %d \\v'%du'\\*(%d\\v'%du'\n",
  82:         yyval, shval, p2, -shval);
  83: #endif NEQN
  84:     ofree(p2);
  85: }
  86: 
  87: shift(p1) int p1; {
  88:     ps -= deltaps;
  89:     yyval = p1;
  90:     if(dbg)printf(".\tshift: %d;ps=%d\n", yyval, ps);
  91: }
  92: 
  93: shift2(p1, p2, p3) int p1, p2, p3; {
  94:     int effps, h1, h2, h3, b1, b2, b3, subsh, d1, d2, supsh, treg;
  95: #ifndef NEQN
  96:     int effps2;
  97: #endif NEQN
  98: 
  99:     treg = oalloc();
 100:     yyval = p1;
 101:     if(dbg)printf(".\tshift2 s%d <- %d %d %d\n", yyval, p1, p2, p3);
 102:     effps = EFFPS(ps+deltaps);
 103: #ifndef NEQN
 104:     eht[p3] = h3 = VERT( (eht[p3] * effps) / EFFPS(ps) );
 105:     ps += deltaps;
 106:     effps2 = EFFPS(ps+deltaps);
 107: #endif NEQN
 108:     h1 = eht[p1]; b1 = ebase[p1];
 109:     h2 = eht[p2]; b2 = ebase[p2];
 110: #ifndef NEQN
 111:     b3 = ebase[p3];
 112:     d1 = VERT( (effps2*6)/2 );
 113: #else NEQN
 114:     h3 = eht[p3]; b3 = ebase[p3];
 115:     d1 = VERT(1);
 116: #endif NEQN
 117:     subsh = -d1+h2-b2;
 118:     if( d1+b1 > h2 ) /* move little sub down */
 119:         subsh = b1-b2;
 120: #ifndef NEQN
 121:     supsh = -VERT( (4*(h1-b1))/10 ) - b3;
 122:     d2 = VERT( (effps*6*2)/10 );
 123:     if( VERT(4*(h1-b1)/10)+h3 < h1-b1 )
 124: #else NEQN
 125:     supsh = - VERT(1) - b3;
 126:     d2 = VERT(1);
 127:     if( VERT(1)+h3 < h1-b1 )
 128: #endif NEQN
 129:         supsh = -(h1-b1) + (h3-b3) - d2;
 130: #ifndef NEQN
 131:     eht[yyval] = h1 + max(0, h3-VERT( (6*(h1-b1))/10 )) + max(0, h2-b1-d1);
 132: #else NEQN
 133:     eht[yyval] = h1 + max(0, h3-VERT(1)) + max(0, h2-b1-d1);
 134: #endif NEQN
 135:     ebase[yyval] = b1+max(0, h2-b1-d1);
 136: #ifndef NEQN
 137:     if (rfont[p1] == ITAL && lfont[p2] == ROM)
 138:         printf(".ds %d \\|\\*(%d\n", p2, p2);
 139:     if (rfont[p2] == ITAL)
 140:         printf(".as %d \\|\n", p2);
 141: #endif NEQN
 142:     nrwid(p2, effps, p2);
 143: #ifndef NEQN
 144:     if (rfont[p1] == ITAL && lfont[p3] == ROM)
 145:         printf(".ds %d \\|\\|\\*(%d\n", p3, p3);
 146:     else
 147:         printf(".ds %d \\|\\*(%d\n", p3, p3);
 148: #endif NEQN
 149:     nrwid(p3, effps, p3);
 150:     printf(".nr %d \\n(%d\n", treg, p3);
 151:     printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, treg, treg, p2);
 152: #ifndef NEQN
 153:     printf(".as %d \\v'%du'\\s%d\\*(%d\\h'-\\n(%du'\\v'%du'\\\n",
 154:         p1, subsh, effps, p2, p2, -subsh+supsh);
 155:     printf("\\s%d\\*(%d\\h'-\\n(%du+\\n(%du'\\s%d\\v'%du'\n",
 156:         effps, p3, p3, treg, effps2, -supsh);
 157: #else NEQN
 158:     printf(".as %d \\v'%du'\\*(%d\\h'-\\n(%du'\\v'%du'\\\n",
 159:         p1, subsh, p2, p2, -subsh+supsh);
 160:     printf("\\*(%d\\h'-\\n(%du+\\n(%du'\\v'%du'\n",
 161:         p3, p3, treg, -supsh);
 162: #endif NEQN
 163:     ps += deltaps;
 164: #ifndef NEQN
 165:     if (rfont[p2] == ITAL)
 166:         rfont[yyval] = 0;   /* lie */
 167: #endif NEQN
 168:     ofree(p2); ofree(p3); ofree(treg);
 169: }

Defined functions

bshiftb defined in line 8; used 4 times
shift defined in line 87; used 2 times
shift2 defined in line 93; used 2 times

Defined variables

sccsid defined in line 2; never used
Last modified: 1987-02-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2504
Valid CSS Valid XHTML 1.0 Strict