Interdata_v6/usr/source/troff/tbl/src.a
ÿeport.c †p0 ¶/*
* Approximate old portable C library using new Standard I/O Library
*
* (ad hoc version for tbl only)
*/
# include "stdio.h"
# undef getchar
int cin = stdin;
int cout;
cclose(fd)
{
fclose(fd);
}
cexit(n)
{
fclose(stdout);
exit(n);
}
copen(fn, type)
{
char *mode;
switch(type) {
case 'r':
mode = "r";
break;
case 'w':
mode = "w";
break;
case 'a':
mode = "a";
break;
}
return(fopen(fn, mode));
}
gets(ss)
char *ss;
{
register c;
register char *s;
s = ss;
while ((c = getc(cin)) >= 0)
if (c == '\n') {
*s = '\0';
return(ss);
} else
*s++ = c;
return(0);
}
getchar()
{
return(getc(cin));
}
gt..c ~±” ¼ ¶# define MAXLIN 200
# define MAXHEAD 30
# define MAXCOL 20
# define MAXCHS 2000
# define CLLEN 10
extern int nlin, ncol, iline, nclin, nslin;
extern int style[MAXHEAD][MAXCOL];
extern int ctop[MAXHEAD][MAXCOL];
extern char font[MAXHEAD][MAXCOL][2];
extern char csize[MAXHEAD][MAXCOL][4];
extern char cll[MAXCOL][CLLEN];
extern int stynum[];
extern int F1, F2;
extern int lefline[MAXHEAD][MAXCOL];
extern int fullbot[];
extern int instead[];
extern int expflg;
extern int ctrflg;
extern int evenflg;
extern int evenup[];
extern int boxflg;
extern int dboxflg;
extern int tab;
extern int allflg;
extern int textflg;
extern int left1flg;
extern int rightl;
struct colstr {char *col, *rcol;};
extern struct colstr *table[];
extern char *cspace, *cstore;
extern char *exstore, *exlim;
extern int sep[];
extern int used[], lused[], rused[];
extern int linestop[];
extern int leftover;
extern char *last, *ifile;
extern int cin, cout;
extern int texname;
# define CRIGHT 80
# define CLEFT 40
# define CMID 60
# define S1 31
# define S2 32
# define TMP 38
# define SF 35
# define SIND 37
/* this refers to the relative position of lines */
# define LEFT 1
# define RIGHT 2
# define THRU 3
# define TOP 1
# define BOT 2
t0.c ~±— Ç ¶#
# include "t..c"
int expflg 0;
int ctrflg 0;
int boxflg 0;
int dboxflg 0;
int tab '\t';
int evenup[MAXCOL], evenflg;
int F1 0;
int F2 0;
int allflg 0;
int leftover 0;
int textflg 0;
int left1flg 0;
int rightl 0;
char *cstore, *cspace;
char *last;
struct colstr *table[MAXLIN];
int style[MAXHEAD][MAXCOL];
int ctop[MAXHEAD][MAXCOL];
char font[MAXHEAD][MAXCOL][2];
char csize[MAXHEAD][MAXCOL][4];
int lefline[MAXHEAD][MAXCOL];
char cll[MAXCOL][CLLEN];
int stynum[MAXLIN+1];
int nslin, nclin;
int sep[MAXCOL];
int fullbot[MAXLIN];
int instead[MAXLIN];
int used[MAXCOL], lused[MAXCOL], rused[MAXCOL];
int linestop[MAXLIN];
int nlin, ncol;
int iline 1;
char *ifile "Input";
int texname 'a';
char *exstore, *exlim;
t1.c ~±™ P ¶#
# include "t..c"
# define BROKPIPE 13
# ifdef unix
# define MACROS "/usr/lib/tmac.s"
# endif
# ifdef gcos
# define MACROS "cc/troff/smac"
# endif
# define ever (;;)
main(argc,argv)
char *argv[];
{
#ifdef gcos
if(!intss()) cout = copen("*qq", 'w'); /* default media code is type 5 */
#endif
# ifdef unix
int badsig();
signal(BROKPIPE, badsig);
# endif
cexit(tbl(argc,argv));
}
tbl(argc,argv)
char *argv[];
{
char line[512];
for ever
{
if (argc>1)
{
argc--;
argv++;
if (match("-ms", *argv))
*argv = MACROS;
cin = copen(ifile= *argv, 'r');
iline=1;
if (cin < 0)
{
printf(2, "can't open input file %s\n", ifile);
return(1);
}
}
while (gets1(line))
{
puts(line);
if (prefix(".TS", line))
tableput();
}
cclose(cin);
if (argc <= 1) break;
}
return(0);
}
# ifdef unix
badsig()
{
signal(BROKPIPE, 1);
cexit(0);
}
# endif
t2.c ~±› ° ¶# include "t..c"
tableput()
{
savefill();
ifdivert();
getcomm();
getspec();
gettbl();
getstop();
checkuse();
choochar();
maktab();
runout();
release();
rstofill();
endoff();
}
t3.c ~± ¶# include "t..c"
struct optstr {char *optnam; int *optadd;} options [] {
"expand", &expflg,
"center", &ctrflg,
"box", &boxflg,
"allbox", &allflg,
"doublebox", &dboxflg,
"frame", &boxflg,
"doubleframe", &dboxflg,
"tab", &tab,
0,0};
getcomm()
{
char line[200], *cp;
struct optstr *lp;
int c;
for(lp= options; lp->optnam; lp++)
*(lp->optadd) = 0;
texname='a';
tab = '\t';
gets1(line);
/* see if this is a command line */
if (index(line,';') < 0)
{
backrest(line);
return;
}
for(cp=line; (c = *cp) != ';'; cp++)
{
if (!letter(c)) continue;
for(lp= options; lp->optadd; lp++)
{
if (prefix(lp->optnam, cp))
{
*(lp->optadd) = 1;
while (letter(*cp)) cp++;
if (lp->optadd == &tab)
{
while (*cp==' ')cp++;
if (*cp == '('){
*(lp->optadd) = *++cp;
cp++;
}
}
break;
}
}
if (letter(*cp)) error("Illegal option");
cp--;
}
cp++;
backrest(cp);
return;
}
backrest(cp)
char *cp;
{
char *s;
for(s=cp; *s; s++);
un1getc('\n', cin);
while (s>cp)
un1getc(*--s, cin);
return;
}
+t4.c ~±Ÿ 4 ‘¶# include "t..c"
getspec()
{
int icol, i;
for(icol=0; icol<MAXCOL; icol++)
{
sep[icol]= -1;
evenup[icol]=0;
cll[icol][0]=0;
for(i=0; i<MAXHEAD; i++)
{
csize[i][icol][0]=0;
font[i][icol][0] = lefline[i][icol] = 0;
ctop[i][icol]=0;
style[i][icol]= 'l';
}
}
nclin=ncol=0;
left1flg=rightl=0;
readspec();
}
readspec()
{
int icol, c, sawchar, stopc, i;
char sn[10], *snp, *temp;
sawchar=icol=0;
while (c=get1char())
{
switch(c)
{
default:
if (c != tab)
error("bad table specification character");
case ' ': /* note this is also case tab */
continue;
case '\n':
if(sawchar==0) continue;
case ',':
case '.': /* end of table specification */
ncol = max(ncol, icol);
if (lefline[nclin][ncol]>0) {ncol++; rightl++;};
if(sawchar)
nclin++;
if (nclin>=MAXHEAD)
error("too many lines in specification");
icol=0;
if (ncol==0 || nclin==0)
error("no specification");
if (c== '.')
{
while ((c=get1char()) && c != '\n');
/* fix up sep - default is 3 except at edge */
for(icol=0; icol<ncol; icol++)
if (sep[icol]<0)
sep[icol] = icol+1<ncol ? 3 : 1;
return;
}
sawchar=0;
continue;
case 'C': case 'S': case 'R': case 'N': case 'L': case 'A':
c =+ ('a'-'A');
case '_': if (c=='_') c= '-';
case '=': case '-':
case '^':
case 'c': case 's': case 'n': case 'r': case 'l': case 'a':
style[nclin][icol]=c;
if (c== 's' && icol<=0)
error("first column can not be S-type");
if (c=='s' && style[nclin][icol-1] == 'a')
{
printf(".tm warning: can't span a-type cols, changed to l\n");
style[nclin][icol-1] = 'l';
}
if (c=='s' && style[nclin][icol-1] == 'n')
{
printf(".tm warning: can't span n-type cols, changed to c\n");
style[nclin][icol-1] = 'c';
}
icol++;
if (c=='^' && nclin<=0)
error("first row can not contain vertical span");
if (icol>=MAXCOL)
error("too many columns in table");
sawchar=1;
continue;
case 'b': case 'i':
c =+ 'A'-'a';
case 'B': case 'I':
if (icol==0) continue;
snp=font[nclin][icol-1];
snp[0]= (c=='I' ? '2' : '3');
snp[1]=0;
continue;
case 't': case 'T':
if (icol>0)
ctop[nclin][icol-1] = 1;
continue;
case 'f': case 'F':
if (icol==0) continue;
snp=font[nclin][icol-1];
snp[0]=snp[1]=stopc=0;
for(i=0; i<2; i++)
{
c = get1char();
if (i==0 && c=='(')
{
stopc=')';
c = get1char();
}
if (c==0) break;
if (c==stopc) {stopc=0; break;}
if (stopc==0) if (c==' ' || c== tab ) break;
if (c=='\n'){un1getc(c,cin); break;}
snp[i] = c;
if (c>= '0' && c<= '9') break;
}
if (stopc) if (get1char()!=stopc)
error("Nonterminated font name");
continue;
case 'P': case 'p':
if (icol<=0) continue;
temp = snp = csize[nclin][icol-1];
while (c = get1char())
{
if (c== ' ' || c== tab || c=='\n') break;
if (c=='-' || c == '+')
if (snp>temp)
break;
else
*snp++=c;
else
if (digit(c))
*snp++ = c;
else break;
if (snp-temp>4)
error("point size too large");
}
*snp=0;
un1getc(c,cin);
continue;
case 'w': case 'W':
snp = cll [icol-1];
if (*snp)
{
printf (2, "Ignored second width specification");
continue;
}
stopc=0;
while (c = get1char())
{
if (snp==cll[icol-1] && c=='(')
{
stopc = ')';
continue;
}
if ( !stopc && (c>'9' || c< '0'))
break;
if (stopc && c== stopc)
break;
*snp++ =c;
}
*snp=0;
if (snp-cll[icol-1]>CLLEN)
error ("column width too long");
if (!stopc)
un1getc(c);
continue;
case 'e': case 'E':
if (icol<1) continue;
evenup[icol-1]=1;
evenflg=1;
continue;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
sn[0] = c;
snp=sn+1;
while (digit(*snp++ = c = get1char()))
;
un1getc(c,cin);
sep[icol-1] = max(sep[icol-1], numb(sn));
continue;
case '|':
lefline[nclin][icol]++;
if (icol==0) left1flg=1;
continue;
}
}
error("EOF reading table specification");
}
t5.c ~±¢ ³ ¶# include "t..c"
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=1;
break;
}
fullbot[nlin]=0;
if (cstore[0] == '.' && letter(cstore[1]))
{
instead[nlin] = cstore;
while (*cstore++);
continue;
}
else instead[nlin] = 0;
while (nodata(nlin))
{
if (ch = oneh(nlin))
fullbot[nlin]= ch;
nlin++;
nslin++;
instead[nlin]=fullbot[nlin]=0;
}
table[nlin] = alocv(ncol*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 =
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 = 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)
{
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;
}
nodata(il)
{
int c;
for (c=0; c<ncol;c++)
{
switch(ctype(il,c))
{
case 'c': case 'n': case 'r': case 'l': case 's': case 'a':
return(0);
}
}
return(1);
}
oneh(lin)
{
int k, icol;
k = ctype(lin,0);
for(icol=1; icol<ncol; icol++)
{
if (k != ctype(nlin,icol))
return(0);
}
return(k);
}
# define SPAN "\\^"
permute()
{
int irow, jcol, is;
char *start, *strig;
for(jcol=0; jcol<ncol; jcol++)
{
for(irow=1; irow<nlin; irow++)
{
if (vspand(irow,jcol))
{
is = prev(irow);
start = table[is][jcol].col;
strig = table[is][jcol].rcol;
while (irow<nlin &&vspand(irow,jcol))
irow++;
table[--irow][jcol].col = start;
table[irow][jcol].rcol = strig;
style[stynum[irow]][jcol] = ctype(is,jcol);
while (is<irow)
{
table[is][jcol].rcol =0;
table[is][jcol].col= SPAN;
is = next(is);
}
}
}
}
}
vspand(ir,ij)
{
if (instead[ir]) return(0);
if (ctype(ir,ij)=='^') return(1);
if (table[ir][ij].rcol!=0) return(0);
if (fullbot[ir]) return(0);
return(vspen(table[ir][ij].col));
}
vspen(s)
char *s;
{
if (s==0) return(0);
if (!point(s)) return(0);
return(match(s, SPAN));
}
at6.c ~±¤ # ‘¶# include "t..c"
maktab()
{
# 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;
int doubled[MAXCOL], acase[MAXCOL];
char *s;
for(icol=0; icol <ncol; icol++)
{
doubled[icol] = acase[icol] = 0;
printf(".nr %d 0\n", icol+CRIGHT);
for(ilin=0; ilin<nlin; ilin++)
{
if (instead[ilin]|| fullbot[ilin]) continue;
if (fspan(ilin,icol)) continue;
switch(ctype(ilin,icol))
{
case 'a':
acase[icol]=1;
case 'n':
if (table[ilin][icol].rcol!=0)
{
if (doubled[icol]==0)
printf(".nr %d 0\n.nr %d 0\n", S1, S2);
doubled[icol]=1;
if (real(s=table[ilin][icol].col))
{
printf(".nr %d ", TMP);
wide(s, FN(ilin,icol), SZ(ilin,icol)); printf("\n");
printf(".if \\n(%d<\\n(%d .nr %d \\n(%d\n", S1, TMP, S1, TMP);
}
if (real(s=table[ilin][icol].rcol))
{
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))
{
printf(".nr %d ", TMP);
wide(s, FN(ilin,icol), SZ(ilin,icol)); printf("\n");
printf(".if \\n(%d<\\n(%d .nr %d \\n(%d\n", icol+CRIGHT, TMP, icol+CRIGHT, TMP);
}
}
}
if (acase[icol])
printf(".if \\n(%d>=\\n(%d .nr %d \\n(%du+2n\n",S2,icol+CRIGHT,icol+CRIGHT,S2);
if (doubled[icol])
{
printf(".nr %d \\n(%d\n", icol+CMID, S1);
printf(".nr %d \\n(%d+\\n(%d\n",TMP,icol+CMID,S2);
printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n",TMP,icol+CRIGHT,icol+CRIGHT,TMP);
printf(".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])
{
printf(".nr %d %sn\n", TMP, cll[icol]);
printf(".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))
{
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(%d",CRIGHT+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 %d +\\n(%d/2\n", icol-k+ik+CMID, TMP);
printf(".nr %d +\\n(%d\n", icol-k+ik+CRIGHT, TMP);
}
}
}
/* 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(%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])
printf(".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 */
printf(".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)
{
printf(".nr %d 0", TMP);
for(icol=0; icol<ncol; icol++)
printf("+\\n(%d", icol+CRIGHT);
printf("\n");
printf(".nr %d \\n(.l-\\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 %d 0\n",CRIGHT-1);
tsep= (boxflg || allflg || dboxflg || left1flg) ? 1 : 0;
for(icol=0; icol<ncol; icol++)
{
printf(".nr %d \\n(%d+(%d*\\n(%d)\n",icol+CLEFT, icol+CRIGHT-1, tsep, TMP);
printf(".nr %d +\\n(%d\n",icol+CRIGHT, icol+CLEFT);
if (doubled[icol])
{
printf(".nr %d +\\n(%d\n", icol+CMID, icol+CLEFT);
/* printf(".if n .if \\n(%d%%24>0 .nr %d +12u\n",icol+CMID, icol+CMID); */
}
tsep=sep[icol];
}
if (rightl)
printf(".nr %d (\\n(%d+\\n(%d)/2\n",ncol+CRIGHT-1, ncol+CLEFT-1, ncol+CRIGHT-2);
printf(".nr TW \\n(%d\n", ncol+CRIGHT-1);
if (boxflg || allflg || dboxflg)
printf(".nr TW +%d*\\n(%d\n", sep[ncol-1], TMP);
printf(".if t .if (\\n(TW+\\n(.o)>7.75i .tm Table at line %d file %s is too wide - \\n(TW units\n", iline-1, ifile);
return;
}
wide(s, fn, size)
char *s, *size, *fn;
{
if (point(s))
{
printf("\\w%c", F1);
if (*fn>0) putfont(fn);
if (*size) putsize(size);
printf("%s", s);
if (*fn>0) putfont("P");
if (*size) putsize("0");
printf("%c",F1);
}
else
printf("\\n(%c-", s);
}
Tt7.c ~±¦ X ¶# include "t..c"
# define realsplit ((ct=='a'||ct=='n') && table[i][c].rcol)
runout()
{
int i, c;
if (boxflg || allflg || dboxflg) need();
if (ctrflg)
{
printf(".nr #I \\n(.i\n");
printf(".in +(\\n(.lu-\\n(TWu-\\n(.iu)/2u\n");
}
printf(".fc %c %c\n", F1, F2);
printf(".nr #T 0\n");
deftail();
for(i=0; i<nlin; i++)
putline(i,i);
if (leftover)
yetmore();
printf(".fc\n");
printf(".nr T. 1\n");
printf(".T# 1\n");
if (ctrflg)
printf(".in \\n(#Iu\n");
}
runtabs(i)
{
int c, ct;
printf(".ta ");
for(c=0; c<ncol; c++)
{
if (fspan(i,c))
continue;
switch(ct=ctype(i,c))
{
case 'n':
case 'a':
if (table[i][c].rcol)
if (lused[c]) /*Zero field width*/
printf("\\n(%du ",c+CMID);
case 'c':
case 'l':
case 'r':
if (realsplit? rused[c]: used[c])
printf("\\n(%du ",c+CRIGHT);
continue;
case 's':
if (lspan(i,c))
printf("\\n(%du ", c+CRIGHT);
continue;
}
}
printf("\n");
}
ifline(s)
char *s;
{
if (s[1] ) return(0);
if (s[0] == '_') return('-');
if (s[0] == '=') return('=');
return(0);
}
need()
{
int texlin, horlin, i;
for(texlin=horlin=i=0; i<nlin; i++)
{
if (fullbot[i]!=0)
horlin++;
else
if (instead[i]!=0)
continue;
else
texlin++;
}
printf(".ne %dv+%dp\n",texlin,2*horlin);
}
deftail()
{
int i, c, lf, lwid;
printf(".eo\n");
printf(".de T#\n");
printf(".ds #d .d\n");
printf(".if \\(ts\\n(.z\\(ts\\(ts .ds #d nl\n");
printf(".mk ##\n");
printf(".nr ## -1v\n");
for(i=0; i<MAXHEAD; i++)
if (linestop[i])
printf(".if \\n(#T>0 .nr #%c \\n(#T\n",linestop[i]+'a'-1);
if (boxflg || allflg || dboxflg) /* bottom of table line */
if (fullbot[nlin-1]==0)
{
printf(".if \\n(T. .vs2p\n");
printf(".if \\n(T. ");
drawline(nlin-1,0,ncol, dboxflg ? '=' : '-',1);
printf("\n.if \\n(T. .vs\n");
/* T. is really an argument to a macro but because of
eqn we don't dare pass it as an argument and reference by $1 */
}
for(c=0; c<ncol; c++)
{
if ((lf=left(nlin-1,c, &lwid))>=0)
{
printf(".if \\n(#%c>0 .sp -1\n",linestop[lf]+'a'-1);
printf(".if \\n(#%c>0 ", linestop[lf]+'a'-1);
tohcol(c);
drawvert(lf, nlin-1, c, lwid);
printf("\\h'|\\n(TWu'\n");
}
}
if (boxflg || allflg || dboxflg) /* right hand line */
{
printf(".if \\n(#a>0 .sp -1\n");
printf(".if \\n(#a>0 \\h'|\\n(TWu'");
drawvert (0, nlin-1, ncol, dboxflg? 2 : 1);
printf("\n");
}
printf("..\n");
printf(".ec\n");
}
t8.c ɆD U Ԧ# include "t..c"
# define realsplit ((ct=='a'||ct=='n') && table[nl][c].rcol)
int watchout;
int once;
putline(i, nl)
/* i is line number for deciding format */
/* nl is line number for finding data usually identical */
{
int c, lf, ct, form, lwid, vspf;
char *s, *size, *fn;
watchout=vspf=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 (point(s)) continue;
printf(".ne \\n(%c|u\n",s);
}
if (linestop[nl])
printf(".mk #%c\n", linestop[nl]+'a'-1);
lf = prev(nl);
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)
{
printf(".nr #^ \\n(\\*(#du\n");
printf(".nr #- \\n(#^\n"); /* current line position relative to bottom */
}
vspf=0;
for(c=0; c<ncol; c++)
{
s = table[nl][c].col;
if (s==0) continue;
if (point(s) ) continue;
lf=prev(nl);
if (lf>=0 && vspen(table[lf][c].col))
printf(".if (\\n(%c|+\\n(^%c-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(^%c-\\n(#--1v)\n",s,'a'+c,s,'a'+c);
else
printf(".if (\\n(%c|+\\n(#^-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(#^-\\n(#--1v)\n",s,s);
}
if (instead[nl])
{
puts(instead[nl]);
return;
}
if (fullbot[nl])
{
switch (ct=fullbot[nl])
{
case '=':
case '-':
fullwide(nl,ct);
}
return;
}
if (allflg && once>0 )
fullwide(i,'-');
once=1;
runtabs(i);
if (allh(i))
printf(".vs 2p\n");
printf("\\&");
for(c=0; c<ncol; c++)
{
if (rightl && c+1==ncol) continue;
if (i+1<nlin && (lf=left(i,c, &lwid))>=0)
{
tohcol(c);
drawvert(lf, i, c, lwid);
}
if ((form=ctype(i,c))!='s')
printf("\\h'|\\n(%du'",
((form=='n'||form=='a')&&lused[c]==0)?c+CMID:c+CLEFT);
s= table[nl][c].col;
fn = font[stynum[i]][c];
size = csize[stynum[i]][c];
if (*size==0)size=0;
switch(ct=ctype(i, c))
{
case 'n':
case 'a':
if (table[nl][c].rcol)
{
if (lused[c]) /*Zero field width*/
{
printf("%c%c",F1,F2);
puttext(table[nl][c].col,fn,size,nl,c);
printf("%c",F1);
}
s= table[nl][c].rcol;
form=1;
break;
}
case 'c':
form=3; break;
case 'r':
form=2; break;
case 'l':
form=1; break;
case '-':
case '=':
makeline(i,c,ct);
continue;
default:
continue;
}
if (realsplit ? rused[c]: used[c]) /*Zero field width*/
; else continue;
/* form: 1 left, 2 right, 3 center adjust */
if (ifline(s))
{
makeline(i,c,ifline(s));
continue;
}
printf("%c", F1);
if (form!= 1)
printf("%c", F2);
if (vspen(s))
vspf=1;
else
puttext(s, fn, size, nl,c);
if (form !=2)
printf("%c", F2);
printf("%c", F1);
/* if lines need to be split for gcos here is the place for a backslash */
}
printf("\n");
if (allh(i)) printf(".vs\n");
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)))
printf(".nr ^%c \\n(#^u\n", 'a'+c);
}
}
puttext(s,fn, size, ilin, icol)
char *s, *size, *fn;
{
int ip, cmidx;
/***/ register int *ct;
if (point(s))
{
putfont(fn);
putsize(size);
ip = prev(ilin);
/*** Temporary fudge because of stack overflow in c1
cmidx = ctop[stynum[ilin]][icol]==0;
***/ ct = ctop[stynum[ilin]]; cmidx = ct[icol]==0;
if (ip>=0)
if (vspen(table[ip][icol].col))
{
printf("\\v'-(\\n(\\*(#du-\\n(^%cu", icol+'a');
if (cmidx)
printf("-((\\n(#-u-\\n(^%cu)/2u)", icol+'a');
printf("'");
}
printf("%s",s);
if (ip>=0)
if (vspen(table[ip][icol].col))
{
printf("\\v'(\\n(\\*(#du-\\n(^%cu", icol+'a');
if (cmidx)
printf("-((\\n(#-u-\\n(^%cu)/2u)", icol+'a');
printf("'");
}
if (*fn>0) putfont("P");
if (size!=0) putsize("0");
}
else
watchout=1;
}
funnies( stl, lin)
{
/* write out funny diverted things */
int c, s;
char *fn;
/***/ register int *ct;
printf(".mk ##\n"); /* rmember current vertical position */
printf(".nr %d \\n(##\n", S1); /* bottom position */
for(c=0; c<ncol; c++)
{
s = table[lin][c].col;
if (point(s)) continue;
if (s==0) continue;
printf(".sp |\\n(##u-1v\n");
printf(".nr %d ", SIND);
switch(ctype(stl,c))
{
case 'n':
case 'c':
printf("(\\n(%du+\\n(%du-\\n(%c-u)/2u\n",c+CLEFT,c-1+ctspan(lin,c)+CRIGHT, s);
break;
case 'l':
case 'a':
printf("\\n(%du\n",c+CLEFT);
break;
case 'r':
printf("\\n(%du-\\n(%c-u\n", c+CRIGHT, s);
break;
}
printf(".in +\\n(%du\n", SIND);
fn=font[stynum[stl]][c];
putfont(fn);
if (stl>0 && vspen(table[prev(stl)][c].col))
{
printf(".sp |\\n(^%cu\n", 'a'+c);
/*** temporary fudge because of stack overflow in c1
if (ctop[stynum[stl]][c]==0)
***/ ct = ctop[stynum[stl]]; if (ct[c]==0)
{
printf(".nr %d \\n(#-u-\\n(^%c-\\n(%c|+1v\n",TMP, 'a'+c, s);
printf(".if \\n(%d>0 .sp \\n(%du/2u\n", TMP, TMP);
}
}
printf(".%c+\n",s);
printf(".in -\\n(%du\n", SIND);
if (*fn>0) putfont("P");
printf(".mk %d\n", S2);
printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", S2, S1, S1, S2);
}
printf(".sp |\\n(%du\n", S1);
}
putfont(fn)
char *fn;
{
if (fn && *fn)
printf( fn[1] ? "\\f(%.2s" : "\\f%.2s", fn);
}
putsize(s)
char *s;
{
if (s && *s)
printf("\\s%s",s);
}
ot9.c ~±« Ó ¶# include "t..c"
yetmore()
{
int icol, ch;
while (gets1(cstore=cspace))
{
if (prefix(".TE", cstore))
break;
if (cstore[0] == '.' && letter(cstore[1]))
{
puts(cstore);
continue;
}
instead[0]=fullbot[0]=0;
if (cstore[1]==0)
switch(cstore[0])
{
case '_': fullbot[0]= '-'; putline(nlin-1,0); continue;
case '=': fullbot[0]= '='; putline(nlin-1, 0); continue;
}
for (icol = 0; icol <ncol; icol++)
{
table[0][icol].col = cstore;
table[0][icol].rcol=0;
for(; (ch= *cstore) != '\0' && ch != tab; cstore++)
;
*cstore++ = '\0';
switch(ctype(nlin-1,icol))
{
case 'n':
table[0][icol].rcol = maknew(table[0][icol].col);
break;
case 'a':
table[0][icol].rcol = table[0][icol].col;
table[0][icol].col= "";
break;
}
while (ctype(nlin-1,icol+1)== 's') /* spanning */
table[0][++icol].col = "";
if (ch == '\0') break;
}
while (++icol <ncol)
table[0][icol].col = "";
putline(nlin-1,0);
}
last =cstore;
return;
}
]tb.c ~± ( ¶# include "t..c"
checkuse()
{
int i,c, k;
for(c=0; c<ncol; c++)
{
used[c]=lused[c]=rused[c]=0;
for(i=0; i<nlin; i++)
{
if (instead[i] || fullbot[i]) continue;
k = ctype(i,c);
if (k== '-' || k == '=') continue;
if ((k=='n'||k=='a'))
{
lused[c] =| real(table[i][c].col);
rused[c]=| real(table[i][c].rcol);
if( !real(table[i][c].rcol))
used[c] =| real(table[i][c].col);
}
else
used[c] =| real(table[i][c].col);
}
}
}
real(s)
char *s;
{
if (s==0) return(0);
if (!point(s)) return(1);
if (*s==0) return(0);
return(1);
}
int spcount 0;
# define MAXVEC 20
char *spvecs[MAXVEC];
chspace()
{
char *pp;
if (spvecs[spcount])
return(spvecs[spcount++]);
if (spcount>=MAXVEC)
error("Too many characters in table");
spvecs[spcount++]= pp = calloc(MAXCHS+200,1);
if (pp== -1)
error("no space for characters");
return(pp);
}
# define MAXPC 50
char *thisvec;
int tpcount -1;
char *tpvecs[MAXPC];
alocv(n)
{
int *tp;
if (tpcount<0 || thisvec+n > tpvecs[tpcount]+MAXCHS)
{
tpcount++;
if (tpvecs[tpcount]==0)
{
tpvecs[tpcount] = calloc(MAXCHS,1);
}
thisvec = tpvecs[tpcount];
if (thisvec == -1)
error("no space for vectors");
}
tp=thisvec;
thisvec=+n;
return(tp);
}
release()
{
extern char *exstore;
/* give back unwanted space in some vectors */
spcount=0;
tpcount= -1;
exstore=0;
}
tc.c ~±¯ ¶# include "t..c"
choochar()
{
/* choose funny characters to delimit fields */
int had[128], ilin,icol, k;
char *s;
for(icol=0; icol<128; icol++)
had[icol]=0;
F1 = F2 = 0;
for(ilin=0;ilin<nlin;ilin++)
{
if (instead[ilin]) continue;
if (fullbot[ilin]) continue;
for(icol=0; icol<ncol; icol++)
{
k = ctype(ilin, icol);
if (k==0 || k == '-' || k == '=')
continue;
s = table[ilin][icol].col;
if (point(s))
while (*s)
had[*s++]=1;
s=table[ilin][icol].rcol;
if (point(s))
while (*s)
had[*s++]=1;
}
}
/* choose first funny character */
for(
s="\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*ABCDEFGHIJKMNOPQRSTUVWXYZabcdefgjkoqrstwxyz";
*s; s++)
{
if (had[*s]==0)
{
F1= *s;
had[F1]=1;
break;
}
}
/* choose second funny character */
for(
s="\002\003\005\006\007:_~^`@;,<=>#%&!/?{}+-*ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstuwxyz";
*s; s++)
{
if (had[*s]==0)
{
F2= *s;
break;
}
}
if (F1==0 || F2==0)
error("couldn't find characters to use for delimiters");
return;
}
point(s)
{
return(s>= 128 || s<0);
}
ste.c ~±² ” ¶# include "t..c"
error(s)
char *s;
{
printf(2, "\n%s: line %d: %s\n", ifile, iline, s);
# ifdef unix
printf(2, "tbl quits\n");
cexit(1);
# endif
# ifdef gcos
printf(2, "run terminated due to error condition detected by tbl preprocessor\n");
cexit(0);
# endif
}
gets1(s)
char *s;
{
char *p;
iline++;
p=gets(s);
while (*s) s++;
s--;
if (*s == '\\')
gets1(s);
return(p);
}
# define BACKMAX 500
char backup[BACKMAX];
char *backp backup;
un1getc(c, f)
{
if (c=='\n')
iline--;
*backp++ = c;
if (backp >= backup+BACKMAX)
error("too much backup");
}
get1char()
{
int c;
if (backp>backup)
c = *--backp;
else
c=getchar();
if (c== '\n')
iline++;
return(c);
}
tf.c ~±´ ² ¶# include "t..c"
savefill()
{
/* remembers the status of fill mode in nr 45 (SF) */
/* nr SF = 0 means no fill, 1 means fill */
printf(".nr %d \\n(.u\n", SF);
printf(".nf\n");
}
rstofill()
{
printf(".if \\n(%d>0 .fi\n", SF);
}
endoff()
{
int i;
for(i=0; i<MAXHEAD; i++)
if (linestop[i])
printf(".nr #%c 0\n", 'a'+i);
printf("%s\n", last);
}
ifdivert()
{
printf(".ds #d .d\n");
printf(".if \\(ts\\n(.z\\(ts\\(ts .ds #d nl\n");
}
tg.c ~±¶ þ ¶# include "t..c"
gettext(sp, ilin,icol, fn, sz)
char *sp, *fn, *sz;
{
/* get a section of text */
char line[256];
if (texname >'z') error("Too many text block diversions");
printf(".br\n");
printf(".di %c+\n", texname);
if (textflg==0)
{
printf(".nr %d \\n(.lu\n", TMP); /* remember old line length */
textflg=1;
}
rstofill();
if (fn && *fn) printf(".ft %s\n", fn);
if (sz && *sz) printf(".ps %s\n.vs \\n(.s+2\n",sz);
if (cll[icol][0])
printf(".ll %sn\n", cll[icol]);
else
printf(".ll \\n(%du*%du/%du\n",TMP,ctspan(ilin,icol),ncol+1);
while (gets1(line))
{
if (line[0]=='T' && line[1]=='}' && line[2]== tab) break;
if (match("T}", line)) break;
printf("%s\n", line);
}
if (fn && *fn) printf(".ft P\n");
if (sz && *sz) printf(".br\n.ps\n.vs\n");
printf(".br\n");
printf(".di\n");
printf(".nr %c| \\n(dn\n", texname);
printf(".nr %c- \\n(dl\n", texname);
/* copy remainder of line */
if (line[2])
tcopy (sp, line+3);
else
*sp=0;
return(texname++);
}
untext()
{
printf(".nf\n");
printf(".ll \\n(%du\n", TMP);
}
ti.c ~±¸ ¹ ¶# include "t..c"
/* determine local environment for intersections */
interv(i,c)
{
int ku, kl;
if (c>=ncol)
{
if (dboxflg)
{
if (i==0) return(BOT);
if (i>=nlin-1) return(TOP);
return(THRU);
}
return(0);
}
ku = i>0 ? lefdata(i-1,c) : 0;
if (i+1 >= nlin)
kl=0;
else
kl = lefdata(allh(i) ? i+1 : i, c);
if (ku==2 && kl==2) return(THRU);
if (ku ==2) return(TOP);
if (kl==BOT) return(2);
return(0);
}
interh(i,c)
{
int kl, kr;
if (fullbot[i]== '=' || (dboxflg && (i==0 || i>= nlin-1)))
{
if (c==ncol)
return(LEFT);
if (c==0)
return(RIGHT);
return(THRU);
}
if (i>=nlin) return(0);
kl = c>0 ? thish (i,c-1) : 0;
if (kl<=1 && i>0 && allh(up1(i)))
kl = c>0 ? thish(up1(i),c-1) : 0;
kr = thish(i,c);
if (kr<=1 && i>0 && allh(up1(i)))
kr = c>0 ? thish(up1(i), c) : 0;
if (kl== '=' && kr == '=') return(THRU);
if (kl== '=') return(LEFT);
if (kr== '=') return(RIGHT);
return(0);
}
up1(i)
{
i--;
while (instead[i] && i>0) i--;
return(i);
}
ftm.c ~±» ¶# include "t..c"
maknew(str)
char *str;
{
/* make two numerical fields */
int dpoint, c;
char *p, *q, *ba;
p = str;
for (ba= 0; c = *str; str++)
if (c == '\\' && *(str+1)== '&')
ba=str;
str=p;
if (ba==0)
{
for (dpoint=0; *str; str++)
if (*str=='.' &&
(str>p && digit(*(str-1)) ||
digit(*(str+1))))
dpoint=str;
if (!dpoint && *(str-1)== '$')
return(0);
if (dpoint==0)
for(; str>p; str--)
{
if (digit( * (str-1) ) )
break;
}
if (!dpoint && p==str) /* not numerical, don't split */
return(0);
if (dpoint) str=dpoint;
}
else
str = ba;
p =str;
if (exstore ==0 || exstore >exlim)
{
exstore = chspace();
exlim= exstore+MAXCHS;
}
q = exstore;
while (*exstore++ = *str++);
*p = 0;
return(q);
}
ts.c ~±½ Î ¶match (s1, s2)
char *s1, *s2;
{
while (*s1 == *s2)
if (*s1++ == '\0')
return(1);
else
s2++;
return(0);
}
prefix(small, big)
char *small, *big;
{
int c;
while ((c= *small++) == *big++)
if (c==0) return(1);
return(c==0);
}
letter (ch)
{
if (ch >= 'a' && ch <= 'z')
return(1);
if (ch >= 'A' && ch <= 'Z')
return(1);
return(0);
}
numb(str)
char *str;
{
/* convert to integer */
int k;
for (k=0; *str >= '0' && *str <= '9'; str++)
k = k*10 + *str - '0';
return(k);
}
digit(x)
{
return(x>= '0' && x<= '9');
}
max(a,b)
{
return( a>b ? a : b);
}
index (s,c)
char *s;
{
int k;
for(k=0; s[k]; k++)
if (s[k]==c)
return(k);
return(-1);
}
tcopy (s,t)
char *s, *t;
{
while (*s++ = *t++);
}
tt.c ~±¿ ø ¶# include "t..c"
ctype(il, ic)
{
if (instead[il])
return(0);
if (fullbot[il])
return(0);
il = stynum[il];
return(style[il][ic]);
}
min(a,b)
{
return(a<b ? a : b);
}
fspan(i,c)
{
c++;
return(c<ncol && ctype(i,c)=='s');
}
lspan(i,c)
{
int k;
if (ctype(i,c) != 's') return(0);
c++;
if (c < ncol && ctype(i,c)== 's')
return(0);
for(k=0; ctype(i,--c) == 's'; k++);
return(k);
}
ctspan(i,c)
{
int k;
c++;
for(k=1; c<ncol && ctype(i,c)=='s'; k++)
c++;
return(k);
}
tohcol(ic)
{
if (ic==0)
printf("\\h'|0'");
else
printf("\\h'(|\\n(%du+|\\n(%du)/2u'", ic+CLEFT, ic+CRIGHT-1);
}
allh(i)
{
/* return true if every element in line i is horizontal */
/* also at least one must be horizontl */
int c, one, k;
if (fullbot[i]) return(1);
for(one=c=0; c<ncol; c++)
{
k = thish(i,c);
if (k==0) return(0);
if (k==1) continue;
one=1;
}
return(one);
}
thish(i,c)
{
int t;
char *s;
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);
s= table[i][c].col;
if (s==0 || (point(s) && *s==0))
return(1);
if (vspen(s)) return(1);
if (t=barent( s))
return(t);
return(0);
}
tu.c ~±Á ë ¶# include "t..c"
makeline(i,c,lintype)
{
int cr, type;
type = thish(i,c);
if (type==0) return;
if (c>0 && thish(i,c-1) == type)return;
for(cr=c; cr < ncol && (ctype(i,cr)=='s'||type==thish(i,cr)); cr++);
drawline(i, c, cr-1, lintype,0);
}
fullwide(i, lintype)
{
int cr, cl;
printf(".vs 2p\n");
cr= 0;
while (cr<ncol)
{
cl=cr;
while (i>0 && vspand(i-1,cl))
cl++;
for(cr=cl; cr<ncol; cr++)
if (i>0 && vspand(i-1,cr))
break;
if (cl<ncol)
drawline(i,cl,cr,lintype,1);
}
printf("\n.vs\n");
}
drawline(i, cl, cr, lintype, noheight)
{
char *exhr, *exhl;
int lcount, ln, linpos, oldpos, nodata;
lcount=0;
exhr=exhl= "";
switch(lintype)
{
case '-': lcount=1;break;
case '=': lcount=2;break;
}
if (lcount<=0) return;
nodata = cr-cl>=ncol || noheight || allh(i);
if (!nodata)
printf("\\v'-.5m'");
for(ln=oldpos=0; ln<lcount; ln++)
{
linpos = 2*ln - lcount +1;
if (linpos != oldpos)
printf("\\v'%dp'", linpos-oldpos);
oldpos=linpos;
tohcol(cl);
if (lcount>1)
{
switch(interv(i,cl))
{
case TOP: exhl = ln==0 ? "1p" : "-1p"; break;
case BOT: exhl = ln==1 ? "1p" : "-1p"; break;
case THRU: exhl = "-1p"; break;
}
if (exhl[0])
printf("\\h'%s'", exhl);
}
else if (lcount==1)
{
switch(interv(i,cl))
{
case TOP: case BOT: exhl = "-1p"; break;
case THRU: exhl = "1p"; break;
}
if (exhl[0])
printf("\\h'%s'", exhl);
}
if (lcount>1)
{
switch(interv(i,cr+1))
{
case TOP: exhr = ln==0 ? "-1p" : "+1p"; break;
case BOT: exhr = ln==1 ? "-1p" : "+1p"; break;
case THRU: exhr = "-1p"; break;
}
}
else if (lcount==1)
{
switch(interv(i,cr+1))
{
case TOP: case BOT: exhr = "+1p"; break;
case THRU: exhr = "-1p"; break;
}
}
if (cr+1>=ncol)
printf("\\l'|\\n(TWu%s\\(ul'", exhr);
else
printf("\\l'(|\\n(%du+|\\n(%du)/2u%s\\(ul'", cr+CRIGHT, cr+1+CLEFT, exhr);
}
if (oldpos!=0)
printf("\\v'%dp'", -oldpos);
if (!nodata)
printf("\\v'+.5m'");
}
getstop()
{
int i,c,k,junk, stopp;
stopp=1;
for(i=0; i<MAXLIN; i++)
linestop[i]=0;
for(i=0; i<nlin; i++)
for(c=0; c<ncol; c++)
{
k = left(i,c,&junk);
if (k>=0 && linestop[k]==0)
linestop[k]= ++stopp;
}
if (boxflg || allflg || dboxflg)
linestop[0]=1;
}
left(i,c, lwidp)
int *lwidp;
{
int kind, li;
/* returns -1 if no line to left */
/* returns number of line where it starts */
/* stores into lwid the kind of line */
*lwidp=0;
kind = lefdata(i,c);
if (kind==0) return(-1);
if (i+1<nlin)
if (lefdata(next(i),c)== kind) return(-1);
while (i>=0 && lefdata(i,c)==kind)
i=prev(li=i);
if (prev(li)== -1) li=0;
*lwidp=kind;
return(li);
}
lefdata(i,c)
{
int ck;
if (i>=nlin) i=nlin-1;
if (ctype(i,c) == 's')
{
for(ck=c; ctype(i,ck)=='s'; ck--);
if (thish(i,ck)==0)
return(0);
}
i =stynum[i];
i = lefline[i][c];
if (i>0) return(i);
if (dboxflg && c==0) return(2);
if (allflg)return(1);
if (boxflg && c==0) return(1);
return(0);
}
next(i)
{
while (i+1 <nlin)
{
i++;
if (!fullbot[i] && !instead[i]) break;
}
return(i);
}
prev(i)
{
while (--i >=0 && (fullbot[i] || instead[i]))
;
return(i);
}
tv.c ~±Ä ¶# include "t..c"
drawvert(start,end, c, lwid)
{
char *exb1, *exb2, *ext1, *ext2;
int sl, ln, tp, pos;
tp =exb1 =exb2 =ext1 = ext2 = 0;
end++;
while (instead[end]) end++;
for(ln=0; ln<lwid; ln++)
{
pos = 2*ln-lwid+1;
if (pos!=tp) printf("\\h'%dp'", pos-tp);
tp = pos;
if (end<nlin)
{
if (fullbot[end]|| (!instead[end] && allh(end)))
exb1= "2p";
else
switch (midbar(end,c))
{
case '-':
exb1 = "(1v-.5m)"; break;
case '=':
exb1 = "(1v-.5m+1p)"; break;
}
}
if (lwid>1)
switch(interh(end, c))
{
case THRU: exb2 ="-1p"; break;
case RIGHT: exb2 = ln==0 ? "1p" : "-1p";break;
case LEFT: exb2 = ln==1 ? "1p" : "-1p"; break;
}
if (lwid==1)
switch(interh(end,c))
{
case THRU: exb2 = "-1p"; break;
case RIGHT: case LEFT: exb2 = "1p"; break;
}
if (start>0)
{
sl = start-1;
while (instead[sl]&&sl>=0) sl--;
if (fullbot[sl] || allh(sl))
ext1 = "0p";
else
if (sl>=0)
switch(midbar(sl,c))
{
case '-':
ext1= ".5m"; break;
case '=':
ext1= "(.5m+1p)"; break;
default:
ext1 = "-2p"; break;
}
else
ext1 = "2p";
}
if (lwid>1)
switch(interh(start,c))
{
case THRU: ext2 = "1p"; break;
case LEFT: ext2 = ln==0 ? "1p" : "-1p"; break;
case RIGHT: ext2 = ln==1 ? "1p" : "-1p"; break;
}
else if (lwid==1)
switch(interh(start,c))
{
case THRU: ext2 = "1p"; break;
case LEFT: case RIGHT: ext2 = "-1p"; break;
}
if (exb1)
printf("\\v'%s'", exb1);
if (exb2)
printf("\\v'%s'", exb2);
printf("\\L'|\\n(#%cu-1v", linestop[start]+'a'-1);
if (ext1)
printf("-%s",ext1);
if (ext2)
printf("+%s", ext2);
if (exb1)
printf("-%s", exb1);
if (exb2)
printf("-%s", exb2);
/* the string #d is either "nl" or ".d" depending
on diversions; on GCOS not the same */
printf("'\\v'\\n(\\*(#du-\\n(#%cu+1v", linestop[start]+'a'-1);
if (ext1)
printf("+%s",ext1);
if (ext2)
printf("-%s", ext2);
printf("'");
}
}
midbar(i,c)
{
int k;
k = midbcol(i,c);
if (k==0 && c>0)
k = midbcol(i, c-1);
return(k);
}
midbcol(i,c)
{
int ct;
while ( (ct=ctype(i,c)) == 's')
c--;
if (ct=='-' || ct == '=')
return(ct);
if (ct=barent(table[i][c].col))
return(ct);
return(0);
}
barent(s)
char *s;
{
if (s==0) return (1);
if (s[1]!= 0)
return(0);
switch(s[0])
{
case '_':
return('-');
case '=':
return('=');
}
return(0);
}