1: #ifndef lint
   2: static char sccsid[] = "@(#)t4.c	4.2 8/11/83";
   3: #endif
   4: 
   5:  /* t4.c: read table specification */
   6: # include "t..c"
   7: int oncol;
   8: getspec()
   9: {
  10: int icol, i;
  11: for(icol=0; icol<MAXCOL; icol++)
  12:     {
  13:     sep[icol]= -1;
  14:     evenup[icol]=0;
  15:     cll[icol][0]=0;
  16:     for(i=0; i<MAXHEAD; i++)
  17:         {
  18:         csize[i][icol][0]=0;
  19:         vsize[i][icol][0]=0;
  20:         font[i][icol][0] = lefline[i][icol] = 0;
  21:         ctop[i][icol]=0;
  22:         style[i][icol]= 'l';
  23:         }
  24:     }
  25: nclin=ncol=0;
  26: oncol =0;
  27: left1flg=rightl=0;
  28: readspec();
  29: fprintf(tabout, ".rm");
  30: for(i=0; i<ncol; i++)
  31:     fprintf(tabout, " %02d", 80+i);
  32: fprintf(tabout, "\n");
  33: }
  34: readspec()
  35: {
  36: int icol, c, sawchar, stopc, i;
  37: char sn[10], *snp, *temp;
  38: sawchar=icol=0;
  39: while (c=get1char())
  40:     {
  41:     switch(c)
  42:         {
  43:         default:
  44:             if (c != tab)
  45:             error("bad table specification character");
  46:         case ' ': /* note this is also case tab */
  47:             continue;
  48:         case '\n':
  49:             if(sawchar==0) continue;
  50:         case ',':
  51:         case '.': /* end of table specification */
  52:             ncol = max(ncol, icol);
  53:             if (lefline[nclin][ncol]>0) {ncol++; rightl++;};
  54:             if(sawchar)
  55:                 nclin++;
  56:             if (nclin>=MAXHEAD)
  57:                 error("too many lines in specification");
  58:             icol=0;
  59:             if (ncol==0 || nclin==0)
  60:                 error("no specification");
  61:             if (c== '.')
  62:                 {
  63:                 while ((c=get1char()) && c != '\n')
  64:                     if (c != ' ' && c != '\t')
  65:                         error("dot not last character on format line");
  66:                 /* fix up sep - default is 3 except at edge */
  67:                 for(icol=0; icol<ncol; icol++)
  68:                     if (sep[icol]<0)
  69:                         sep[icol] =  icol+1<ncol ? 3 : 1;
  70:                 if (oncol == 0)
  71:                     oncol = ncol;
  72:                 else if (oncol +2 <ncol)
  73:                     error("tried to widen table in T&, not allowed");
  74:                 return;
  75:                 }
  76:             sawchar=0;
  77:             continue;
  78:         case 'C': case 'S': case 'R': case 'N': case 'L':  case 'A':
  79:             c += ('a'-'A');
  80:         case '_': if (c=='_') c= '-';
  81:         case '=': case '-':
  82:         case '^':
  83:         case 'c': case 's': case 'n': case 'r': case 'l':  case 'a':
  84:             style[nclin][icol]=c;
  85:             if (c== 's' && icol<=0)
  86:                 error("first column can not be S-type");
  87:             if (c=='s' && style[nclin][icol-1] == 'a')
  88:                 {
  89:                 fprintf(tabout, ".tm warning: can't span a-type cols, changed to l\n");
  90:                 style[nclin][icol-1] = 'l';
  91:                 }
  92:             if (c=='s' && style[nclin][icol-1] == 'n')
  93:                 {
  94:                 fprintf(tabout, ".tm warning: can't span n-type cols, changed to c\n");
  95:                 style[nclin][icol-1] = 'c';
  96:                 }
  97:             icol++;
  98:             if (c=='^' && nclin<=0)
  99:                 error("first row can not contain vertical span");
 100:             if (icol>=MAXCOL)
 101:                 error("too many columns in table");
 102:             sawchar=1;
 103:             continue;
 104:         case 'b': case 'i':
 105:             c += 'A'-'a';
 106:         case 'B': case 'I':
 107:             if (icol==0) continue;
 108:             snp=font[nclin][icol-1];
 109:             snp[0]= (c=='I' ? '2' : '3');
 110:             snp[1]=0;
 111:             continue;
 112:         case 't': case 'T':
 113:             if (icol>0)
 114:             ctop[nclin][icol-1] = 1;
 115:             continue;
 116:         case 'd': case 'D':
 117:             if (icol>0)
 118:             ctop[nclin][icol-1] = -1;
 119:             continue;
 120:         case 'f': case 'F':
 121:             if (icol==0) continue;
 122:             snp=font[nclin][icol-1];
 123:             snp[0]=snp[1]=stopc=0;
 124:             for(i=0; i<2; i++)
 125:                 {
 126:                 c = get1char();
 127:                 if (i==0 && c=='(')
 128:                     {
 129:                     stopc=')';
 130:                     c = get1char();
 131:                     }
 132:                 if (c==0) break;
 133:                 if (c==stopc) {stopc=0; break;}
 134:                 if (stopc==0)  if (c==' ' || c== tab ) break;
 135:                 if (c=='\n'){un1getc(c); break;}
 136:                 snp[i] = c;
 137:                 if (c>= '0' && c<= '9') break;
 138:                 }
 139:             if (stopc) if (get1char()!=stopc)
 140:                 error("Nonterminated font name");
 141:             continue;
 142:         case 'P': case 'p':
 143:             if (icol<=0) continue;
 144:             temp = snp = csize[nclin][icol-1];
 145:             while (c = get1char())
 146:                 {
 147:                 if (c== ' ' || c== tab || c=='\n') break;
 148:                 if (c=='-' || c == '+')
 149:                     if (snp>temp)
 150:                         break;
 151:                     else
 152:                         *snp++=c;
 153:                 else
 154:                 if (digit(c))
 155:                     *snp++ = c;
 156:                 else break;
 157:                 if (snp-temp>4)
 158:                     error("point size too large");
 159:                 }
 160:             *snp = 0;
 161:             if (atoi(temp)>36)
 162:                 error("point size unreasonable");
 163:             un1getc (c);
 164:             continue;
 165:         case 'V': case 'v':
 166:             if (icol<=0) continue;
 167:             temp = snp = vsize[nclin][icol-1];
 168:             while (c = get1char())
 169:                 {
 170:                 if (c== ' ' || c== tab || c=='\n') break;
 171:                 if (c=='-' || c == '+')
 172:                     if (snp>temp)
 173:                         break;
 174:                     else
 175:                         *snp++=c;
 176:                 else
 177:                 if (digit(c))
 178:                     *snp++ = c;
 179:                 else break;
 180:                 if (snp-temp>4)
 181:                     error("vertical spacing value too large");
 182:                 }
 183:             *snp=0;
 184:             un1getc(c);
 185:             continue;
 186:         case 'w': case 'W':
 187:             snp = cll [icol-1];
 188:         /* Dale Smith didn't like this check - possible to have two text blocks
 189: 		   of different widths now ....
 190: 			if (*snp)
 191: 				{
 192: 				fprintf(tabout, "Ignored second width specification");
 193: 				continue;
 194: 				}
 195: 		/* end commented out code ... */
 196:             stopc=0;
 197:             while (c = get1char())
 198:                 {
 199:                 if (snp==cll[icol-1] && c=='(')
 200:                     {
 201:                     stopc = ')';
 202:                     continue;
 203:                     }
 204:                 if ( !stopc && (c>'9' || c< '0'))
 205:                     break;
 206:                 if (stopc && c== stopc)
 207:                     break;
 208:                 *snp++ =c;
 209:                 }
 210:             *snp=0;
 211:             if (snp-cll[icol-1]>CLLEN)
 212:                 error ("column width too long");
 213:             if (!stopc)
 214:                 un1getc(c);
 215:             continue;
 216:         case 'e': case 'E':
 217:             if (icol<1) continue;
 218:             evenup[icol-1]=1;
 219:             evenflg=1;
 220:             continue;
 221:         case '0': case '1': case '2': case '3': case '4':
 222:         case '5': case '6': case '7': case '8': case '9':
 223:             sn[0] = c;
 224:             snp=sn+1;
 225:             while (digit(*snp++ = c = get1char()))
 226:                 ;
 227:             un1getc(c);
 228:             sep[icol-1] = max(sep[icol-1], numb(sn));
 229:             continue;
 230:         case '|':
 231:             lefline[nclin][icol]++;
 232:             if (icol==0) left1flg=1;
 233:             continue;
 234:         }
 235:     }
 236: error("EOF reading table specification");
 237: }

Defined functions

getspec defined in line 8; used 1 times
readspec defined in line 34; used 2 times

Defined variables

oncol defined in line 7; used 4 times
sccsid defined in line 2; never used
Last modified: 1987-02-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1452
Valid CSS Valid XHTML 1.0 Strict