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