4.3BSD nroff patches for System V machines
Christos S. Zoulas
christos at theory.tn.cornell.edu
Thu Mar 7 10:11:03 AEST 1991
Hello,
I just happened to be on a system V box that did not come with nroff, so
ported 4.3BSD nroff for it. The only problem was that nroff contains code
to read the term ``.o'' files which are in "a.out" format, but couldn't read
the ``.o'' files in "COFF" format.
The following patch adds COFF support to nroff, and support for boldfacing.
[the boldfacing patch is courtesy of Lawrence Crowl <crowl at cs.rochester.edu>]
You'll need to define COFF in your Makefile if you are on a system V machine.
christos
*** n10.c.dist Tue Jan 31 18:45:56 1989
--- n10.c Wed Mar 6 18:12:48 1991
***************
*** 1,3 ****
--- 1,4 ----
+
#ifndef lint
static char sccsid[] = "@(#)n10.c 4.2 4/17/85";
#endif lint
***************
*** 10,15 ****
--- 11,21 ----
#include "v.h"
extern
#include "tw.h"
+ #ifdef COFF
+ #include <aouthdr.h>
+ #include <filehdr.h>
+ #include <scnhdr.h>
+ #endif
/*
nroff10.c
***************
*** 49,54 ****
--- 55,64 ----
char *q;
int x[8];
extern char *setbrk();
+ #ifdef COFF
+ struct scnhdr sec;
+ struct filehdr hdr;
+ #endif
if(((i=open(termtab,0)) < 0) && (i=open("/usr/lib/term/tab37",0)) < 0){
prstr("Cannot open ");
***************
*** 56,61 ****
--- 66,72 ----
prstr("\n");
exit(-1);
}
+ #ifndef COFF
read(i,(char *)x,8*sizeof(int));
read(i,(char *)&t.bset,j = sizeof(int)*((int *)&t.zzz - &t.bset));
x[2] -= j;
***************
*** 71,76 ****
--- 82,144 ----
dtab = 8 * t.Em;
for(i=0; i<16; i++)tabtab[i] = dtab * (i+1);
if(eqflg)t.Adj = t.Hor;
+ #else
+ if (read(i, (char *) &hdr, sizeof(struct filehdr)) !=
+ sizeof(struct filehdr)) {
+ prstr("Error reading ");
+ prstr(termtab);
+ prstr(" file header.\n");
+ exit(-1);
+ }
+ if (!ISCOFF(hdr.f_magic)) {
+ prstr("Error reading ");
+ prstr(termtab);
+ prstr(" (not a coff file)\n");
+ exit(-1);
+ }
+ while (hdr.f_opthdr--) if (read(i, (char *) &sec, 1) != 1) {
+ prstr("Error reading ");
+ prstr(termtab);
+ prstr(" optional header.\n");
+ exit(-1);
+ }
+ if (read(i, (char *) &sec, sizeof(struct scnhdr)) !=
+ sizeof(struct scnhdr)) {
+ prstr("Error reading ");
+ prstr(termtab);
+ prstr(" section header.\n");
+ exit(-1);
+ }
+ if (strcmp(sec.s_name, _DATA) != 0) {
+ prstr("Wrong section type ");
+ prstr(sec.s_name);
+ prstr(" in ");
+ prstr(termtab);
+ prstr(".\n");
+ exit(-1);
+ }
+
+ if (lseek(i, sec.s_scnptr, 0) == -1) {
+ prstr("Error seeking to data section in ");
+ prstr(termtab);
+ prstr(".\n");
+ exit(-1);
+ }
+ read(i,(char *)&t.bset,j = sizeof(int)*((int *)&t.zzz - &t.bset));
+ x[2] -= j;
+ q = setbrk(x[2]);
+ lseek(i,(long)t.twinit + sec.s_scnptr,0);
+ i = read(i,q,x[2]);
+ j = q - t.twinit;
+ for(p = &t.twinit; p < &t.zzz; p++){
+ if(*p)*p += j;else *p = "";
+ }
+ sps = EM;
+ ics = EM*2;
+ dtab = 8 * t.Em;
+ for(i=0; i<16; i++)tabtab[i] = dtab * (i+1);
+ if(eqflg)t.Adj = t.Hor;
+ #endif /* COFF */
}
twdone(){
obufp = obuf;
***************
*** 113,118 ****
--- 181,192 ----
register char *codep;
extern char *plot();
int *q, w, j, phyw;
+ int underlining_ok; /* boolean, true iff we are allowed to
+ underline this character, we interpret this
+ to also mean allow simulating boldface using
+ backspacing */
+ int bold_toggle; /* boolean, true iff the terminal has hardware
+ bolding capability */
for(q=oline; q<olinep; q++){
if((i = *q) & MOT){
***************
*** 131,136 ****
--- 205,211 ----
continue;
}
codep = t.codetab[k-32];
+ underlining_ok = (*codep & 0200);
w = t.Char * (*codep++ & 0177);
phyw = w;
if(i&ZBIT)w = 0;
***************
*** 137,143 ****
if(*codep && (esc || lead))move();
esct += w;
if(i&074000)xfont = (i>>9) & 03;
! if(*t.bdon & 0377){
if(!bdmode && (xfont == 2)){
oputs(t.bdon);
bdmode++;
--- 212,219 ----
if(*codep && (esc || lead))move();
esct += w;
if(i&074000)xfont = (i>>9) & 03;
! bold_toggle = t.bdon && (*t.bdon & 0377);
! if(bold_toggle){
if(!bdmode && (xfont == 2)){
oputs(t.bdon);
bdmode++;
***************
*** 147,156 ****
bdmode = 0;
}
}
- if(xfont == ulfont){
- for(k=w/t.Char;k>0;k--)oput('_');
- for(k=w/t.Char;k>0;k--)oput('\b');
- }
while(*codep != 0){
if(*codep & 0200){
codep = plot(codep);
--- 223,228 ----
***************
*** 158,166 ****
oput(' ');
}else{
if(plotmode)oputs(t.plotoff);
! *obufp++ = *codep++;
! if(obufp == (obuf + OBUFSZ + ascii - 1))flusho();
! /* oput(*codep++);*/
}
}
if(!w)for(k=phyw/t.Char;k>0;k--)oput('\b');
--- 230,245 ----
oput(' ');
}else{
if(plotmode)oputs(t.plotoff);
! if(underlining_ok){
! if(xfont == ulfont){
! oput('_');
! oput('\b');
! }else if(xfont == 2 && !bold_toggle){
! oput(*codep);
! oput('\b');
! }
! }
! oput(*codep++);
}
}
if(!w)for(k=phyw/t.Char;k>0;k--)oput('\b');
--
+------------------------------------------------------------------------+
| Christos Zoulas | 389 Theory Center, Electrical Engineering, |
| christos at ee.cornell.edu | Cornell University, Ithaca NY 14853. |
| christos at crnlee.bitnet | Phone: (607) 255 0302 | Fax: (607) 254 4565 |
More information about the Alt.sources
mailing list