Annotation of researchv10no/cmd/tbl/ot5.c, revision 1.1.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:                nlin++;
                     41:                nslin++;
                     42:                fullbot[nlin] = 0;
                     43:                instead[nlin] = (char *) 0;
                     44:                }
                     45:        table[nlin] = (struct colstr *) alocv((ncol+2)*sizeof(table[0][0]));
                     46:        if (cstore[1]==0)
                     47:        switch(cstore[0])
                     48:                {
                     49:                case '_': fullbot[nlin]= '-'; continue;
                     50:                case '=': fullbot[nlin]= '='; continue;
                     51:                }
                     52:        stynum[nlin] = nslin;
                     53:        nslin = min(nslin+1, nclin-1);
                     54:        for (icol = 0; icol <ncol; icol++)
                     55:                {
                     56:                table[nlin][icol].col = cstore;
                     57:                table[nlin][icol].rcol=0;
                     58:                ch=1;
                     59:                if (match(cstore, "T{")) /* text follows */
                     60:                        table[nlin][icol].col =
                     61:                                (char *)gettext(cstore, nlin, icol,
                     62:                                        font[icol][stynum[nlin]],
                     63:                                        csize[icol][stynum[nlin]]);
                     64:                else
                     65:                        {
                     66:                        for(; (ch= *cstore) != '\0' && ch != tab; cstore++)
                     67:                                        ;
                     68:                        *cstore++ = '\0';
                     69:                        switch(ctype(nlin,icol)) /* numerical or alpha, subcol */
                     70:                                {
                     71:                                case 'n':
                     72:                                        table[nlin][icol].rcol = maknew(table[nlin][icol].col);
                     73:                                        break;
                     74:                                case 'a':
                     75:                                        table[nlin][icol].rcol = table[nlin][icol].col;
                     76:                                        table[nlin][icol].col = "";
                     77:                                        break;
                     78:                                }
                     79:                        }
                     80:                while (ctype(nlin,icol+1)== 's') /* spanning */
                     81:                        table[nlin][++icol].col = "";
                     82:                if (ch == '\0') break;
                     83:                }
                     84:        while (++icol <ncol+2)
                     85:                {
                     86:                table[nlin][icol].col = "";
                     87:                table [nlin][icol].rcol=0;
                     88:                }
                     89:        while (*cstore != '\0')
                     90:                 cstore++;
                     91:        if (cstore-cspace > MAXCHS)
                     92:                cstore = cspace = chspace();
                     93:        }
                     94: last = cstore;
                     95: permute();
                     96: if (textflg) untext();
                     97: return;
                     98: }
                     99: nodata(il)
                    100: {
                    101: int c;
                    102: for (c=0; c<ncol;c++)
                    103:        {
                    104:        switch(ctype(il,c))
                    105:                {
                    106:                case 'c': case 'n': case 'r': case 'l': case 's': case 'a':
                    107:                        return(0);
                    108:                }
                    109:        }
                    110: return(1);
                    111: }
                    112: oneh(lin)
                    113: {
                    114: int k, icol;
                    115: k = ctype(lin,0);
                    116: for(icol=1; icol<ncol; icol++)
                    117:        {
                    118:        if (k != ctype(lin,icol))
                    119:                return(0);
                    120:        }
                    121: return(k);
                    122: }
                    123: # define SPAN "\\^"
                    124: permute()
                    125: {
                    126: int irow, jcol, is;
                    127: char *start, *strig;
                    128: for(jcol=0; jcol<ncol; jcol++)
                    129:        {
                    130:        for(irow=1; irow<nlin; irow++)
                    131:                {
                    132:                if (vspand(irow,jcol,0))
                    133:                        {
                    134:                        is = prev(irow);
                    135:                        if (is<0)
                    136:                                error("Vertical spanning in first row not allowed");
                    137:                        start = table[is][jcol].col;
                    138:                        strig = table[is][jcol].rcol;
                    139:                        while (irow<nlin &&vspand(irow,jcol,0))
                    140:                                irow++;
                    141:                        table[--irow][jcol].col = start;
                    142:                        table[irow][jcol].rcol = strig;
                    143:                        while (is<irow)
                    144:                                {
                    145:                                table[is][jcol].rcol =0;
                    146:                                table[is][jcol].col= SPAN;
                    147:                                is = next(is);
                    148:                                }
                    149:                        }
                    150:                }
                    151:        }
                    152: }
                    153: vspand(ir,ij,ifform)
                    154: {
                    155: if (ir<0) return(0);
                    156: if (ir>=nlin)return(0);
                    157: if (instead[ir]) return(0);
                    158: if (ifform==0 && ctype(ir,ij)=='^') return(1);
                    159: if (table[ir][ij].rcol!=0) return(0);
                    160: if (fullbot[ir]) return(0);
                    161: return(vspen(table[ir][ij].col));
                    162: }
                    163: vspen(s)
                    164:        char *s;
                    165: {
                    166: if (s==0) return(0);
                    167: if (!point(s)) return(0);
                    168: return(match(s, SPAN));
                    169: }

unix.superglobalmegacorp.com

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