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

1.1     ! root        1:  /* t5.c: read data for table */
        !             2: # include "t..c"
        !             3: gettbl()
        !             4: {
        !             5: extern char *chspace();
        !             6: extern char *maknew();
        !             7: int icol, ch;
        !             8: cstore=cspace= chspace();
        !             9: textflg=0;
        !            10: for (nlin=nslin=0; gets1(cstore); nlin++)
        !            11:        {
        !            12:        stynum[nlin]=nslin;
        !            13:        if (prefix(".TE", cstore))
        !            14:                {
        !            15:                leftover=0;
        !            16:                break;
        !            17:                }
        !            18:        if (prefix(".TC", cstore) || prefix(".T&", cstore))
        !            19:                {
        !            20:                readspec();
        !            21:                nslin++;
        !            22:                }
        !            23:        if (nlin>=MAXLIN)
        !            24:                {
        !            25:                leftover=(int)cstore;
        !            26:                break;
        !            27:                }
        !            28:        fullbot[nlin]=0;
        !            29:        if (cstore[0] == '.' && !isdigit(cstore[1]))
        !            30:                {
        !            31:                instead[nlin] = cstore;
        !            32:                while (*cstore++);
        !            33:                continue;
        !            34:                }
        !            35:        else instead[nlin] = 0;
        !            36:        if (nodata(nlin))
        !            37:                {
        !            38:                if (ch = oneh(nlin))
        !            39:                        fullbot[nlin]= ch;
        !            40:                table[nlin] = (struct colstr *) alocv((ncol+2)*sizeof(table[0][0]));
        !            41:                for(icol=0;icol<ncol;icol++){
        !            42:                        table[nlin][icol].rcol = "";
        !            43:                        table[nlin][icol].col = "";
        !            44:                }
        !            45:                nlin++;
        !            46:                nslin++;
        !            47:                fullbot[nlin] = 0;
        !            48:                instead[nlin] = (char *) 0;
        !            49:                }
        !            50:        table[nlin] = (struct colstr *) alocv((ncol+2)*sizeof(table[0][0]));
        !            51:        if (cstore[1]==0)
        !            52:        switch(cstore[0])
        !            53:                {
        !            54:                case '_': fullbot[nlin]= '-'; continue;
        !            55:                case '=': fullbot[nlin]= '='; continue;
        !            56:                }
        !            57:        stynum[nlin] = nslin;
        !            58:        nslin = min(nslin+1, nclin-1);
        !            59:        for (icol = 0; icol <ncol; icol++)
        !            60:                {
        !            61:                table[nlin][icol].col = cstore;
        !            62:                table[nlin][icol].rcol=0;
        !            63:                ch=1;
        !            64:                if (match(cstore, "T{")){ /* text follows */
        !            65:                        table[nlin][icol].col =
        !            66:                                (char *)gettext(cstore, nlin, icol,
        !            67:                                        font[icol][stynum[nlin]],
        !            68:                                        csize[icol][stynum[nlin]]);
        !            69:                }
        !            70:                else
        !            71:                        {
        !            72:                        for(; (ch= *cstore) != '\0' && ch != tab; cstore++)
        !            73:                                        ;
        !            74:                        *cstore++ = '\0';
        !            75:                        switch(ctype(nlin,icol)) /* numerical or alpha, subcol */
        !            76:                                {
        !            77:                                case 'n':
        !            78:                                        table[nlin][icol].rcol = maknew(table[nlin][icol].col);
        !            79:                                        break;
        !            80:                                case 'a':
        !            81:                                        table[nlin][icol].rcol = table[nlin][icol].col;
        !            82:                                        table[nlin][icol].col = "";
        !            83:                                        break;
        !            84:                                }
        !            85:                        }
        !            86:                while (ctype(nlin,icol+1)== 's') /* spanning */
        !            87:                        table[nlin][++icol].col = "";
        !            88:                if (ch == '\0') break;
        !            89:                }
        !            90:        while (++icol <ncol+2)
        !            91:                {
        !            92:                table[nlin][icol].col = "";
        !            93:                table [nlin][icol].rcol=0;
        !            94:                }
        !            95:        while (*cstore != '\0')
        !            96:                 cstore++;
        !            97:        if (cstore-cspace > MAXCHS)
        !            98:                cstore = cspace = chspace();
        !            99:        }
        !           100: last = cstore;
        !           101: permute();
        !           102: if (textflg) untext();
        !           103: return;
        !           104: }
        !           105: nodata(il)
        !           106: {
        !           107: int c;
        !           108: for (c=0; c<ncol;c++)
        !           109:        {
        !           110:        switch(ctype(il,c))
        !           111:                {
        !           112:                case 'c': case 'n': case 'r': case 'l': case 's': case 'a':
        !           113:                        return(0);
        !           114:                }
        !           115:        }
        !           116: return(1);
        !           117: }
        !           118: oneh(lin)
        !           119: {
        !           120: int k, icol;
        !           121: k = ctype(lin,0);
        !           122: for(icol=1; icol<ncol; icol++)
        !           123:        {
        !           124:        if (k != ctype(lin,icol))
        !           125:                return(0);
        !           126:        }
        !           127: return(k);
        !           128: }
        !           129: # define SPAN "\\^"
        !           130: permute()
        !           131: {
        !           132: int irow, jcol, is;
        !           133: char *start, *strig;
        !           134: for(jcol=0; jcol<ncol; jcol++)
        !           135:        {
        !           136:        for(irow=1; irow<nlin; irow++)
        !           137:                {
        !           138:                if (vspand(irow,jcol,0))
        !           139:                        {
        !           140:                        is = prev(irow);
        !           141:                        if (is<0)
        !           142:                                error("Vertical spanning in first row not allowed");
        !           143:                        start = table[is][jcol].col;
        !           144:                        strig = table[is][jcol].rcol;
        !           145:                        while (irow<nlin &&vspand(irow,jcol,0))
        !           146:                                irow++;
        !           147:                        table[--irow][jcol].col = start;
        !           148:                        table[irow][jcol].rcol = strig;
        !           149:                        while (is<irow)
        !           150:                                {
        !           151:                                table[is][jcol].rcol =0;
        !           152:                                table[is][jcol].col= SPAN;
        !           153:                                is = next(is);
        !           154:                                }
        !           155:                        }
        !           156:                }
        !           157:        }
        !           158: }
        !           159: vspand(ir,ij,ifform)
        !           160: {
        !           161: if (ir<0) return(0);
        !           162: if (ir>=nlin)return(0);
        !           163: if (instead[ir]) return(0);
        !           164: if (ifform==0 && ctype(ir,ij)=='^') return(1);
        !           165: if (table[ir][ij].rcol!=0) return(0);
        !           166: if (fullbot[ir]) return(0);
        !           167: return(vspen(table[ir][ij].col));
        !           168: }
        !           169: vspen(s)
        !           170:        char *s;
        !           171: {
        !           172: if (s==0) return(0);
        !           173: if (!point(s)) return(0);
        !           174: return(match(s, SPAN));
        !           175: }

unix.superglobalmegacorp.com

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