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

Defined functions

gettbl defined in line 7; used 1 times
nodata defined in line 102; used 1 times
  • in line 38
oneh defined in line 115; used 1 times
  • in line 40
permute defined in line 127; used 1 times
  • in line 98
vspand defined in line 156; used 4 times
vspen defined in line 166; used 22 times

Defined variables

sccsid defined in line 2; never used

Defined macros

SPAN defined in line 126; used 2 times
Last modified: 1987-02-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2660
Valid CSS Valid XHTML 1.0 Strict