gettbl() { int icol, ch; cstore=cspace= chspace(); textflg=0; for (nlin=nslin=0; gets1(cstore); nlin++) { stynum[nlin]=nslin; if (prefix(".TE", cstore)) { leftover=0; break; } if (prefix(".TC", cstore) || prefix(".T&", cstore)) { readspec(); nslin++; } if (nlin>=MAXLIN) { leftover=(int)cstore; break; } fullbot[nlin]=0; if (cstore[0] == '.' && !isdigit(cstore[1])) { instead[nlin] = cstore; while (*cstore++); continue; } else instead[nlin] = 0; if (nodata(nlin)) { if (ch = oneh(nlin)) fullbot[nlin]= ch; nlin++; nslin++; instead[nlin]=(char *)0; fullbot[nlin]=0; } table[nlin] = (struct colstr *)alocv((ncol+2)*sizeof(table[0][0])); if (cstore[1]==0) switch(cstore[0]) { case '_': fullbot[nlin]= '-'; continue; case '=': fullbot[nlin]= '='; continue; } stynum[nlin] = nslin; nslin = min(nslin+1, nclin-1); for (icol = 0; icol <ncol; icol++) { table[nlin][icol].col = cstore; table[nlin][icol].rcol=0; ch=1; if (match(cstore, "T{")) /* text follows */ table[nlin][icol].col = (char *)gettext(cstore, nlin, icol, font[stynum[nlin]][icol], csize[stynum[nlin]][icol]); else { for(; (ch= *cstore) != '\0' && ch != tab; cstore++) ; *cstore++ = '\0'; switch(ctype(nlin,icol)) /* numerical or alpha, subcol */ { case 'n': table[nlin][icol].rcol = (char *)maknew(table[nlin][icol].col); break; case 'a': table[nlin][icol].rcol = table[nlin][icol].col; table[nlin][icol].col = ""; break; } } while (ctype(nlin,icol+1)== 's') /* spanning */ table[nlin][++icol].col = ""; if (ch == '\0') break; } while (++icol <ncol+2) { table[nlin][icol].col = ""; table [nlin][icol].rcol=0; } while (*cstore != '\0') cstore++; if (cstore-cspace > MAXCHS) cstore = cspace = chspace(); } last = cstore; permute(); if (textflg) untext(); return; }
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; }
/* * 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; }
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] */ }
/* **************************************************************** * Processa uma programa reentrante * **************************************************************** */ void untext_file (const char *file_nm) { register char *cp; const char *prefixp = env_path; char path[512]; /* * Se o nome dado tiver um "/", não utiliza os prefixos */ if (strchr (file_nm, '/')) prefixp = "."; /* * Tenta os vários prefixos */ while (*prefixp) { cp = path; /* * Copia um prefixo */ while (*prefixp && (*cp = *prefixp++) != ':') cp++; if (cp != path) *cp++ = '/'; /* * Copia no final o nome do arquivo dado */ strcpy (cp, file_nm); /* * Tira o "./" do início */ cp = path; if (cp[0] == '.' && cp[1] == '/') cp += 2; /* * Tenta liberar os recursos */ errno = NOERR; untext (cp); #undef DEBUG #ifdef DEBUG if (vflag) printf ("=> \"%s\", errno = %s\n", cp, strerror (errno)); #endif DEBUG /* * Verifica se conseguiu */ switch (errno) { /* * Conseguiu */ case NOERR: fprintf ( stderr, "Liberei os recursos de \"%s\"\n", cp ); return; /* * Arquivo desconhecido: tenta o próximo nome */ case ENOENT: case ENOTDIR: continue; /* * O arquivo não tem recursos alocados */ case EINVAL: fprintf ( stderr, "O arquivo \"%s\" não tem recursos alocados\n", cp ); exit_code++; return; /* * Outros erros */ default: break; } /* end switch */ break; } /* end while */ /* * Outros erros */ fprintf ( stderr, "%s: Não consegui liberar os recursos de \"%s\" (%s)\n", pgname, file_nm, strerror (errno) ); exit_code++; } /* end untext_file */