static char sccsid
[]="@(#)n10.c 1.2 (CWI) 86/08/15";
struct t t
; /* terminal characteristics */
char xchname
[4 * (NROFFCHARS
-128)]; /* hy, em, etc. */
short xchtab
[NROFFCHARS
-128]; /* indexes into chname[] */
int nfonts
= 4; /* R, I, B, S */
/* these characters are used as various signals or values
/* in miscellaneous places.
/* values are set in specnames in t10.c
register char *p
, *cp
, *q
;
extern char *skipstr(), *getstr(), *getint();
strcat(termtab
, devname
);
if ((fd
= open(termtab
, 0)) < 0) {
errprint("cannot open %s", termtab
);
codestr
= setbrk((int) stbuf
.st_size
);
nread
= read(fd
, codestr
, (int) stbuf
.st_size
);
p
= skipstr(p
); /* skip over type, could check */
p
= skipstr(p
); p
= getint(p
, &t
.bset
);
p
= skipstr(p
); p
= getint(p
, &t
.breset
);
p
= skipstr(p
); p
= getint(p
, &t
.Hor
);
p
= skipstr(p
); p
= getint(p
, &t
.Vert
);
p
= skipstr(p
); p
= getint(p
, &t
.Newline
);
p
= skipstr(p
); p
= getint(p
, &t
.Char
);
p
= skipstr(p
); p
= getint(p
, &t
.Em
);
p
= skipstr(p
); p
= getint(p
, &t
.Halfline
);
p
= skipstr(p
); p
= getint(p
, &t
.Adj
);
p
= skipstr(p
); p
= getstr(p
, t
.twinit
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.twrest
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.twnl
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.hlr
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.hlf
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.flr
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.bdon
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.bdoff
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.iton
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.itoff
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.ploton
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.plotoff
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.up
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.down
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.right
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.left
= p
);
p
= skipstr(p
); p
= getstr(p
, t
.eject
= p
);
if (strcmp(check
, "charset") != 0) {
errprint("device table apparently curdled");
for (i
= 0; i
< 128; i
++)
t
.width
[i
] = 1; /* default ascii widths */
/* this ought to be a pointer array and in place in codestr */
cp
= chname
+ 1; /* bug if starts at 0, in setch */
while (p
< codestr
+ nread
) {
while (*p
== ' ' || *p
== '\t' || *p
== '\n')
chtab
[i
] = cp
- chname
; /* index, not pointer */
*cp
++ = *p
++; /* 2-char names */
while (*p
== ' ' || *p
== '\t')
t
.width
[i
+128] = *p
++ - '0';
while (*p
== ' ' || *p
== '\t')
p
= getstr(p
, p
); /* compress string */
tabtab
[i
] = dtab
* (i
+ 1);
ll
= ll1
= lt
= lt1
= LL
;
smnt
= nfonts
= 5; /* R I B BI S */
specnames(); /* install names like "hyphen", etc. */
char *skipstr(s
) /* skip over leading space plus string */
while (*s
== ' ' || *s
== '\t' || *s
== '\n')
while (*s
!= ' ' && *s
!= '\t' && *s
!= '\n')
char *getstr(s
, t
) /* find next string in s, copy to t */
while (*s
== ' ' || *s
== '\t' || *s
== '\n')
if (quote
&& *s
== '"') {
if (!quote
&& (*s
== ' ' || *s
== '\t' || *s
== '\n'))
if (isdigit(s
[0]) && isdigit(s
[1]) && isdigit(s
[2])) {
*t
++ = (s
[0]-'0')<<6 | (s
[1]-'0')<<3 | s
[2]-'0';
} else if (isdigit(s
[0])) {
char *getint(s
, pn
) /* find integer at s */
while (*s
== ' ' || *s
== '\t' || *s
== '\n')
*pn
= 10 * *pn
+ *s
++ - '0';
for (i
= 0; spnames
[i
].n
; i
++)
*spnames
[i
].n
= findch(spnames
[i
].v
);
findch(s
) /* find char s in chname */
for (i
= 0; chtab
[i
] != 0; i
++)
if (strcmp(s
, &chname
[chtab
[i
]]) == 0)
if (olinep
>= &oline
[LNSIZE
])
lead
+= dip
->blss
+ lss
- t
.Newline
;
static int oxfont
= FT
; /* start off in roman */
for (q
= oline
; q
< olinep
; q
++) {
if ((k
= cbits(i
)) <= 040) {
phyw
= w
= t
.Char
* t
.width
[k
];
case ULFONT
: oputs(t
.itoff
); break;
case BDFONT
: oputs(t
.bdoff
); break;
case BIFONT
: oputs(t
.itoff
); oputs(t
.bdoff
); break;
if (*t
.iton
& 0377) oputs(t
.iton
); break;
if (*t
.bdon
& 0377) oputs(t
.bdon
); break;
if (*t
.bdon
& 0377) oputs(t
.bdon
);
if (*t
.iton
& 0377) oputs(t
.iton
);
if ((xfont
== ULFONT
|| xfont
== BIFONT
) && !(*t
.iton
& 0377)) {
for (j
= w
/ t
.Char
; j
> 0; j
--)
for (j
= w
/ t
.Char
; j
> 0; j
--)
if (!(*t
.bdon
& 0377) && ((j
= bdtab
[xfont
]) || xfont
== BDFONT
|| xfont
== BIFONT
))
j
= 1; /* number of overstrikes for bold */
if (k
< 128) { /* ordinary ascii */
codep
= t
.codetab
[k
-128];
if (*codep
== '%') /* escape */
for (j
= oj
; --j
> 0; ) {
for (j
= phyw
/ t
.Char
; j
> 0; j
--)
if (*k
== '%') { /* quote char within plot mode */
if ((i
= *k
& 037) == 0) { /* 2nd 0200 turns it off */
/* if(!esct)i = t.flr; else i = "\0";*/
lead
= lead
% t
.Halfline
;
} else { /* no half-line forward, not at line begining */
while ((dt
= dtab
- (iesct
% dtab
)) <= esc
) {
if ((*t
.ploton
& 0377) && (esc
|| lead
)) {