int gettext9(char *sp, int ilin, int icol, char *fn, char *sz) { /* get a section of text */ char line[4096]; int oname, startline; char *vs; startline = iline; if (texname == 0) error("Too many text block diversions"); if (textflg == 0) { Bprint(&tabout.Biobufhdr, ".nr %d \\n(.lu\n", SL); /* remember old line length */ textflg = 1; } Bprint(&tabout.Biobufhdr, ".eo\n"); Bprint(&tabout.Biobufhdr, ".am %s\n", reg(icol, CRIGHT)); Bprint(&tabout.Biobufhdr, ".br\n"); Bprint(&tabout.Biobufhdr, ".di %c+\n", texname); rstofill(); if (fn && *fn) Bprint(&tabout.Biobufhdr, ".nr %d \\n(.f\n.ft %s\n", S1, fn); Bprint(&tabout.Biobufhdr, ".ft \\n(.f\n"); /* protect font */ vs = vsize[icol][stynum[ilin]]; if ((sz && *sz) || (vs && *vs)) { Bprint(&tabout.Biobufhdr, ".nr %d \\n(.v\n", S9); if (vs == 0 || *vs == 0) vs = "\\n(.s+2"; if (sz && *sz) Bprint(&tabout.Biobufhdr, ".ps %s\n", sz); Bprint(&tabout.Biobufhdr, ".vs %s\n", vs); Bprint(&tabout.Biobufhdr, ".if \\n(%du>\\n(.vu .sp \\n(%du-\\n(.vu\n", S9, S9); } if (cll[icol][0]) Bprint(&tabout.Biobufhdr, ".ll %sn\n", cll[icol]); else Bprint(&tabout.Biobufhdr, ".ll \\n(%du*%du/%du\n", SL, ctspan(ilin, icol), ncol + 1); Bprint(&tabout.Biobufhdr, ".if \\n(.l<\\n(%2s .ll \\n(%2su\n", reg(icol, CRIGHT), reg(icol, CRIGHT)); if (ctype(ilin, icol) == 'a') Bprint(&tabout.Biobufhdr, ".ll -2n\n"); Bprint(&tabout.Biobufhdr, ".in 0\n"); for (;;) { if (gets1(line, sizeof(line)) == nil) { iline = startline; error("missing closing T}"); } if (line[0] == 'T' && line[1] == '}' && line[2] == tab) break; if (match("T}", line)) break; Bprint(&tabout.Biobufhdr, "%s\n", line); } if (fn && *fn) Bprint(&tabout.Biobufhdr, ".ft \\n(%d\n", S1); if (sz && *sz) Bprint(&tabout.Biobufhdr, ".br\n.ps\n.vs\n"); Bprint(&tabout.Biobufhdr, ".br\n"); Bprint(&tabout.Biobufhdr, ".di\n"); Bprint(&tabout.Biobufhdr, ".nr %c| \\n(dn\n", texname); Bprint(&tabout.Biobufhdr, ".nr %c- \\n(dl\n", texname); Bprint(&tabout.Biobufhdr, "..\n"); Bprint(&tabout.Biobufhdr, ".ec \\\n"); /* copy remainder of line */ if (line[2]) tcopy (sp, line + 3); else *sp = 0; oname = texname; texname = texstr[++texct]; return(oname); }
/* get_text was originally gettext and was renamed */ char * get_text(char *sp, int ilin, int icol, char *fn, char *sz) { /* get a section of text */ char *line = NULL; size_t linesize = 0; char *oname; const char *vs; if (texname==0) texct2 = texname = 300; if (texct2>0 && point(texct2)) { error("Too many text block diversions"); return (char *)-1; } if (textflg==0) { fprintf(tabout, ".nr %d \\n(.lu\n", SL); /* remember old line length */ textflg=1; } fprintf(tabout, ".eo\n"); fprintf(tabout, ".am %02d 00\n", icol+80); fprintf(tabout, ".br\n"); if (texct2 < 0) fprintf(tabout, ".di %c+\n", (int)texname); else fprintf(tabout, ".do di %d+\n", texct2); rstofill(); if (fn && *fn) fprintf(tabout, ".nr %d \\n(.f\n.ft %s\n", S1, fn); fprintf(tabout, ".ft \\n(.f\n"); /* protect font */ vs = vsize[stynum[ilin]][icol]; if ((sz && *sz) || (vs && *vs)) { fprintf(tabout, ".nr %d \\n(.v\n", S2); if (vs==0 || *vs==0) vs= "\\n(.s+2"; if (sz && *sz) fprintf(tabout, ".ps %s\n",sz); fprintf(tabout, ".vs %s\n",vs); fprintf(tabout, ".if \\n(%du>\\n(.vu .sp \\n(%du-\\n(.vu\n", S2,S2); } if (cll[icol][0]) fprintf(tabout, ".ll %sn\n", cll[icol]); else fprintf(tabout, ".ll \\n(%du*%du/%du\n",SL,ctspan(ilin,icol),ncol+1); fprintf(tabout,".if \\n(.l<\\n(%d .ll \\n(%du\n", icol+CRIGHT, icol+CRIGHT); if (ctype(ilin,icol)=='a') fprintf(tabout, ".ll -2n\n"); fprintf(tabout, ".in 0\n"); while (gets1(&line, &line, &linesize)) { if (line[0]=='T' && line[1]=='}' && line[2]== tab) break; if (strcmp("T}", line) == 0) break; fprintf(tabout, "%s\n", line); } if (fn && *fn) fprintf(tabout, ".ft \\n(%d\n", S1); if (sz && *sz) fprintf(tabout, ".br\n.ps\n.vs\n"); fprintf(tabout, ".br\n"); fprintf(tabout, ".di\n"); if (texct2 < 0) { fprintf(tabout, ".nr %c| \\n(dn\n", (int)texname); fprintf(tabout, ".nr %c- \\n(dl\n", (int)texname); } else { fprintf(tabout, ".do nr %d| \\n(dn\n", texct2); fprintf(tabout, ".do nr %d- \\n(dl\n", texct2); } fprintf(tabout, ".00\n"); fprintf(tabout, ".ec \\\n"); /* copy remainder of line */ if (line[2]) tcopy (sp, line+3); else *sp=0; oname = (char *)texname; if (texct2 < 0) texname = texstr[++texct]; else texname = ++texct2; free(line); return oname; }
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"); }