getcomm() { char line[200], *cp, nb[25], *t; struct optstr *lp; int c, ci, found; for(lp= options; lp->optnam; lp++) *(lp->optadd) = 0; texname = texstr[texct=0]; tab = '\t'; printf(".nr %d \\n(.s\n", LSIZE); gets1(line); /* see if this is a command line */ if (index(line,';') == NULL) { backrest(line); return; } for(cp=line; (c = *cp) != ';'; cp++) { if (!letter(c)) continue; found=0; for(lp= options; lp->optadd; lp++) { if (prefix(lp->optnam, cp)) { *(lp->optadd) = 1; cp += strlen(lp->optnam); if (letter(*cp)) error("Misspelled global option"); while (*cp==' ')cp++; t=nb; if ( *cp == '(') while ((ci= *++cp) != ')') *t++ = ci; else cp--; *t++ = 0; *t=0; if (lp->optadd == &tab) { if (nb[0]) *(lp->optadd) = nb[0]; } if (lp->optadd == &linsize) printf(".nr %d %s\n", LSIZE, nb); if (lp->optadd == &delim1) { delim1 = nb[0]; delim2 = nb[1]; } found=1; break; } } if (!found) error("Illegal option"); } cp++; backrest(cp); return; }
int tbl(int argc,char *argv[]) { char line[BUFSIZ]; /* required by GCOS because "stdout" is set by troff preprocessor */ tabin=stdin; tabout=stdout; setinp(argc,argv); while (gets1(line)) { fprintf(tabout, "%s\n",line); if (prefix(".TS", line)) tableput(); } fclose(tabin); return(0); }
void yetmore(void) { for(useln=0; useln<MAXLIN && table[useln]==0; useln++); if (useln>=MAXLIN) error("Wierd. No data in table."); table[0]=table[useln]; for(useln=nlin-1; useln>=0 && (fullbot[useln] || instead[useln]); useln--); if (useln<0) error("Wierd. No real lines in table."); domore((char *)leftover); while (gets1(cstore=cspace) && domore(cstore)) ; last =cstore; return; }
int tbl(int argc, char *argv[]) { char line[5120]; /*int x;*/ /*x=malloc((char *)0); uncomment when allocation breaks*/ Binit(&tabout, 1, OWRITE); setinp(argc, argv); while (gets1(line, sizeof(line))) { Bprint(&tabout, "%s\n", line); if (prefix(".TS", line)) tableput(); } Bterm(tabin); return(0); }
int tbl(int argc, char *argv[]) { char *line = NULL; size_t linesize = 0; /* required by GCOS because "stdout" is set by troff preprocessor */ tabin=stdin; tabout=stdout; setinp(argc,argv); while (gets1(&line, &line, &linesize)) { fprintf(tabout, "%s\n",line); if (cprefix("TS", line)) tableput(); } fclose(tabin); free(line); return(0); }
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; }
/* 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; }
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); }