1*779fc935Sceastha /*
2*779fc935Sceastha * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3*779fc935Sceastha * Use is subject to license terms.
4*779fc935Sceastha */
5*779fc935Sceastha
67c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
77c478bd9Sstevel@tonic-gate /* All Rights Reserved */
87c478bd9Sstevel@tonic-gate
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California.
117c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement
127c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution.
137c478bd9Sstevel@tonic-gate */
147c478bd9Sstevel@tonic-gate
15*779fc935Sceastha #pragma ident "%Z%%M% %I% %E% SMI"
167c478bd9Sstevel@tonic-gate
177c478bd9Sstevel@tonic-gate #include "e.h"
187c478bd9Sstevel@tonic-gate
19*779fc935Sceastha void
lpile(int type,int p1,int p2)20*779fc935Sceastha lpile(int type, int p1, int p2)
21*779fc935Sceastha {
227c478bd9Sstevel@tonic-gate int bi, hi, i, gap, h, b, nlist, nlist2, mid;
237c478bd9Sstevel@tonic-gate yyval = oalloc();
247c478bd9Sstevel@tonic-gate #ifndef NEQN
257c478bd9Sstevel@tonic-gate gap = VERT(EM(0.4, ps)); /* 4/10 m between blocks */
26*779fc935Sceastha #else /* NEQN */
277c478bd9Sstevel@tonic-gate gap = VERT(1);
28*779fc935Sceastha #endif /* NEQN */
297c478bd9Sstevel@tonic-gate if (type == '-') gap = 0;
307c478bd9Sstevel@tonic-gate nlist = p2 - p1;
317c478bd9Sstevel@tonic-gate nlist2 = (nlist+1)/2;
327c478bd9Sstevel@tonic-gate mid = p1 + nlist2 -1;
337c478bd9Sstevel@tonic-gate h = 0;
347c478bd9Sstevel@tonic-gate for (i = p1; i < p2; i++)
357c478bd9Sstevel@tonic-gate h += eht[lp[i]];
367c478bd9Sstevel@tonic-gate eht[yyval] = h + (nlist-1)*gap;
377c478bd9Sstevel@tonic-gate b = 0;
387c478bd9Sstevel@tonic-gate for (i = p2-1; i > mid; i--)
397c478bd9Sstevel@tonic-gate b += eht[lp[i]] + gap;
407c478bd9Sstevel@tonic-gate #ifndef NEQN
41*779fc935Sceastha ebase[yyval] = (nlist%2) ? b + ebase[lp[mid]]
427c478bd9Sstevel@tonic-gate : b - VERT(EM(0.5, ps)) - gap;
43*779fc935Sceastha #else /* NEQN */
44*779fc935Sceastha ebase[yyval] = (nlist%2) ? b + ebase[lp[mid]]
457c478bd9Sstevel@tonic-gate : b - VERT(1) - gap;
46*779fc935Sceastha #endif /* NEQN */
477c478bd9Sstevel@tonic-gate if (dbg) {
487c478bd9Sstevel@tonic-gate printf(".\tS%d <- %c pile of:", yyval, type);
497c478bd9Sstevel@tonic-gate for (i = p1; i < p2; i++)
507c478bd9Sstevel@tonic-gate printf(" S%d", lp[i]);
517c478bd9Sstevel@tonic-gate printf(";h=%d b=%d\n", eht[yyval], ebase[yyval]);
527c478bd9Sstevel@tonic-gate }
537c478bd9Sstevel@tonic-gate nrwid(lp[p1], ps, lp[p1]);
547c478bd9Sstevel@tonic-gate printf(".nr %d \\n(%d\n", yyval, lp[p1]);
557c478bd9Sstevel@tonic-gate for (i = p1+1; i < p2; i++) {
567c478bd9Sstevel@tonic-gate nrwid(lp[i], ps, lp[i]);
577c478bd9Sstevel@tonic-gate printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n",
587c478bd9Sstevel@tonic-gate lp[i], yyval, yyval, lp[i]);
597c478bd9Sstevel@tonic-gate }
607c478bd9Sstevel@tonic-gate printf(".ds %d \\v'%du'\\h'%du*\\n(%du'\\\n", yyval, ebase[yyval],
617c478bd9Sstevel@tonic-gate type == 'R' ? 1 : 0, yyval);
627c478bd9Sstevel@tonic-gate for (i = p2-1; i >= p1; i--) {
637c478bd9Sstevel@tonic-gate hi = eht[lp[i]];
647c478bd9Sstevel@tonic-gate bi = ebase[lp[i]];
657c478bd9Sstevel@tonic-gate switch (type) {
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate case 'L':
687c478bd9Sstevel@tonic-gate printf("\\v'%du'\\*(%d\\h'-\\n(%du'\\v'0-%du'\\\n",
697c478bd9Sstevel@tonic-gate -bi, lp[i], lp[i], hi-bi+gap);
707c478bd9Sstevel@tonic-gate continue;
717c478bd9Sstevel@tonic-gate case 'R':
727c478bd9Sstevel@tonic-gate printf("\\v'%du'\\h'-\\n(%du'\\*(%d\\v'0-%du'\\\n",
737c478bd9Sstevel@tonic-gate -bi, lp[i], lp[i], hi-bi+gap);
747c478bd9Sstevel@tonic-gate continue;
757c478bd9Sstevel@tonic-gate case 'C':
767c478bd9Sstevel@tonic-gate case '-':
777c478bd9Sstevel@tonic-gate printf("\\v'%du'\\h'\\n(%du-\\n(%du/2u'\\*(%d",
787c478bd9Sstevel@tonic-gate -bi, yyval, lp[i], lp[i]);
797c478bd9Sstevel@tonic-gate printf("\\h'-\\n(%du-\\n(%du/2u'\\v'0-%du'\\\n",
807c478bd9Sstevel@tonic-gate yyval, lp[i], hi-bi+gap);
817c478bd9Sstevel@tonic-gate continue;
827c478bd9Sstevel@tonic-gate }
837c478bd9Sstevel@tonic-gate }
847c478bd9Sstevel@tonic-gate printf("\\v'%du'\\h'%du*\\n(%du'\n", eht[yyval]-ebase[yyval]+gap,
857c478bd9Sstevel@tonic-gate type != 'R' ? 1 : 0, yyval);
867c478bd9Sstevel@tonic-gate for (i = p1; i < p2; i++)
877c478bd9Sstevel@tonic-gate ofree(lp[i]);
887c478bd9Sstevel@tonic-gate lfont[yyval] = rfont[yyval] = 0;
897c478bd9Sstevel@tonic-gate }
90