Annotation of researchv9/cmd/tbl/tu.c, revision 1.1

1.1     ! root        1:  /* tu.c: draws horizontal lines */
        !             2: # include "t..c"
        !             3: makeline(i,c,lintype)
        !             4: {
        !             5: int cr, type, shortl;
        !             6: type = thish(i,c);
        !             7: if (type==0) return;
        !             8: cr=c;
        !             9: shortl = (table[i][c].col[0]=='\\');
        !            10: if (c>0 && !shortl && thish(i,c-1) == type)return;
        !            11: if (shortl==0)
        !            12:        for(cr=c; cr < ncol && (ctype(i,cr)=='s'||type==thish(i,cr)); cr++);
        !            13: else
        !            14:        for(cr=c+1; cr<ncol && ctype(i,cr)=='s'; cr++);
        !            15: drawline(i, c, cr-1, lintype, 0, shortl);
        !            16: }
        !            17: fullwide(i, lintype)
        !            18: {
        !            19: int cr, cl;
        !            20: if (!pr1403)
        !            21:        fprintf(tabout, ".nr %d \\n(.v\n.vs \\n(.vu-\\n(.sp\n", SVS);
        !            22: cr= 0;
        !            23: while (cr<ncol)
        !            24:        {
        !            25:        cl=cr;
        !            26:        while (i>0 && vspand(prev(i),cl,1))
        !            27:                cl++;
        !            28:        for(cr=cl; cr<ncol; cr++)
        !            29:                if (i>0 && vspand(prev(i),cr,1))
        !            30:                        break;
        !            31:        if (cl<ncol)
        !            32:        drawline(i,cl,(cr<ncol?cr-1:cr),lintype,1,0);
        !            33:        }
        !            34: fprintf(tabout, "\n");
        !            35: if (!pr1403)
        !            36:        fprintf(tabout, ".vs \\n(%du\n", SVS);
        !            37: }
        !            38: 
        !            39: drawline(i, cl, cr, lintype, noheight, shortl)
        !            40: {
        !            41:        char *exhr, *exhl, *lnch;
        !            42:        int lcount, ln, linpos, oldpos, nodata;
        !            43: lcount=0;
        !            44: exhr=exhl= "";
        !            45: switch(lintype)
        !            46:        {
        !            47:        case '-': lcount=1;break;
        !            48:        case '=': lcount = pr1403? 1 : 2; break;
        !            49:        case SHORTLINE: lcount=1; break;
        !            50:        }
        !            51: if (lcount<=0) return;
        !            52: nodata = cr-cl>=ncol || noheight || allh(i);
        !            53:        if (!nodata)
        !            54:                fprintf(tabout, "\\v'-.5m'");
        !            55: for(ln=oldpos=0; ln<lcount; ln++)
        !            56:        {
        !            57:        linpos = 2*ln - lcount +1;
        !            58:        if (linpos != oldpos)
        !            59:                fprintf(tabout, "\\v'%dp'", linpos-oldpos);
        !            60:        oldpos=linpos;
        !            61:        if (shortl==0)
        !            62:        {
        !            63:        tohcol(cl);
        !            64:        if (lcount>1)
        !            65:                {
        !            66:                switch(interv(i,cl))
        !            67:                        {
        !            68:                        case TOP: exhl = ln==0 ? "1p" : "-1p"; break;
        !            69:                        case BOT: exhl = ln==1 ? "1p" : "-1p"; break;
        !            70:                        case THRU: exhl = "1p"; break;
        !            71:                        }
        !            72:                if (exhl[0])
        !            73:                fprintf(tabout, "\\h'%s'", exhl);
        !            74:                }
        !            75:        else if (lcount==1)
        !            76:                {
        !            77:                switch(interv(i,cl))
        !            78:                        {
        !            79:                        case TOP: case BOT: exhl = "-1p"; break;
        !            80:                        case THRU: exhl = "1p"; break;
        !            81:                        }
        !            82:                if (exhl[0])
        !            83:                fprintf(tabout, "\\h'%s'", exhl);
        !            84:                }
        !            85:        if (lcount>1)
        !            86:                {
        !            87:                switch(interv(i,cr+1))
        !            88:                        {
        !            89:                        case TOP: exhr = ln==0 ? "-1p" : "+1p"; break;
        !            90:                        case BOT: exhr = ln==1 ? "-1p" : "+1p"; break;
        !            91:                        case THRU: exhr = "-1p"; break;
        !            92:                        }
        !            93:                }
        !            94:        else if (lcount==1)
        !            95:                {
        !            96:                switch(interv(i,cr+1))
        !            97:                        {
        !            98:                        case TOP: case BOT: exhr = "+1p"; break;
        !            99:                        case THRU: exhr = "-1p"; break;
        !           100:                        }
        !           101:                }
        !           102:        }
        !           103:        else
        !           104:                fprintf(tabout, "\\h'|\\n(%2su'", reg(cl,CLEFT));
        !           105:        fprintf(tabout, "\\s\\n(%d",LSIZE);
        !           106:        if (linsize)
        !           107:                fprintf(tabout, "\\v'-\\n(%dp/6u'", LSIZE);
        !           108:        if (shortl)
        !           109:                fprintf(tabout, "\\l'|\\n(%2su'", reg(cr,CRIGHT));
        !           110:        else
        !           111:        {
        !           112:        lnch = "\\(ul";
        !           113:        if (pr1403)
        !           114:                lnch = lintype==2 ? "=" : "\\(ru";
        !           115:        if (cr+1>=ncol)
        !           116:                fprintf(tabout, "\\l'|\\n(TWu%s%s'", exhr,lnch);
        !           117:        else
        !           118:                fprintf(tabout, "\\l'(|\\n(%2su+|\\n(%2su)/2u%s%s'", reg(cr,CRIGHT),
        !           119:                        reg(cr+1,CLEFT), exhr, lnch);
        !           120:        }
        !           121:        if (linsize)
        !           122:                fprintf(tabout, "\\v'\\n(%dp/6u'", LSIZE);
        !           123:        fprintf(tabout, "\\s0");
        !           124:        }
        !           125: if (oldpos!=0)
        !           126:        fprintf(tabout, "\\v'%dp'", -oldpos);
        !           127: if (!nodata)
        !           128:        fprintf(tabout, "\\v'+.5m'");
        !           129: }
        !           130: getstop()
        !           131: {
        !           132: int i,c,k,junk, stopp;
        !           133: stopp=1;
        !           134: for(i=0; i<MAXLIN; i++)
        !           135:        linestop[i]=0;
        !           136: for(i=0; i<nlin; i++)
        !           137:        for(c=0; c<ncol; c++)
        !           138:                {
        !           139:                k = left(i,c,&junk);
        !           140:                if (k>=0 && linestop[k]==0)
        !           141:                        linestop[k]= ++stopp;
        !           142:                }
        !           143: if (boxflg || allflg || dboxflg)
        !           144:        linestop[0]=1;
        !           145: }
        !           146: left(i,c, lwidp)
        !           147:        int *lwidp;
        !           148: {
        !           149: int kind, li, lj;
        !           150:        /* returns -1 if no line to left */
        !           151:        /* returns number of line where it starts */
        !           152:        /* stores into lwid the kind of line */
        !           153: *lwidp=0;
        !           154: if (i<0) return(-1);
        !           155: kind = lefdata(i,c);
        !           156: if (kind==0) return(-1);
        !           157: if (i+1<nlin)
        !           158: if (lefdata(next(i),c)== kind) return(-1);
        !           159: while (i>=0 && lefdata(i,c)==kind)
        !           160:        i=prev(li=i);
        !           161: if (prev(li)== -1) li=0;
        !           162: *lwidp=kind;
        !           163: for(lj= i+1; lj<li; lj++)
        !           164:        if (instead[lj] && strcmp(instead[lj], ".TH")==0)
        !           165:                return(li);
        !           166: for(i= i+1; i<li; i++)
        !           167:        if (fullbot[i])
        !           168:                li=i;
        !           169: return(li);
        !           170: }
        !           171: lefdata(i,c)
        !           172: {
        !           173: int ck;
        !           174: if (i>=nlin) i=nlin-1;
        !           175: if (ctype(i,c) == 's')
        !           176:        {
        !           177:        for(ck=c; ctype(i,ck)=='s'; ck--);
        !           178:        if (thish(i,ck)==0)
        !           179:                return(0);
        !           180:        }
        !           181: i =stynum[i];
        !           182: i = lefline[c][i];
        !           183: if (i>0) return(i);
        !           184: if (dboxflg && c==0) return(2);
        !           185: if (allflg)return(1);
        !           186: if (boxflg && c==0) return(1);
        !           187: return(0);
        !           188: }
        !           189: next(i)
        !           190: {
        !           191: while (i+1 <nlin)
        !           192:        {
        !           193:        i++;
        !           194:        if (!fullbot[i] && !instead[i]) break;
        !           195:        }
        !           196: return(i);
        !           197: }
        !           198: prev(i)
        !           199: {
        !           200: while (--i >=0  && (fullbot[i] || instead[i]))
        !           201:        ;
        !           202: return(i);
        !           203: }

unix.superglobalmegacorp.com

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