Annotation of researchv9/cmd/eqn/pile.c, revision 1.1

1.1     ! root        1: #include "e.h"
        !             2: #include "y.tab.h"
        !             3: 
        !             4: pile(oct)
        !             5:        int oct;
        !             6: {
        !             7:        int i, nlist, nlist2, mid;
        !             8:        float bi, hi, h, b, gap, sb;
        !             9:        extern float Pilegap, Pilebase;
        !            10:        int type, p1, p2;
        !            11: 
        !            12:        yyval = salloc();
        !            13:        type = lp[oct];
        !            14:        p1 = oct + 3;           /* first entry */
        !            15:        p2 = p1 + lp[oct+1];    /* 1 after last */
        !            16:        gap = lp[oct+2];
        !            17:        if (gap != DEFGAP)
        !            18:                gap = EM(gap/100.0, ps);
        !            19:        else if (type == COL)
        !            20:                gap = 0;
        !            21:        else
        !            22:                gap = EM(Pilegap, ps);  /* 0.4 m between LCOL, etc. */
        !            23:        nlist = p2 - p1;
        !            24:        nlist2 = (nlist+1)/2;
        !            25:        mid = p1 + nlist2 - 1;
        !            26:        h = 0;
        !            27:        for (i = p1; i < p2; i++)
        !            28:                h += eht[lp[i]];
        !            29:        eht[yyval] = h + (nlist-1)*gap;
        !            30:        b = 0;
        !            31:        for (i = p2-1; i > mid; i--)
        !            32:                b += eht[lp[i]] + gap;
        !            33:        ebase[yyval] = (nlist%2) ? b + ebase[lp[mid]]
        !            34:                        : b - EM(Pilebase, ps) - gap;
        !            35:        if (dbg) {
        !            36:                printf(".\tS%d <- %d pile of:", yyval, type);
        !            37:                for (i = p1; i < p2; i++)
        !            38:                        printf(" S%d", lp[i]);
        !            39:                printf("; h=%g b=%g\n", eht[yyval], ebase[yyval]);
        !            40:        }
        !            41:        nrwid(lp[p1], ps, lp[p1]);
        !            42:        printf(".nr %d \\n(%d\n", yyval, lp[p1]);
        !            43:        for (i = p1+1; i < p2; i++) {
        !            44:                nrwid(lp[i], ps, lp[i]);
        !            45:                printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", 
        !            46:                        lp[i], yyval, yyval, lp[i]);
        !            47:        }
        !            48:        printf(".ds %d \\v'%gm'\\h'%du*\\n(%du'\\\n", yyval, REL(ebase[yyval],ps), 
        !            49:                type==RCOL ? 1 : 0, yyval);
        !            50:        sb = 0;         /* sum of box hts */
        !            51:        for (i = p2-1; i >= p1; i--) {
        !            52:                bi = sb + ebase[lp[i]];
        !            53:                switch (type) {
        !            54:                case LCOL:
        !            55:                        printf("\\v'%gm'\\*(%d\\h'-\\n(%du'\\v'%gm'\\\n", 
        !            56:                                REL(-bi,ps), lp[i], lp[i], REL(bi,ps));
        !            57:                        break;
        !            58:                case RCOL:
        !            59:                        printf("\\v'%gm'\\h'-\\n(%du'\\*(%d\\v'%gm'\\\n", 
        !            60:                                REL(-bi,ps), lp[i], lp[i], REL(bi,ps));
        !            61:                        break;
        !            62:                case CCOL:
        !            63:                case COL:
        !            64:                        printf("\\v'%gm'\\h'\\n(%du-\\n(%du/2u'\\*(%d", 
        !            65:                                REL(-bi,ps), yyval, lp[i], lp[i]);
        !            66:                        printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%gm'\\\n", 
        !            67:                                yyval, lp[i], REL(bi,ps));
        !            68:                        break;
        !            69:                }
        !            70:                sb += eht[lp[i]] + gap;
        !            71:        }
        !            72:        printf("\\v'%gm'\\h'%du*\\n(%du'\n", REL(-ebase[yyval],ps), 
        !            73:                type!=RCOL ? 1 : 0, yyval);
        !            74:        for (i = p1; i < p2; i++)
        !            75:                sfree(lp[i]);
        !            76:        lfont[yyval] = rfont[yyval] = 0;
        !            77: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.