1 #ifndef lint 2 static char sccsid[] = "@(#)t7.c 4.3 08/11/83"; 3 #endif 4 5 /* t7.c: control to write table entries */ 6 # include "t..c" 7 # define realsplit ((ct=='a'||ct=='n') && table[ldata][c].rcol) 8 runout() 9 { 10 int i; 11 if (boxflg || allflg || dboxflg) need(); 12 if (ctrflg) 13 { 14 fprintf(tabout, ".nr #I \\n(.i\n"); 15 fprintf(tabout, ".in +(\\n(.lu-\\n(TWu-\\n(.iu)/2u\n"); 16 } 17 fprintf(tabout, ".fc %c %c\n", F1, F2); 18 fprintf(tabout, ".nr #T 0-1\n"); 19 deftail(); 20 for(i=0; i<nlin; i++) 21 putline(i,i); 22 if (leftover) 23 yetmore(); 24 fprintf(tabout, ".fc\n"); 25 fprintf(tabout, ".nr T. 1\n"); 26 fprintf(tabout, ".T# 1\n"); 27 if (ctrflg) 28 fprintf(tabout, ".in \\n(#Iu\n"); 29 } 30 runtabs(lform, ldata) 31 { 32 int c, ct, vforml, lf; 33 fprintf(tabout, ".ta "); 34 for(c=0; c<ncol; c++) 35 { 36 vforml=lform; 37 for(lf=prev(lform); lf>=0 && vspen(table[lf][c].col); lf=prev(lf)) 38 vforml=lf; 39 if (fspan(vforml,c)) 40 continue; 41 switch(ct=ctype(vforml,c)) 42 { 43 case 'n': 44 case 'a': 45 if (table[ldata][c].rcol) 46 if (lused[c]) /*Zero field width*/ 47 fprintf(tabout, "\\n(%du ",c+CMID); 48 case 'c': 49 case 'l': 50 case 'r': 51 if (realsplit? rused[c]: (used[c]+lused[c])) 52 fprintf(tabout, "\\n(%du ",c+CRIGHT); 53 continue; 54 case 's': 55 if (lspan(lform, c)) 56 fprintf(tabout, "\\n(%du ", c+CRIGHT); 57 continue; 58 } 59 } 60 fprintf(tabout, "\n"); 61 } 62 ifline(s) 63 char *s; 64 { 65 if (!point(s)) return(0); 66 if (s[0] == '\\') s++; 67 if (s[1] ) return(0); 68 if (s[0] == '_') return('-'); 69 if (s[0] == '=') return('='); 70 return(0); 71 } 72 need() 73 { 74 int texlin, horlin, i; 75 for(texlin=horlin=i=0; i<nlin; i++) 76 { 77 if (fullbot[i]!=0) 78 horlin++; 79 else 80 if (instead[i]!=0) 81 continue; 82 else 83 texlin++; 84 } 85 fprintf(tabout, ".ne %dv+%dp\n",texlin,2*horlin); 86 } 87 deftail() 88 { 89 int i, c, lf, lwid; 90 for(i=0; i<MAXHEAD; i++) 91 if (linestop[i]) 92 fprintf(tabout, ".nr #%c 0-1\n", linestop[i]+'a'-1); 93 fprintf(tabout, ".nr #a 0-1\n"); 94 fprintf(tabout, ".eo\n"); 95 fprintf(tabout, ".de T#\n"); 96 fprintf(tabout, ".ds #d .d\n"); 97 fprintf(tabout, ".if \\(ts\\n(.z\\(ts\\(ts .ds #d nl\n"); 98 fprintf(tabout, ".mk ##\n"); 99 fprintf(tabout, ".nr ## -1v\n"); 100 fprintf(tabout, ".ls 1\n"); 101 for(i=0; i<MAXHEAD; i++) 102 if (linestop[i]) 103 fprintf(tabout, ".if \\n(#T>=0 .nr #%c \\n(#T\n",linestop[i]+'a'-1); 104 if (boxflg || allflg || dboxflg) /* bottom of table line */ 105 if (fullbot[nlin-1]==0) 106 { 107 if (!pr1403) 108 fprintf(tabout, ".if \\n(T. .vs \\n(.vu-\\n(.sp\n"); 109 fprintf(tabout, ".if \\n(T. "); 110 drawline(nlin,0,ncol, dboxflg ? '=' : '-',1,0); 111 fprintf(tabout, "\n.if \\n(T. .vs\n"); 112 /* T. is really an argument to a macro but because of 113 eqn we don't dare pass it as an argument and reference by $1 */ 114 } 115 for(c=0; c<ncol; c++) 116 { 117 if ((lf=left(nlin-1,c, &lwid))>=0) 118 { 119 fprintf(tabout, ".if \\n(#%c>=0 .sp -1\n",linestop[lf]+'a'-1); 120 fprintf(tabout, ".if \\n(#%c>=0 ", linestop[lf]+'a'-1); 121 tohcol(c); 122 drawvert(lf, nlin-1, c, lwid); 123 fprintf(tabout, "\\h'|\\n(TWu'\n"); 124 } 125 } 126 if (boxflg || allflg || dboxflg) /* right hand line */ 127 { 128 fprintf(tabout, ".if \\n(#a>=0 .sp -1\n"); 129 fprintf(tabout, ".if \\n(#a>=0 \\h'|\\n(TWu'"); 130 drawvert (0, nlin-1, ncol, dboxflg? 2 : 1); 131 fprintf(tabout, "\n"); 132 } 133 fprintf(tabout, ".ls\n"); 134 fprintf(tabout, "..\n"); 135 fprintf(tabout, ".ec\n"); 136 } 137