1: #ifndef lint
   2: static char sccsid[] = "@(#)t8.c	4.2 8/11/83";
   3: #endif
   4: 
   5:  /* t8.c: write out one line of output table */
   6: # include "t..c"
   7: # define realsplit ((ct=='a'||ct=='n') && table[nl][c].rcol)
   8: int watchout;
   9: int once;
  10: int topat[MAXCOL];
  11: putline(i, nl)
  12:     /* i is line number for deciding format */
  13:     /* nl is line number for finding data   usually identical */
  14: {
  15: int c, lf, ct, form, lwid, vspf, ip, cmidx, exvspen, vforml;
  16: int vct, chfont;
  17: char *s, *size, *fn;
  18: watchout=vspf=exvspen=0;
  19: if (i==0) once=0;
  20: if (i==0 && ( allflg || boxflg || dboxflg))
  21:     fullwide(0,   dboxflg? '=' : '-');
  22: if (instead[nl]==0 && fullbot[nl] ==0)
  23: for(c=0; c<ncol; c++)
  24:     {
  25:     s = table[nl][c].col;
  26:     if (s==0) continue;
  27:     if (vspen(s))
  28:         {
  29:         for(ip=nl; ip<nlin; ip=next(ip))
  30:             if (!vspen(s=table[ip][c].col)) break;
  31:         if (s>0 && s<128)
  32:         fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n",s);
  33:         continue;
  34:         }
  35:     if (point(s)) continue;
  36:     fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n",s);
  37:     watchout=1;
  38:     }
  39: if (linestop[nl])
  40:     fprintf(tabout, ".mk #%c\n", linestop[nl]+'a'-1);
  41: lf = prev(nl);
  42: if (instead[nl])
  43:     {
  44:     puts(instead[nl]);
  45:     return;
  46:     }
  47: if (fullbot[nl])
  48:     {
  49:     switch (ct=fullbot[nl])
  50:         {
  51:         case '=':
  52:         case '-':
  53:             fullwide(nl,ct);
  54:         }
  55:     return;
  56:     }
  57: for(c=0; c<ncol; c++)
  58:     {
  59:     if (instead[nl]==0 && fullbot[nl]==0)
  60:     if (vspen(table[nl][c].col)) vspf=1;
  61:     if (lf>=0)
  62:         if (vspen(table[lf][c].col)) vspf=1;
  63:     }
  64: if (vspf)
  65:     {
  66:     fprintf(tabout, ".nr #^ \\n(\\*(#du\n");
  67:     fprintf(tabout, ".nr #- \\n(#^\n"); /* current line position relative to bottom */
  68:     }
  69: vspf=0;
  70: chfont=0;
  71: for(c=0; c<ncol; c++)
  72:     {
  73:     s = table[nl][c].col;
  74:     if (s==0) continue;
  75:     chfont |= (int)(font[stynum[nl]][c]);
  76:     if (point(s) ) continue;
  77:     lf=prev(nl);
  78:     if (lf>=0 && vspen(table[lf][c].col))
  79:         fprintf(tabout, ".if (\\n(%c|+\\n(^%c-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(^%c-\\n(#--1v)\n",s,'a'+c,s,'a'+c);
  80:     else
  81:         fprintf(tabout, ".if (\\n(%c|+\\n(#^-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(#^-\\n(#--1v)\n",s,s);
  82:     }
  83: if (allflg && once>0 )
  84:     fullwide(i,'-');
  85: once=1;
  86: runtabs(i, nl);
  87: if (allh(i) && !pr1403)
  88:     {
  89:     fprintf(tabout, ".nr %d \\n(.v\n", SVS);
  90:     fprintf(tabout, ".vs \\n(.vu-\\n(.sp\n");
  91:     }
  92: if (chfont)
  93:     fprintf(tabout, ".nr %2d \\n(.f\n", S1);
  94: fprintf(tabout, ".nr 35 1m\n");
  95: fprintf(tabout, "\\&");
  96: vct = 0;
  97: for(c=0; c<ncol; c++)
  98:     {
  99:     if (watchout==0 && i+1<nlin && (lf=left(i,c, &lwid))>=0)
 100:         {
 101:         tohcol(c);
 102:         drawvert(lf, i, c, lwid);
 103:         vct += 2;
 104:         }
 105:     if (rightl && c+1==ncol) continue;
 106:     vforml=i;
 107:     for(lf=prev(nl); lf>=0 && vspen(table[lf][c].col); lf=prev(lf))
 108:         vforml= lf;
 109:     form= ctype(vforml,c);
 110:     if (form != 's')
 111:         {
 112:         ct = c+CLEFT;
 113:         if (form=='a') ct = c+CMID;
 114:         if (form=='n' && table[nl][c].rcol && lused[c]==0) ct= c+CMID;
 115:         fprintf(tabout, "\\h'|\\n(%du'", ct);
 116:         }
 117:     s= table[nl][c].col;
 118:     fn = font[stynum[vforml]][c];
 119:     size = csize[stynum[vforml]][c];
 120:     if (*size==0)size=0;
 121:     switch(ct=ctype(vforml, c))
 122:         {
 123:         case 'n':
 124:         case 'a':
 125:             if (table[nl][c].rcol)
 126:                 {
 127:                if (lused[c]) /*Zero field width*/
 128:                 {
 129:                 ip = prev(nl);
 130:                 if (ip>=0)
 131:                 if (vspen(table[ip][c].col))
 132:                     {
 133:                     if (exvspen==0)
 134:                         {
 135:                         fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c+'a');
 136:                         if (cmidx)
 137:                             fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a');
 138:                         vct++;
 139:                         fprintf(tabout, "'");
 140:                         exvspen=1;
 141:                         }
 142:                     }
 143:                 fprintf(tabout, "%c%c",F1,F2);
 144:                 puttext(s,fn,size);
 145:                 fprintf(tabout, "%c",F1);
 146:                 }
 147:                 s= table[nl][c].rcol;
 148:                 form=1;
 149:                 break;
 150:                 }
 151:         case 'c':
 152:             form=3; break;
 153:         case 'r':
 154:             form=2; break;
 155:         case 'l':
 156:             form=1; break;
 157:         case '-':
 158:         case '=':
 159:             if (real(table[nl][c].col))
 160:                 fprintf(stderr,"%s: line %d: Data ignored on table line %d\n", ifile, iline-1, i+1);
 161:             makeline(i,c,ct);
 162:             continue;
 163:         default:
 164:             continue;
 165:         }
 166:     if (realsplit ? rused[c]: used[c]) /*Zero field width*/
 167:         {
 168:         /* form: 1 left, 2 right, 3 center adjust */
 169:         if (ifline(s))
 170:             {
 171:             makeline(i,c,ifline(s));
 172:             continue;
 173:             }
 174:         if (filler(s))
 175:             {
 176:             printf("\\l'|\\n(%du\\&%s'", c+CRIGHT, s+2);
 177:             continue;
 178:             }
 179:         ip = prev(nl);
 180:         cmidx = ctop[stynum[nl]][c]==0;
 181:         if (ip>=0)
 182:         if (vspen(table[ip][c].col))
 183:             {
 184:             if (exvspen==0)
 185:                 {
 186:                 fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c+'a');
 187:                 if (cmidx)
 188:                     fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a');
 189:                 vct++;
 190:                 fprintf(tabout, "'");
 191:                 }
 192:             }
 193:         fprintf(tabout, "%c", F1);
 194:         if (form!= 1)
 195:             fprintf(tabout, "%c", F2);
 196:         if (vspen(s))
 197:             vspf=1;
 198:         else
 199:         puttext(s, fn, size);
 200:         if (form !=2)
 201:             fprintf(tabout, "%c", F2);
 202:         fprintf(tabout, "%c", F1);
 203:         }
 204:     if (ip>=0)
 205:     if (vspen(table[ip][c].col))
 206:         {
 207:         exvspen = (c+1 < ncol) && vspen(table[ip][c+1].col) &&
 208:             (topat[c] == topat[c+1]) &&
 209:             (cmidx == (ctop [stynum[nl]][c+1]==0)) && (left(i,c+1,&lwid)<0);
 210:         if (exvspen==0)
 211:             {
 212:             fprintf(tabout, "\\v'(\\n(\\*(#du-\\n(^%cu", c+'a');
 213:             if (cmidx)
 214:                 fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a');
 215:             vct++;
 216:             fprintf(tabout, "'");
 217:             }
 218:         }
 219:     else
 220:         exvspen=0;
 221:     /* if lines need to be split for gcos here is the place for a backslash */
 222:     if (vct > 7 && c < ncol)
 223:         {
 224:         fprintf(tabout, "\n.sp-1\n\\&");
 225:         vct=0;
 226:         }
 227:     }
 228: fprintf(tabout, "\n");
 229: if (allh(i) && !pr1403) fprintf(tabout, ".vs \\n(%du\n", SVS);
 230: if (watchout)
 231:     funnies(i,nl);
 232: if (vspf)
 233:     {
 234:     for(c=0; c<ncol; c++)
 235:         if (vspen(table[nl][c].col) && (nl==0 || (lf=prev(nl))<0 || !vspen(table[lf][c].col)))
 236:             {
 237:             fprintf(tabout, ".nr ^%c \\n(#^u\n", 'a'+c);
 238:             topat[c]=nl;
 239:             }
 240:     }
 241: }
 242: puttext(s,fn, size)
 243:     char *s, *size, *fn;
 244: {
 245: if (point(s))
 246:     {
 247:     putfont(fn);
 248:     putsize(size);
 249:     fprintf(tabout, "%s",s);
 250:     if (*fn>0) fprintf(tabout, "\\f\\n(%2d", S1);
 251:     if (size!=0) putsize("0");
 252:     }
 253: }
 254: funnies( stl, lin)
 255: {
 256: /* write out funny diverted things */
 257: int c, s, pl, lwid, dv, lf, ct;
 258: char *fn;
 259: fprintf(tabout, ".mk ##\n"); /* rmember current vertical position */
 260: fprintf(tabout, ".nr %d \\n(##\n", S1); /* bottom position */
 261: for(c=0; c<ncol; c++)
 262:     {
 263:     s = (int)table[lin][c].col;
 264:     if (point(s)) continue;
 265:     if (s==0) continue;
 266:     fprintf(tabout, ".sp |\\n(##u-1v\n");
 267:     fprintf(tabout, ".nr %d ", SIND);
 268:     for(pl=stl; pl>=0 && !isalpha(ct=ctype(pl,c)); pl=prev(pl))
 269:         ;
 270:     switch (ct)
 271:         {
 272:         case 'n':
 273:         case 'c':
 274:             fprintf(tabout, "(\\n(%du+\\n(%du-\\n(%c-u)/2u\n",c+CLEFT,c-1+ctspan(lin,c)+CRIGHT, s);
 275:             break;
 276:         case 'l':
 277:             fprintf(tabout, "\\n(%du\n",c+CLEFT);
 278:             break;
 279:         case 'a':
 280:             fprintf(tabout, "\\n(%du\n",c+CMID);
 281:             break;
 282:         case 'r':
 283:             fprintf(tabout, "\\n(%du-\\n(%c-u\n", c+CRIGHT, s);
 284:             break;
 285:         }
 286:     fprintf(tabout, ".in +\\n(%du\n", SIND);
 287:     fn=font[stynum[stl]][c];
 288:     putfont(fn);
 289:     pl = prev(stl);
 290:     if (stl>0 && pl>=0 && vspen(table[pl][c].col))
 291:         {
 292:         fprintf(tabout, ".sp |\\n(^%cu\n", 'a'+c);
 293:         if (ctop[stynum[stl]][c]==0)
 294:             {
 295:             fprintf(tabout, ".nr %d \\n(#-u-\\n(^%c-\\n(%c|+1v\n",TMP, 'a'+c, s);
 296:             fprintf(tabout, ".if \\n(%d>0 .sp \\n(%du/2u\n", TMP, TMP);
 297:             }
 298:         }
 299:     fprintf(tabout, ".%c+\n",s);
 300:     fprintf(tabout, ".in -\\n(%du\n", SIND);
 301:     if (*fn>0) putfont("P");
 302:     fprintf(tabout, ".mk %d\n", S2);
 303:     fprintf(tabout, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n", S2, S1, S1, S2);
 304:     }
 305: fprintf(tabout, ".sp |\\n(%du\n", S1);
 306: for(c=dv=0; c<ncol; c++)
 307:     {
 308:     if (stl+1< nlin && (lf=left(stl,c,&lwid))>=0)
 309:         {
 310:         if (dv++ == 0)
 311:             fprintf(tabout, ".sp -1\n");
 312:         tohcol(c);
 313:         dv++;
 314:         drawvert(lf, stl, c, lwid);
 315:         }
 316:     }
 317: if (dv)
 318:     fprintf(tabout,"\n");
 319: }
 320: putfont(fn)
 321:     char *fn;
 322: {
 323: if (fn && *fn)
 324:     fprintf(tabout,  fn[1] ? "\\f(%.2s" : "\\f%.2s",  fn);
 325: }
 326: putsize(s)
 327:     char *s;
 328: {
 329: if (s && *s)
 330:     fprintf(tabout, "\\s%s",s);
 331: }

Defined functions

funnies defined in line 254; used 1 times
putfont defined in line 320; used 5 times
putline defined in line 11; used 4 times
putsize defined in line 326; used 4 times
puttext defined in line 242; used 2 times

Defined variables

once defined in line 9; used 3 times
sccsid defined in line 2; never used
topat defined in line 10; used 3 times
watchout defined in line 8; used 4 times

Defined macros

realsplit defined in line 7; used 1 times
Last modified: 1993-01-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3259
Valid CSS Valid XHTML 1.0 Strict