int thish(int i, int c) { int t; char *s; struct colstr *pc; if (c<0)return(0); if (i<0) return(0); t = ctype(i,c); if (t=='_' || t == '-') return('-'); if (t=='=')return('='); if (t=='^') return(1); if (fullbot[i] ) return(fullbot[i]); if (t=='s') return(thish(i,c-1)); if (t==0) return(1); pc = &table[i][c]; s = (t=='a' ? pc->rcol : pc->col); if (s==0 || (point(s) && *s==0)) return(1); if (vspen(s)) return(1); if (t=barent( s)) return(t); return(0); }
void runtabs(int lform, int ldata) { int c, ct, vforml, lf; fprintf(tabout, ".ta "); for(c=0; c<ncol; c++) { vforml=lform; for(lf=prev(lform); lf>=0 && vspen(table[lf][c].col); lf=prev(lf)) vforml=lf; if (fspan(vforml,c)) continue; switch(ct=ctype(vforml,c)) { case 'n': case 'a': if (table[ldata][c].rcol) if (lused[c]) /*Zero field width*/ fprintf(tabout, "\\n(%du ",c+CMID); case 'c': case 'l': case 'r': if (realsplit? rused[c]: (used[c]+lused[c])) fprintf(tabout, "\\n(%du ",c+CRIGHT); continue; case 's': if (lspan(lform, c)) fprintf(tabout, "\\n(%du ", c+CRIGHT); continue; } } fprintf(tabout, "\n"); }
vspand(ir,ij,ifform) { if (ir<0) return(0); if (ir>=nlin)return(0); if (instead[ir]) return(0); if (ifform==0 && ctype(ir,ij)=='^') return(1); if (table[ir][ij].rcol!=0) return(0); if (fullbot[ir]) return(0); return(vspen(table[ir][ij].col)); }
void maktab(void) { # define FN(i,c) font[stynum[i]][c] # define SZ(i,c) csize[stynum[i]][c] /* define the tab stops of the table */ int icol, ilin, tsep, k, ik, vforml, il, text; int doubled[MAXCOL], acase[MAXCOL]; char *s; char space[40]; for(icol=0; icol <ncol; icol++) { doubled[icol] = acase[icol] = 0; fprintf(tabout, ".nr %d 0\n", icol+CRIGHT); for(text=0; text<2; text++) { if (text) { warnoff(); fprintf(tabout, ".%02d\n.rm %02d\n", icol+80, icol+80); warnon(); } for(ilin=0; ilin<nlin; ilin++) { if (instead[ilin]|| fullbot[ilin]) continue; vforml=ilin; for(il=prev(ilin); il>=0 && vspen(table[il][icol].col); il=prev(il)) vforml=il; if (fspan(vforml,icol)) continue; if (filler(table[ilin][icol].col)) continue; switch(ctype(vforml,icol)) { case 'a': acase[icol]=1; s = table[ilin][icol].col; if (tx(s) && text) { if (doubled[icol]==0) fprintf(tabout, ".nr %d 0\n.nr %d 0\n",S1,S2); doubled[icol]=1; nreg(space, sizeof(space), s, '-'); fprintf(tabout, ".if %s>\\n(%d .nr %d %s\n",space,S2,S2,space); } case 'n': if (table[ilin][icol].rcol!=0) { if (doubled[icol]==0 && text==0) fprintf(tabout, ".nr %d 0\n.nr %d 0\n", S1, S2); doubled[icol]=1; if (real(s=table[ilin][icol].col) && !vspen(s)) { if (tx(s) != text) continue; fprintf(tabout, ".nr %d ", TMP); wide(s, FN(vforml,icol), SZ(vforml,icol)); fprintf(tabout, "\n"); fprintf(tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", S1, TMP, S1, TMP); } if (text==0 && real(s=table[ilin][icol].rcol) && !vspen(s) && !barent(s)) { fprintf(tabout, ".nr %d \\w%c%s%c\n",TMP, F1, s, F1); fprintf(tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n",S2,TMP,S2,TMP); } continue; } case 'r': case 'c': case 'l': if (real(s=table[ilin][icol].col) && !vspen(s)) { if (tx(s) != text) continue; fprintf(tabout, ".nr %d ", TMP); wide(s, FN(vforml,icol), SZ(vforml,icol)); fprintf(tabout, "\n"); fprintf(tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", icol+CRIGHT, TMP, icol+CRIGHT, TMP); } } } } if (acase[icol]) { fprintf(tabout, ".if \\n(%d>=\\n(%d .nr %d \\n(%du+2n\n",S2,icol+CRIGHT,icol+CRIGHT,S2); } if (doubled[icol]) { fprintf(tabout, ".nr %d \\n(%d\n", icol+CMID, S1); fprintf(tabout, ".nr %d \\n(%d+\\n(%d\n",TMP,icol+CMID,S2); fprintf(tabout, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n",TMP,icol+CRIGHT,icol+CRIGHT,TMP); fprintf(tabout, ".if \\n(%d<\\n(%d .nr %d +(\\n(%d-\\n(%d)/2\n",TMP,icol+CRIGHT,icol+CMID,icol+CRIGHT,TMP); } if (cll[icol][0]) { fprintf(tabout, ".nr %d %sn\n", TMP, cll[icol]); fprintf(tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n",icol+CRIGHT, TMP, icol+CRIGHT, TMP); } for(ilin=0; ilin<nlin; ilin++) if ((k=lspan(ilin, icol))) { s=table[ilin][icol-k].col; if (!real(s) || barent(s) || vspen(s) ) continue; fprintf(tabout, ".nr %d ", TMP); wide(table[ilin][icol-k].col, FN(ilin,icol-k), SZ(ilin,icol-k)); for(ik=k; ik>=0; ik--) { fprintf(tabout, "-\\n(%d",CRIGHT+icol-ik); if (!expflg && ik>0) fprintf(tabout, "-%dn", sep[icol-ik]); } fprintf(tabout, "\n"); fprintf(tabout, ".if \\n(%d>0 .nr %d \\n(%d/%d\n", TMP, TMP, TMP, k); fprintf(tabout, ".if \\n(%d<0 .nr %d 0\n", TMP, TMP); for(ik=0; ik<k; ik++) { if (doubled[icol-k+ik]) fprintf(tabout, ".nr %d +\\n(%d/2\n", icol-k+ik+CMID, TMP); fprintf(tabout, ".nr %d +\\n(%d\n", icol-k+ik+CRIGHT, TMP); } } } if (textflg) untext(); /* if even requested, make all columns widest width */ # define TMP1 S1 # define TMP2 S2 if (evenflg) { fprintf(tabout, ".nr %d 0\n", TMP); for(icol=0; icol<ncol; icol++) { if (evenup[icol]==0) continue; fprintf(tabout, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n", icol+CRIGHT, TMP, TMP, icol+CRIGHT); } for(icol=0; icol<ncol; icol++) { if (evenup[icol]==0) /* if column not evened just retain old interval */ continue; if (doubled[icol]) fprintf(tabout, ".nr %d (100*\\n(%d/\\n(%d)*\\n(%d/100\n", icol+CMID, icol+CMID, icol+CRIGHT, TMP); /* that nonsense with the 100's and parens tries to avoid overflow while proportionally shifting the middle of the number */ fprintf(tabout, ".nr %d \\n(%d\n", icol+CRIGHT, TMP); } } /* now adjust for total table width */ for(tsep=icol=0; icol<ncol; icol++) tsep+= sep[icol]; if (expflg) { fprintf(tabout, ".nr %d 0", TMP); for(icol=0; icol<ncol; icol++) fprintf(tabout, "+\\n(%d", icol+CRIGHT); fprintf(tabout, "\n"); fprintf(tabout, ".nr %d \\n(.l-\\n(.i-\\n(%d%s\n", TMP, TMP, (utf8 || tlp) && (boxflg || dboxflg || allflg) ? "-1n" : ""); if (boxflg || dboxflg || allflg) tsep += 1; else tsep -= sep[ncol-1]; fprintf(tabout, ".nr %d \\n(%d/%d\n", TMP, TMP, tsep); fprintf(tabout, ".if \\n(%d<1n .nr %d 1n\n", TMP, TMP); } else if (xcolflg) { fprintf(tabout, ".nr %d 0", TMP); for(icol=0; icol<ncol; icol++) fprintf(tabout, "+\\n(%d", icol+CRIGHT); fprintf(tabout, "\n"); fprintf(tabout, ".nr %d \\n(.l-\\n(.i-\\n(%d-%dn/%d\n", TMP, TMP, tsep + ((boxflg || dboxflg || allflg) ? (utf8 || tlp) ? 2 : 1 : -1), xcolflg); for(icol=0; icol<ncol; icol++) { if (!xcol[icol]) continue; fprintf(tabout, ".nr %d +\\n(%d\n", icol+CRIGHT, TMP); } fprintf(tabout, ".nr %d 1n\n", TMP); } else fprintf(tabout, ".nr %d 1n\n", TMP); fprintf(tabout, ".nr %d 0\n",CRIGHT-1); tsep= (boxflg || allflg || dboxflg || left1flg) ? 1 : 0; for(icol=0; icol<ncol; icol++) { fprintf(tabout, ".nr %d \\n(%d+(%d*\\n(%d)\n",icol+CLEFT, icol+CRIGHT-1, tsep, TMP); fprintf(tabout, ".nr %d +\\n(%d\n",icol+CRIGHT, icol+CLEFT); if (doubled[icol]) { /* the next line is last-ditch effort to avoid zero field width */ /*fprintf(tabout, ".if \\n(%d=0 .nr %d 1\n",icol+CMID, icol+CMID);*/ fprintf(tabout, ".nr %d +\\n(%d\n", icol+CMID, icol+CLEFT); /* fprintf(tabout, ".if n .if \\n(%d%%24>0 .nr %d +12u\n",icol+CMID, icol+CMID); */ } tsep=sep[icol]; } if (rightl) fprintf(tabout, ".nr %d (\\n(%d+\\n(%d)/2\n",ncol+CRIGHT-1, ncol+CLEFT-1, ncol+CRIGHT-2); fprintf(tabout, ".nr TW \\n(%d\n", ncol+CRIGHT-1); if (boxflg || allflg || dboxflg) fprintf(tabout, ".nr TW +%d*\\n(%d\n", sep[ncol-1], TMP); fprintf(tabout, ".if t .if \\n(TW>\\n(.l .tm Table at line %d file %s is too wide - \\n(TW units\n", iline-1, ifile); return; }
void maktab(void) /* define the tab stops of the table */ { int icol, ilin, tsep, k, ik, vforml, il, s, text; char *ss; for (icol = 0; icol < ncol; icol++) { doubled[icol] = acase[icol] = 0; Bprint(&tabout, ".nr %2s 0\n", reg(icol, CRIGHT)); for (text = 0; text < 2; text++) { if (text) Bprint(&tabout, ".%2s\n.rm %2s\n", reg(icol, CRIGHT), reg(icol, CRIGHT)); for (ilin = 0; ilin < nlin; ilin++) { if (instead[ilin] || fullbot[ilin]) continue; vforml = ilin; for (il = prev(ilin); il >= 0 && vspen(table[il][icol].col); il = prev(il)) vforml = il; if (fspan(vforml, icol)) continue; if (filler(table[ilin][icol].col)) continue; if ((flags[icol][stynum[ilin]] & ZEROW) != 0) continue; switch (ctype(vforml, icol)) { case 'a': acase[icol] = 1; ss = table[ilin][icol].col; s = (int)(uintptr)ss; if (s > 0 && s < 128 && text) { if (doubled[icol] == 0) Bprint(&tabout, ".nr %d 0\n.nr %d 0\n", S1, S2); doubled[icol] = 1; Bprint(&tabout, ".if \\n(%c->\\n(%d .nr %d \\n(%c-\n", s, S2, S2, (int)s); } case 'n': if (table[ilin][icol].rcol != 0) { if (doubled[icol] == 0 && text == 0) Bprint(&tabout, ".nr %d 0\n.nr %d 0\n", S1, S2); doubled[icol] = 1; if (real(ss = table[ilin][icol].col) && !vspen(ss)) { s = (int)(uintptr)ss; if (tx(s) != text) continue; Bprint(&tabout, ".nr %d ", TMP); wide(ss, FN(vforml, icol), SZ(vforml, icol)); Bprint(&tabout, "\n"); Bprint(&tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", S1, TMP, S1, TMP); } if (text == 0 && real(ss = table[ilin][icol].rcol) && !vspen(ss) && !barent(ss)) { Bprint(&tabout, ".nr %d \\w%c%s%c\n", TMP, F1, ss, F1); Bprint(&tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", S2, TMP, S2, TMP); } continue; } case 'r': case 'c': case 'l': if (real(ss = table[ilin][icol].col) && !vspen(ss)) { s = (int)(uintptr)ss; if (tx(s) != text) continue; Bprint(&tabout, ".nr %d ", TMP); wide(ss, FN(vforml, icol), SZ(vforml, icol)); Bprint(&tabout, "\n"); Bprint(&tabout, ".if \\n(%2s<\\n(%d .nr %2s \\n(%d\n", reg(icol, CRIGHT), TMP, reg(icol, CRIGHT), TMP); } } } } if (acase[icol]) { Bprint(&tabout, ".if \\n(%d>=\\n(%2s .nr %2s \\n(%du+2n\n", S2, reg(icol, CRIGHT), reg(icol, CRIGHT), S2); } if (doubled[icol]) { Bprint(&tabout, ".nr %2s \\n(%d\n", reg(icol, CMID), S1); Bprint(&tabout, ".nr %d \\n(%2s+\\n(%d\n", TMP, reg(icol, CMID), S2); Bprint(&tabout, ".if \\n(%d>\\n(%2s .nr %2s \\n(%d\n", TMP, reg(icol, CRIGHT), reg(icol, CRIGHT), TMP); Bprint(&tabout, ".if \\n(%d<\\n(%2s .nr %2s +(\\n(%2s-\\n(%d)/2\n", TMP, reg(icol, CRIGHT), reg(icol, CMID), reg(icol, CRIGHT), TMP); } if (cll[icol][0]) { Bprint(&tabout, ".nr %d %sn\n", TMP, cll[icol]); Bprint(&tabout, ".if \\n(%2s<\\n(%d .nr %2s \\n(%d\n", reg(icol, CRIGHT), TMP, reg(icol, CRIGHT), TMP); } for (ilin = 0; ilin < nlin; ilin++) if (k = lspan(ilin, icol)) { ss = table[ilin][icol-k].col; if (!real(ss) || barent(ss) || vspen(ss) ) continue; Bprint(&tabout, ".nr %d ", TMP); wide(table[ilin][icol-k].col, FN(ilin, icol - k), SZ(ilin, icol - k)); for (ik = k; ik >= 0; ik--) { Bprint(&tabout, "-\\n(%2s", reg(icol - ik, CRIGHT)); if (!expflg && ik > 0) Bprint(&tabout, "-%dn", sep[icol-ik]); } Bprint(&tabout, "\n"); Bprint(&tabout, ".if \\n(%d>0 .nr %d \\n(%d/%d\n", TMP, TMP, TMP, k); Bprint(&tabout, ".if \\n(%d<0 .nr %d 0\n", TMP, TMP); for (ik = 1; ik <= k; ik++) { if (doubled[icol-k+ik]) Bprint(&tabout, ".nr %2s +\\n(%d/2\n", reg(icol - k + ik, CMID), TMP); Bprint(&tabout, ".nr %2s +\\n(%d\n", reg(icol - k + ik, CRIGHT), TMP); } } } if (textflg) untext(); /* if even requested, make all columns widest width */ if (evenflg) { Bprint(&tabout, ".nr %d 0\n", TMP); for (icol = 0; icol < ncol; icol++) { if (evenup[icol] == 0) continue; Bprint(&tabout, ".if \\n(%2s>\\n(%d .nr %d \\n(%2s\n", reg(icol, CRIGHT), TMP, TMP, reg(icol, CRIGHT)); } for (icol = 0; icol < ncol; icol++) { if (evenup[icol] == 0) /* if column not evened just retain old interval */ continue; if (doubled[icol]) Bprint(&tabout, ".nr %2s (100*\\n(%2s/\\n(%2s)*\\n(%d/100\n", reg(icol, CMID), reg(icol, CMID), reg(icol, CRIGHT), TMP); /* that nonsense with the 100's and parens tries to avoid overflow while proportionally shifting the middle of the number */ Bprint(&tabout, ".nr %2s \\n(%d\n", reg(icol, CRIGHT), TMP); } } /* now adjust for total table width */ for (tsep = icol = 0; icol < ncol; icol++) tsep += sep[icol]; if (expflg) { Bprint(&tabout, ".nr %d 0", TMP); for (icol = 0; icol < ncol; icol++) Bprint(&tabout, "+\\n(%2s", reg(icol, CRIGHT)); Bprint(&tabout, "\n"); Bprint(&tabout, ".nr %d \\n(.l-\\n(%d\n", TMP, TMP); if (boxflg || dboxflg || allflg) /* tsep += 1; */ {} else tsep -= sep[ncol-1]; Bprint(&tabout, ".nr %d \\n(%d/%d\n", TMP, TMP, tsep); Bprint(&tabout, ".if \\n(%d<0 .nr %d 0\n", TMP, TMP); } else Bprint(&tabout, ".nr %d 1n\n", TMP); Bprint(&tabout, ".nr %2s 0\n", reg(-1, CRIGHT)); tsep = (boxflg || allflg || dboxflg || left1flg) ? 2 : 0; if (sep[-1] >= 0) tsep = sep[-1]; for (icol = 0; icol < ncol; icol++) { Bprint(&tabout, ".nr %2s \\n(%2s+((%d*\\n(%d)/2)\n", reg(icol, CLEFT), reg(icol - 1, CRIGHT), tsep, TMP); Bprint(&tabout, ".nr %2s +\\n(%2s\n", reg(icol, CRIGHT), reg(icol, CLEFT)); if (doubled[icol]) { /* the next line is last-ditch effort to avoid zero field width */ /*Bprint(&tabout, ".if \\n(%2s=0 .nr %2s 1\n",reg(icol,CMID), reg(icol,CMID));*/ Bprint(&tabout, ".nr %2s +\\n(%2s\n", reg(icol, CMID), reg(icol, CLEFT)); /* Bprint(&tabout, ".if n .if \\n(%s%%24>0 .nr %s +12u\n",reg(icol,CMID), reg(icol,CMID)); */ } tsep = sep[icol] * 2; } if (rightl) Bprint(&tabout, ".nr %s (\\n(%s+\\n(%s)/2\n", reg(ncol - 1, CRIGHT), reg(ncol - 1, CLEFT), reg(ncol - 2, CRIGHT)); Bprint(&tabout, ".nr TW \\n(%2s\n", reg(ncol - 1, CRIGHT)); tsep = sep[ncol-1]; if (boxflg || allflg || dboxflg) Bprint(&tabout, ".nr TW +((%d*\\n(%d)/2)\n", tsep, TMP); Bprint(&tabout, ".if t .if (\\n(TW>\\n(.l .tm Table at line %d file %s is too wide - \\n(TW units\n", iline - 1, ifile); /* * Used to be: ".if t .if (\\n(TW+\\n(.o)>7.65i .tm Table at line %d file %s is too wide - \\n(TW units\n", iline - 1, ifile); * but that gives warnings where none are necessary (or desired) [sape] */ }
/* * define the tab stops of the table */ maktab() { int icol, ilin, tsep, k, ik, vforml, il, text; int doubled[MAXCOL], acase[MAXCOL]; char *s; for(icol = 0; icol < ncol; icol++){ doubled[icol] = acase[icol] = 0; printf(".nr %2s 0\n", reg(icol, CRIGHT)); for(text = 0; text < 2; text++){ if(text) printf(".%2s\n.rm %2s\n", reg(icol, CRIGHT), reg(icol, CRIGHT)); for(ilin = 0; ilin < nlin; ilin++){ if(instead[ilin] || fullbot[ilin]){ continue; } vforml = ilin; for(il = prev(ilin); il >= 0 && vspen(table[il][icol].col); il = prev(il)) vforml = il; if(fspan(vforml, icol)){ continue; } if(filler(table[ilin][icol].col)){ continue; } if((ctop[stynum[ilin]][icol] & ZEROW) != 0){ continue; } switch(ctype(vforml, icol)){ case 'a': acase[icol] = 1; s = table[ilin][icol].col; if(s > 0 && s < (char *)128 && text){ if(doubled[icol] == 0) printf( ".nr %d 0\n.nr %d 0\n", S1, S2); doubled[icol] = 1; printf( ".if \\n(%c->\\n(%d .nr %d \\n(%c-\n", s, S2, S2, s); } case 'n': if(table[ilin][icol].rcol != 0){ if(doubled[icol] == 0 && text == 0) printf( ".nr %d 0\n.nr %d 0\n", S1, S2); doubled[icol] = 1; if(real(s=table[ilin][icol].col) && !vspen(s)){ if(tx((int)s) != text) continue; printf(".nr %d ", TMP); wide(s, FN(vforml, icol), SZ(vforml, icol)); printf("\n"); printf( ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", S1, TMP, S1, TMP); } if(text == 0 && real(s=table[ilin][icol].rcol) && !vspen(s) && !barent(s)){ printf( ".nr %d \\w%c%s%c\n", TMP, F1, s, F1); printf( ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", S2, TMP, S2, TMP); } continue; } case 'r': case 'c': case 'l': if(real(s = table[ilin][icol].col) && !vspen(s)){ if(tx((int)s) != text) continue; printf(".nr %d ", TMP); wide(s, FN(vforml, icol), SZ(vforml, icol)); printf("\n"); printf( ".if \\n(%2s<\\n(%d .nr %2s \\n(%d\n", reg(icol, CRIGHT), TMP, reg(icol, CRIGHT), TMP); } } } } if(acase[icol]){ printf(".if \\n(%d>=\\n(%2s .nr %2s \\n(%du+2n\n", S2, reg(icol, CRIGHT), reg(icol, CRIGHT), S2); } if(doubled[icol]){ printf(".nr %2s \\n(%d\n", reg(icol, CMID), S1); printf(".nr %d \\n(%2s+\\n(%d\n", TMP, reg(icol, CMID), S2); printf(".if \\n(%d>\\n(%2s .nr %2s \\n(%d\n", TMP, reg(icol, CRIGHT), reg(icol, CRIGHT), TMP); printf( ".if \\n(%d<\\n(%2s .nr %2s +(\\n(%2s-\\n(%d)/2\n", TMP, reg(icol, CRIGHT), reg(icol, CMID), reg(icol, CRIGHT), TMP); } if(cll[icol][0]){ printf(".nr %d %sn\n", TMP, cll[icol]); printf(".if \\n(%2s<\\n(%d .nr %2s \\n(%d\n", reg(icol, CRIGHT), TMP, reg(icol, CRIGHT), TMP); } for(ilin = 0; ilin < nlin; ilin++) if(k = lspan(ilin, icol)){ s = table[ilin][icol - k].col; if(!real(s) || barent(s) || vspen(s)) continue; printf(".nr %d ", TMP); wide(table[ilin][icol - k].col, FN(ilin, icol - k), SZ(ilin, icol - k)); for(ik = k; ik >= 0; ik--){ printf("-\\n(%2s", reg(icol-ik,CRIGHT)); if(!expflg && ik > 0) printf( "-%dn", sep[icol - ik]); } printf("\n"); printf(".if \\n(%d>0 .nr %d \\n(%d/%d\n", TMP, TMP, TMP, k); printf(".if \\n(%d<0 .nr %d 0\n", TMP, TMP); for(ik = 1; ik <= k; ik++){ if(doubled[icol - k + ik]){ printf(".nr %2s +\\n(%d/2\n", reg(icol - k + ik,CMID), TMP); } printf(".nr %2s +\\n(%d\n", reg(icol - k + ik, CRIGHT),TMP); } } } if(textflg) untext(); /* * if even requested, make all columns widest width */ #define TMP1 S1 #define TMP2 S2 if(evenflg){ printf(".nr %d 0\n", TMP); for(icol = 0; icol < ncol; icol++){ if(evenup[icol] == 0) continue; printf(".if \\n(%2s>\\n(%d .nr %d \\n(%2s\n", reg(icol, CRIGHT), TMP, TMP, reg(icol, CRIGHT)); } for(icol = 0; icol < ncol; icol++){ /* * if column not evened just retain old interval */ if(evenup[icol] == 0) continue; if(doubled[icol]) printf( ".nr %2s (100*\\n(%2s/\\n(%2s)*\\n(%d/100\n", reg(icol, CMID), reg(icol, CMID), reg(icol, CRIGHT), TMP); /* * that nonsense with the 100's and parens tries to avoid * overflow while proportionally shifting the middle of * the number */ printf(".nr %2s \\n(%d\n", reg(icol, CRIGHT), TMP); } } /* * now adjust for total table width */ for(tsep = icol = 0; icol < ncol; icol++) tsep += sep[icol]; if(expflg){ printf(".nr %d 0", TMP); for(icol = 0; icol < ncol; icol++) printf("+\\n(%2s", reg(icol, CRIGHT)); printf("\n"); /* * Bug fix: Most users expect the expand to take place * over the line length minus the current indentation * (I do as well, a bit ugly to see the table creeping * in the right margin (jna)) */ printf(".nr %d \\n(.l-\\n(.i-\\n(%d\n", TMP, TMP); if(boxflg || dboxflg || allflg) tsep += 1; else tsep -= sep[ncol - 1]; printf(".nr %d \\n(%d/%d\n", TMP, TMP, tsep); printf(".if \\n(%d<0 .nr %d 0\n", TMP, TMP); } else printf(".nr %d 1n\n", TMP); printf(".nr %2s 0\n", reg(-1,CRIGHT)); tsep = (boxflg || allflg || dboxflg || left1flg) ? 1 : 0; for(icol = 0; icol < ncol; icol++){ printf(".nr %2s \\n(%2s+(%d*\\n(%d)\n", reg(icol, CLEFT), reg(icol -1, CRIGHT), tsep, TMP); printf(".nr %2s +\\n(%2s\n",reg(icol, CRIGHT),reg(icol, CLEFT)); if(doubled[icol]){ /* * the next line is last-ditch effort to avoid * zero field width */ /* printf(".if \\n(%2s=0 .nr %2s 1\n", reg(icol,CMID), reg(icol,CMID)); */ printf(".nr %2s +\\n(%2s\n", reg(icol, CMID), reg(icol, CLEFT)); /* printf(".if n .if \\n(%2s%%24>0 .nr %2s +12u\n", reg(icol, CMID), reg(icol, CMID)); */ } tsep = sep[icol]; } if(rightl) printf(".nr %2s (\\n(%2s+\\n(%2s)/2\n", reg(ncol-1, CRIGHT), reg(ncol-1, CLEFT), reg(ncol-2, CRIGHT)); printf(".nr TW \\n(%2s\n", reg(ncol-1, CRIGHT)); if(boxflg || allflg || dboxflg) printf(".nr TW +%d*\\n(%d\n", sep[ncol - 1], TMP); printf( ".if t .if\\n(TW>\\n(.lu .tm Table at line %d file %s is too wide - \\n(TW units\n", iline - 1, strlen(oldname) ? oldname : ifile); return; }
/* * parameters * * i: line number for deciding format * nl: line number for finding data usually identical */ void putline(int i, int nl) { int c, lf, ct, form, lwid, vspf, ip = -1, cmidx, exvspen, vforml; int vct, chfont; char *s, *size, *fn; watchout=vspf=exvspen=0; if (i==0) once=0; if (i==0 && ( allflg || boxflg || dboxflg)) fullwide(0, dboxflg? '=' : '-'); if (instead[nl]==0 && fullbot[nl] ==0) for(c=0; c<ncol; c++) { s = table[nl][c].col; if (s==0) continue; if (vspen(s)) { for(ip=nl; ip<nlin; ip=next(ip)) if (!vspen(s=table[ip][c].col)) break; if (s>(char *)0 && s<(char *)128) fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n",s); continue; } if (point(s)) continue; fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n",s); watchout=1; } if (linestop[nl]) fprintf(tabout, ".mk #%c\n", linestop[nl]+'a'-1); lf = prev(nl); if (instead[nl]) { puts(instead[nl]); return; } if (fullbot[nl]) { switch (ct=fullbot[nl]) { case '=': case '-': fullwide(nl,ct); } return; } for(c=0; c<ncol; c++) { if (instead[nl]==0 && fullbot[nl]==0) if (vspen(table[nl][c].col)) vspf=1; if (lf>=0) if (vspen(table[lf][c].col)) vspf=1; } if (vspf) { fprintf(tabout, ".nr #^ \\n(\\*(#du\n"); fprintf(tabout, ".nr #- \\n(#^\n"); /* current line position relative to bottom */ } vspf=0; chfont=0; for(c=0; c<ncol; c++) { s = table[nl][c].col; if (s==0) continue; chfont |= (int)(font[stynum[nl]][c]); if (point(s) ) continue; lf=prev(nl); if (lf>=0 && vspen(table[lf][c].col)) fprintf(tabout, ".if (\\n(%c|+\\n(^%c-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(^%c-\\n(#--1v)\n",s,'a'+c,s,'a'+c); else fprintf(tabout, ".if (\\n(%c|+\\n(#^-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(#^-\\n(#--1v)\n",s,s); } if (allflg && once>0 ) fullwide(i,'-'); once=1; runtabs(i, nl); if (allh(nl) && !pr1403) { fprintf(tabout, ".nr %d \\n(.v\n", SVS); fprintf(tabout, ".vs \\n(.vu-\\n(.sp\n"); } if (chfont) fprintf(tabout, ".nr %2d \\n(.f\n", S1); fprintf(tabout, ".nr 35 1m\n"); fprintf(tabout, "\\&"); vct = 0; for(c=0; c<ncol; c++) { if (watchout==0 && i+1<nlin && (lf=left(i,c, &lwid))>=0) { tohcol(c); drawvert(lf, i, c, lwid); vct += 2; } if (rightl && c+1==ncol) continue; vforml=i; for(lf=prev(nl); lf>=0 && vspen(table[lf][c].col); lf=prev(lf)) vforml= lf; form= ctype(vforml,c); if (form != 's') { ct = c+CLEFT; if (form=='a') ct = c+CMID; if (form=='n' && table[nl][c].rcol && lused[c]==0) ct= c+CMID; fprintf(tabout, "\\h'|\\n(%du'", ct); } s= table[nl][c].col; fn = font[stynum[vforml]][c]; size = csize[stynum[vforml]][c]; if (*size==0)size=0; switch(ct=ctype(vforml, c)) { case 'n': case 'a': if (table[nl][c].rcol) { if (lused[c]) /*Zero field width*/ { ip = prev(nl); if (ip>=0) if (vspen(table[ip][c].col)) { if (exvspen==0) { fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c+'a'); if (cmidx) fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a'); vct++; fprintf(tabout, "'"); exvspen=1; } } fprintf(tabout, "%c%c",F1,F2); puttext(s,fn,size); fprintf(tabout, "%c",F1); } s= table[nl][c].rcol; form=1; break; } /* FALLTHROUGH */ case 'c': form=3; break; case 'r': form=2; break; case 'l': form=1; break; case '-': case '=': if (real(table[nl][c].col)) fprintf(stderr,gettext("%s: line %d: Data ignored on table line %d\n"), ifile, iline-1, i+1); makeline(i,c,ct); continue; default: continue; } if (realsplit ? rused[c]: used[c]) /*Zero field width*/ { /* form: 1 left, 2 right, 3 center adjust */ if (ifline(s)) { makeline(i,c,ifline(s)); continue; } if (filler(s)) { printf("\\l'|\\n(%du\\&%s'", c+CRIGHT, s+2); continue; } ip = prev(nl); cmidx = ctop[stynum[nl]][c]==0; if (ip>=0) if (vspen(table[ip][c].col)) { if (exvspen==0) { fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c+'a'); if (cmidx) fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a'); vct++; fprintf(tabout, "'"); } } fprintf(tabout, "%c", F1); if (form!= 1) fprintf(tabout, "%c", F2); if (vspen(s)) vspf=1; else puttext(s, fn, size); if (form !=2) fprintf(tabout, "%c", F2); fprintf(tabout, "%c", F1); } if (ip>=0) if (vspen(table[ip][c].col)) { exvspen = (c+1 < ncol) && vspen(table[ip][c+1].col) && (topat[c] == topat[c+1]) && (cmidx == (ctop [stynum[nl]][c+1]==0)) && (left(i,c+1,&lwid)<0); if (exvspen==0) { fprintf(tabout, "\\v'(\\n(\\*(#du-\\n(^%cu", c+'a'); if (cmidx) fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a'); vct++; fprintf(tabout, "'"); } } else exvspen=0; /* if lines need to be split for gcos here is the place for a backslash */ if (vct > 7 && c < ncol) { fprintf(tabout, "\n.sp-1\n\\&"); vct=0; } } fprintf(tabout, "\n"); if (allh(nl) && !pr1403) fprintf(tabout, ".vs \\n(%du\n", SVS); if (watchout) funnies(i,nl); if (vspf) { for(c=0; c<ncol; c++) if (vspen(table[nl][c].col) && (nl==0 || (lf=prev(nl))<0 || !vspen(table[lf][c].col))) { fprintf(tabout, ".nr ^%c \\n(#^u\n", 'a'+c); topat[c]=nl; } } }
void funnies(int stl, int lin) { /* write out funny diverted things */ int c, s, pl, lwid, dv, lf, ct; char *fn; fprintf(tabout, ".mk ##\n"); /* rmember current vertical position */ fprintf(tabout, ".nr %d \\n(##\n", S1); /* bottom position */ for(c=0; c<ncol; c++) { s = (int)table[lin][c].col; if (point(s)) continue; if (s==0) continue; fprintf(tabout, ".sp |\\n(##u-1v\n"); fprintf(tabout, ".nr %d ", SIND); for(pl=stl; pl>=0 && !isalpha(ct=ctype(pl,c)); pl=prev(pl)) ; switch (ct) { case 'n': case 'c': fprintf(tabout, "(\\n(%du+\\n(%du-\\n(%c-u)/2u\n",c+CLEFT,c-1+ctspan(lin,c)+CRIGHT, s); break; case 'l': fprintf(tabout, "\\n(%du\n",c+CLEFT); break; case 'a': fprintf(tabout, "\\n(%du\n",c+CMID); break; case 'r': fprintf(tabout, "\\n(%du-\\n(%c-u\n", c+CRIGHT, s); break; } fprintf(tabout, ".in +\\n(%du\n", SIND); fn=font[stynum[stl]][c]; putfont(fn); pl = prev(stl); if (stl>0 && pl>=0 && vspen(table[pl][c].col)) { fprintf(tabout, ".sp |\\n(^%cu\n", 'a'+c); if (ctop[stynum[stl]][c]==0) { fprintf(tabout, ".nr %d \\n(#-u-\\n(^%c-\\n(%c|+1v\n",TMP, 'a'+c, s); fprintf(tabout, ".if \\n(%d>0 .sp \\n(%du/2u\n", TMP, TMP); } } fprintf(tabout, ".%c+\n",s); fprintf(tabout, ".in -\\n(%du\n", SIND); if (*fn>0) putfont("P"); fprintf(tabout, ".mk %d\n", S2); fprintf(tabout, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n", S2, S1, S1, S2); } fprintf(tabout, ".sp |\\n(%du\n", S1); for(c=dv=0; c<ncol; c++) { if (stl+1< nlin && (lf=left(stl,c,&lwid))>=0) { if (dv++ == 0) fprintf(tabout, ".sp -1\n"); tohcol(c); dv++; drawvert(lf, stl, c, lwid); } } if (dv) fprintf(tabout,"\n"); }