1: # include "e.h" 2: #include "e.def" 3: 4: bshiftb(p1, dir, p2) int p1, dir, p2; { 5: int shval, d1, h1, b1, h2, b2; 6: yyval = p1; 7: h1 = eht[p1]; 8: b1 = ebase[p1]; 9: h2 = eht[p2]; 10: b2 = ebase[p2]; 11: if( dir == SUB ) { /* subscript */ 12: d1 = VERT(1); 13: shval = - d1 + h2 - b2; 14: if( d1+b1 > h2 ) /* move little sub down */ 15: shval = b1-b2; 16: ebase[yyval] = b1 + max(0, h2-b1-d1); 17: eht[yyval] = h1 + max(0, h2-b1-d1); 18: } else { /* superscript */ 19: d1 = VERT(1); 20: ebase[yyval] = b1; 21: shval = -VERT(1) - b2; 22: if( VERT(1) + h2 < h1-b1 ) /* raise little super */ 23: shval = -(h1-b1) + h2-b2 - d1; 24: eht[yyval] = h1 + max(0, h2 - VERT(1)); 25: } 26: if(dbg)printf(".\tb:b shift b: S%d <- S%d vert %d S%d vert %d; b=%d, h=%d\n", 27: yyval, p1, shval, p2, -shval, ebase[yyval], eht[yyval]); 28: printf(".as %d \\v'%du'\\*(%d\\v'%du'\n", 29: yyval, shval, p2, -shval); 30: ofree(p2); 31: } 32: 33: shift(p1) int p1; { 34: ps -= deltaps; 35: yyval = p1; 36: if(dbg)printf(".\tshift: %d;ps=%d\n", yyval, ps); 37: } 38: 39: shift2(p1, p2, p3) int p1, p2, p3; { 40: int effps, h1, h2, h3, b1, b2, b3, subsh, d1, d2, supsh; 41: int treg; 42: 43: treg = oalloc(); 44: yyval = p1; 45: if(dbg)printf(".\tshift2 s%d <- %d %d %d\n", yyval, p1, p2, p3); 46: effps = EFFPS(ps+deltaps); 47: h1 = eht[p1]; b1 = ebase[p1]; 48: h2 = eht[p2]; b2 = ebase[p2]; 49: h3 = eht[p3]; b3 = ebase[p3]; 50: d1 = VERT(1); 51: subsh = -d1+h2-b2; 52: if( d1+b1 > h2 ) /* move little sub down */ 53: subsh = b1-b2; 54: supsh = - VERT(1) - b3; 55: d2 = VERT(1); 56: if( VERT(1)+h3 < h1-b1 ) 57: supsh = -(h1-b1) + (h3-b3) - d2; 58: eht[yyval] = h1 + max(0, h3-VERT(1)) + max(0, h2-b1-d1); 59: ebase[yyval] = b1+max(0, h2-b1-d1); 60: nrwid(p2, effps, p2); 61: nrwid(p3, effps, p3); 62: printf(".nr %d \\n(%d\n", treg, p3); 63: printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, treg, treg, p2); 64: printf(".as %d \\v'%du'\\*(%d\\h'-\\n(%du'\\v'%du'\\\n", 65: p1, subsh, p2, p2, -subsh+supsh); 66: printf("\\*(%d\\h'-\\n(%du+\\n(%du'\\v'%du'\n", 67: p3, p3, treg, -supsh); 68: ps += deltaps; 69: ofree(p2); ofree(p3); ofree(treg); 70: }