1*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 3*7c478bd9Sstevel@tonic-gate 4*7c478bd9Sstevel@tonic-gate 5*7c478bd9Sstevel@tonic-gate /* 6*7c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 7*7c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 8*7c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 9*7c478bd9Sstevel@tonic-gate */ 10*7c478bd9Sstevel@tonic-gate 11*7c478bd9Sstevel@tonic-gate /* 12*7c478bd9Sstevel@tonic-gate * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. 13*7c478bd9Sstevel@tonic-gate * All Rights Reserved. 14*7c478bd9Sstevel@tonic-gate */ 15*7c478bd9Sstevel@tonic-gate 16*7c478bd9Sstevel@tonic-gate #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ 17*7c478bd9Sstevel@tonic-gate 18*7c478bd9Sstevel@tonic-gate # include "e.h" 19*7c478bd9Sstevel@tonic-gate 20*7c478bd9Sstevel@tonic-gate lpile(type, p1, p2) int type, p1, p2; { 21*7c478bd9Sstevel@tonic-gate int bi, hi, i, gap, h, b, nlist, nlist2, mid; 22*7c478bd9Sstevel@tonic-gate yyval = oalloc(); 23*7c478bd9Sstevel@tonic-gate #ifndef NEQN 24*7c478bd9Sstevel@tonic-gate gap = VERT(EM(0.4, ps)); /* 4/10 m between blocks */ 25*7c478bd9Sstevel@tonic-gate #else NEQN 26*7c478bd9Sstevel@tonic-gate gap = VERT(1); 27*7c478bd9Sstevel@tonic-gate #endif NEQN 28*7c478bd9Sstevel@tonic-gate if( type=='-' ) gap = 0; 29*7c478bd9Sstevel@tonic-gate nlist = p2 - p1; 30*7c478bd9Sstevel@tonic-gate nlist2 = (nlist+1)/2; 31*7c478bd9Sstevel@tonic-gate mid = p1 + nlist2 -1; 32*7c478bd9Sstevel@tonic-gate h = 0; 33*7c478bd9Sstevel@tonic-gate for( i=p1; i<p2; i++ ) 34*7c478bd9Sstevel@tonic-gate h += eht[lp[i]]; 35*7c478bd9Sstevel@tonic-gate eht[yyval] = h + (nlist-1)*gap; 36*7c478bd9Sstevel@tonic-gate b = 0; 37*7c478bd9Sstevel@tonic-gate for( i=p2-1; i>mid; i-- ) 38*7c478bd9Sstevel@tonic-gate b += eht[lp[i]] + gap; 39*7c478bd9Sstevel@tonic-gate ebase[yyval] = (nlist%2) ? b + ebase[lp[mid]] 40*7c478bd9Sstevel@tonic-gate #ifndef NEQN 41*7c478bd9Sstevel@tonic-gate : b - VERT(EM(0.5, ps)) - gap; 42*7c478bd9Sstevel@tonic-gate #else NEQN 43*7c478bd9Sstevel@tonic-gate : b - VERT(1) - gap; 44*7c478bd9Sstevel@tonic-gate #endif NEQN 45*7c478bd9Sstevel@tonic-gate if(dbg) { 46*7c478bd9Sstevel@tonic-gate printf(".\tS%d <- %c pile of:", yyval, type); 47*7c478bd9Sstevel@tonic-gate for( i=p1; i<p2; i++) 48*7c478bd9Sstevel@tonic-gate printf(" S%d", lp[i]); 49*7c478bd9Sstevel@tonic-gate printf(";h=%d b=%d\n", eht[yyval], ebase[yyval]); 50*7c478bd9Sstevel@tonic-gate } 51*7c478bd9Sstevel@tonic-gate nrwid(lp[p1], ps, lp[p1]); 52*7c478bd9Sstevel@tonic-gate printf(".nr %d \\n(%d\n", yyval, lp[p1]); 53*7c478bd9Sstevel@tonic-gate for( i = p1+1; i<p2; i++ ) { 54*7c478bd9Sstevel@tonic-gate nrwid(lp[i], ps, lp[i]); 55*7c478bd9Sstevel@tonic-gate printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", 56*7c478bd9Sstevel@tonic-gate lp[i], yyval, yyval, lp[i]); 57*7c478bd9Sstevel@tonic-gate } 58*7c478bd9Sstevel@tonic-gate printf(".ds %d \\v'%du'\\h'%du*\\n(%du'\\\n", yyval, ebase[yyval], 59*7c478bd9Sstevel@tonic-gate type=='R' ? 1 : 0, yyval); 60*7c478bd9Sstevel@tonic-gate for(i = p2-1; i >=p1; i--) { 61*7c478bd9Sstevel@tonic-gate hi = eht[lp[i]]; 62*7c478bd9Sstevel@tonic-gate bi = ebase[lp[i]]; 63*7c478bd9Sstevel@tonic-gate switch(type) { 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate case 'L': 66*7c478bd9Sstevel@tonic-gate printf("\\v'%du'\\*(%d\\h'-\\n(%du'\\v'0-%du'\\\n", 67*7c478bd9Sstevel@tonic-gate -bi, lp[i], lp[i], hi-bi+gap); 68*7c478bd9Sstevel@tonic-gate continue; 69*7c478bd9Sstevel@tonic-gate case 'R': 70*7c478bd9Sstevel@tonic-gate printf("\\v'%du'\\h'-\\n(%du'\\*(%d\\v'0-%du'\\\n", 71*7c478bd9Sstevel@tonic-gate -bi, lp[i], lp[i], hi-bi+gap); 72*7c478bd9Sstevel@tonic-gate continue; 73*7c478bd9Sstevel@tonic-gate case 'C': 74*7c478bd9Sstevel@tonic-gate case '-': 75*7c478bd9Sstevel@tonic-gate printf("\\v'%du'\\h'\\n(%du-\\n(%du/2u'\\*(%d", 76*7c478bd9Sstevel@tonic-gate -bi, yyval, lp[i], lp[i]); 77*7c478bd9Sstevel@tonic-gate printf("\\h'-\\n(%du-\\n(%du/2u'\\v'0-%du'\\\n", 78*7c478bd9Sstevel@tonic-gate yyval, lp[i], hi-bi+gap); 79*7c478bd9Sstevel@tonic-gate continue; 80*7c478bd9Sstevel@tonic-gate } 81*7c478bd9Sstevel@tonic-gate } 82*7c478bd9Sstevel@tonic-gate printf("\\v'%du'\\h'%du*\\n(%du'\n", eht[yyval]-ebase[yyval]+gap, 83*7c478bd9Sstevel@tonic-gate type!='R' ? 1 : 0, yyval); 84*7c478bd9Sstevel@tonic-gate for( i=p1; i<p2; i++ ) 85*7c478bd9Sstevel@tonic-gate ofree(lp[i]); 86*7c478bd9Sstevel@tonic-gate lfont[yyval] = rfont[yyval] = 0; 87*7c478bd9Sstevel@tonic-gate } 88