Checkpoint.
diff --git a/src/cmd/postscript/tr2post/Bgetfield.c b/src/cmd/postscript/tr2post/Bgetfield.c
index 8922139..974fce6 100644
--- a/src/cmd/postscript/tr2post/Bgetfield.c
+++ b/src/cmd/postscript/tr2post/Bgetfield.c
@@ -4,9 +4,6 @@
 #include "../common/common.h"
 #include "tr2post.h"
 
-#undef isspace
-#define isspace bisspace
-
 int
 isspace(Rune r)
 {
@@ -14,7 +11,7 @@
 }
 
 int
-Bskipws(Biobuf *bp) {
+Bskipws(Biobufhdr *bp) {
 	int r;
 	char c[UTFmax];
 	int sindex = 0;
@@ -36,13 +33,15 @@
 
 int
 asc2dig(char c, int base) {
-	if (c >= '0' && c <= '9')
+	if (c >= '0' && c <= '9'){
 		if (base == 8 && c > '7') return(-1);
 		else return(c - '0');
+	}
 
-	if (base == 16)
+	if (base == 16){
 		if (c >= 'a' && c <= 'f') return(10 + c - 'a');
 		else if (c >= 'A' && c <= 'F') return(10 + c - 'A');
+	}
 
 	return(-1);
 }
@@ -55,7 +54,7 @@
  */
 
 int
-Bgetfield(Biobuf *bp, int type, void *thing, int size) {
+Bgetfield(Biobufhdr *bp, int type, void *thing, int size) {
 	int r;
 	Rune R;
 	char c[UTFmax];
diff --git a/src/cmd/postscript/tr2post/chartab.c b/src/cmd/postscript/tr2post/chartab.c
index 87ab556..89bf0ff 100644
--- a/src/cmd/postscript/tr2post/chartab.c
+++ b/src/cmd/postscript/tr2post/chartab.c
@@ -120,30 +120,31 @@
 	return(-1);
 }
 
-char postroffdirname[] = "#9/sys/lib/postscript/troff";		/* "/sys/lib/postscript/troff/"; */
-char troffmetricdirname[] = "#9/sys/lib/troff/font";	/* "/sys/lib/troff/font/devutf/"; */
+char postroffdirname[] = LIBDIR "/postscript/troff";		/* "/sys/lib/postscript/troff/"; */
+char troffmetricdirname[] = LIBDIR "/troff/font";	/* "/sys/lib/troff/font/devutf/"; */
 
 int
 readpsfontdesc(char *fontname, int trindex) {
 	static char *filename = 0;
 	Biobuf *bfd;
-	Biobuf *Bfd;
+	Biobufhdr *Bfd;
 	int warn = 0, errorflg = 0, line =1, rv;
 	int start, end, offset;
 	int startfont, endfont, startchar, endchar, i, pfid;
 	char psfontnam[128];
 	struct troffont *tp;
+/*	struct charent *cp[]; */
 
 	if (debug) Bprint(Bstderr, "readpsfontdesc(%s,%d)\n", fontname, trindex);
 	filename=galloc(filename, strlen(postroffdirname)+1+strlen(fontname)+1, "readpsfontdesc: cannot allocate memory\n");
 	sprint(filename, "%s/%s", postroffdirname, fontname);
 
-	bfd = Bopen(unsharp(filename), OREAD);
+	bfd = Bopen(filename, OREAD);
 	if (bfd == 0) {
 		error(WARNING, "cannot open file %s\n", filename);
 		return(0);
 	}
-	Bfd = bfd;
+	Bfd = bfd; /* &(bfd->Biobufhdr); */
 
 	do {
 		offset = 0;
@@ -211,7 +212,7 @@
 readtroffmetric(char *fontname, int trindex) {
 	static char *filename = 0;
 	Biobuf *bfd;
-	Biobuf *Bfd;
+	Biobufhdr *Bfd;
 	int warn = 0, errorflg = 0, line =1, rv;
 	struct troffont *tp;
 	struct charent **cp;
@@ -225,12 +226,12 @@
 	filename=galloc(filename, strlen(troffmetricdirname)+4+strlen(devname)+1+strlen(fontname)+1, "readtroffmetric():filename");
 	sprint(filename, "%s/dev%s/%s", troffmetricdirname, devname, fontname);
 
-	bfd = Bopen(unsharp(filename), OREAD);
+	bfd = Bopen(filename, OREAD);
 	if (bfd == 0) {
 		error(WARNING, "cannot open file %s\n", filename);
 		return(0);
 	}
-	Bfd = bfd;
+	Bfd = bfd; /* &(bfd->Biobufhdr); */
 	do {
 		/* deal with the few lines at the beginning of the
 		 * troff font metric files.
diff --git a/src/cmd/postscript/tr2post/conv.c b/src/cmd/postscript/tr2post/conv.c
index 4b7d97f..ebc1f43 100644
--- a/src/cmd/postscript/tr2post/conv.c
+++ b/src/cmd/postscript/tr2post/conv.c
@@ -5,14 +5,14 @@
 #include "tr2post.h"
 
 void
-conv(Biobuf *Bp) {
+conv(Biobufhdr *Bp) {
 	long c, n;
 	int r;
 	char special[10];
 	int save;
 
 	inputlineno = 1;
-	if (debug) Bprint(Bstderr, "conv(Biobuf *Bp=0x%x)\n", Bp);
+	if (debug) Bprint(Bstderr, "conv(Biobufhdr *Bp=0x%x)\n", Bp);
 	while ((r = Bgetrune(Bp)) >= 0) {
 /* Bprint(Bstderr, "r=<%c>,0x%x\n", r, r); */
 /*		Bflush(Bstderr); */
diff --git a/src/cmd/postscript/tr2post/devcntl.c b/src/cmd/postscript/tr2post/devcntl.c
index 8b438f7..2566229 100644
--- a/src/cmd/postscript/tr2post/devcntl.c
+++ b/src/cmd/postscript/tr2post/devcntl.c
@@ -16,11 +16,11 @@
 
 /* I won't need this if getfields can replace sscanf
 
-extern void picture(Biobuf *);
+extern void picture(Biobufhdr *);
 extern void notavail(char *);
 
 void
-PSInclude(Biobuf *inp) {
+PSInclude(Biobufhdr *inp) {
 	char buf[256];
 
 	Bgetfield(inp, 's', buf, 256);
@@ -51,7 +51,7 @@
 */
 
 void
-devcntl(Biobuf *inp) {
+devcntl(Biobufhdr *inp) {
 
 	char cmd[50], buf[256], str[MAXTOKENSIZE], *line;
 	int c, n, linelen;
diff --git a/src/cmd/postscript/tr2post/draw.c b/src/cmd/postscript/tr2post/draw.c
index 575ec88..0cb368a 100644
--- a/src/cmd/postscript/tr2post/draw.c
+++ b/src/cmd/postscript/tr2post/draw.c
@@ -13,7 +13,7 @@
 }
 
 void
-drawspline(Biobuf *Bp, int flag) {	/* flag!=1 connect end points */
+drawspline(Biobufhdr *Bp, int flag) {	/* flag!=1 connect end points */
 	int x[100], y[100];
 	int i, N;
 /*
@@ -96,7 +96,7 @@
 }
 
 void
-draw(Biobuf *Bp) {
+draw(Biobufhdr *Bp) {
 
 	int r, x1, y1, x2, y2, i;
 	int d1, d2;
diff --git a/src/cmd/postscript/tr2post/pictures.c b/src/cmd/postscript/tr2post/pictures.c
index a20b7ad..8d758cb 100644
--- a/src/cmd/postscript/tr2post/pictures.c
+++ b/src/cmd/postscript/tr2post/pictures.c
@@ -50,8 +50,8 @@
 /* #include "ext.h" */
 
 Biobuf	*bfp_pic = NULL;
-Biobuf	*Bfp_pic;
-Biobuf	*picopen(char *);
+Biobufhdr	*Bfp_pic;
+Biobufhdr	*picopen(char *);
 
 #define MAXGETFIELDS	16
 char *fields[MAXGETFIELDS];
@@ -63,7 +63,7 @@
 /*****************************************************************************/
 
 void
-picture(Biobuf *inp, char *buf) {
+picture(Biobufhdr *inp, char *buf) {
 	int	poffset;		/* page offset */
 	int	indent;		/* indent */
 	int	length;		/* line length  */
@@ -80,7 +80,7 @@
 	double	adjx = 0.5;	/* left-right adjustment */
 	double	adjy = 0.5;	/* top-bottom adjustment */
 	double	rot = 0;	/* rotation in clockwise degrees */
-	Biobuf	*fp_in;	/* for *name */
+	Biobufhdr	*fp_in;	/* for *name */
 	int	i;			/* loop index */
 
 /*
@@ -195,18 +195,18 @@
  * open file *path and return the resulting file pointer to the caller.
  *
  */
-Biobuf *
+Biobufhdr *
 picopen(char *path) {
 /*	char	name[100];	/* pathnames */
 /*	long	pos;			/* current position */
 /*	long	total;			/* and sizes - from *fp_pic */
 	Biobuf *bfp;
-	Biobuf	*Bfp;		/* and pointer for the new temp file */
+	Biobufhdr	*Bfp;		/* and pointer for the new temp file */
 
 
 	if ((bfp = Bopen(path, OREAD)) == 0)
 		error(FATAL, "can't open %s\n", path);
-	Bfp = bfp;
+	Bfp = bfp; /* &(bfp->Biobufhdr); */
 	return(Bfp);
 #ifdef UNDEF
 	if (Bfp_pic != NULL) {
@@ -219,7 +219,7 @@
 					error(FATAL, "can't generate temp file name");
 				if ( (bfp = Bopen(pictmpname, ORDWR)) == NULL )
 					error(FATAL, "can't open %s", pictmpname);
-				Bfp = bfp;
+				Bfp = &(bfp->Biobufhdr);
 				piccopy(Bfp_pic, Bfp, total);
 				Bseek(Bfp, 0L, 0);
 				return(Bfp);
@@ -230,7 +230,7 @@
 	if ((bfp = Bopen(path, OREAD)) == 0)
 		Bfp = 0;
 	else
-		Bfp = bfp;
+		Bfp = &(bfp->Biobufhdr);
 	return(Bfp);
 #endif
 }
@@ -249,7 +249,7 @@
 
 #ifdef UNDEF
 void
-inlinepic(Biobuf *Bfp, char *buf) {
+inlinepic(Biobufhdr *Bfp, char *buf) {
 	char	name[100];		/* picture file pathname */
 	long	total;			/* and size - both from *buf */
 
@@ -285,7 +285,7 @@
 /*	*fp_out;	and output file pointers */
 /*	total;		number of bytes to be copied */
 void
-piccopy(Biobuf *Bfp_in, Biobuf *Bfp_out, long total) {
+piccopy(Biobufhdr *Bfp_in, Biobufhdr *Bfp_out, long total) {
 	long i;
 
 	for (i = 0; i < total; i++)
diff --git a/src/cmd/postscript/tr2post/ps_include.c b/src/cmd/postscript/tr2post/ps_include.c
index af30ff2..27d020a 100644
--- a/src/cmd/postscript/tr2post/ps_include.c
+++ b/src/cmd/postscript/tr2post/ps_include.c
@@ -11,8 +11,8 @@
 typedef struct {long start, end;} Section;
 static char *buf;
 
-static void
-copy(Biobuf *fin, Biobuf *fout, Section *s) {
+static
+copy(Biobufhdr *fin, Biobufhdr *fout, Section *s) {
 	int cond;
 	if (s->end <= s->start)
 		return;
@@ -57,7 +57,7 @@
 /*	rot;			/* rotation - in clockwise degrees */
 
 void
-ps_include(Biobuf *fin, Biobuf *fout, int page_no, int whiteout,
+ps_include(Biobufhdr *fin, Biobufhdr *fout, int page_no, int whiteout,
 	int outline, int scaleboth, double cx, double cy, double sx, double sy,
 	double ax, double ay, double rot) {
 	char		**strp;
diff --git a/src/cmd/postscript/tr2post/readDESC.c b/src/cmd/postscript/tr2post/readDESC.c
index 03b8b64..4dbc193 100644
--- a/src/cmd/postscript/tr2post/readDESC.c
+++ b/src/cmd/postscript/tr2post/readDESC.c
@@ -44,19 +44,19 @@
 	char *descnameformat = "%s/dev%s/DESC";
 	char *descfilename = 0;
 	Biobuf *bfd;
-	Biobuf *Bfd;
+	Biobufhdr *Bfd;
 	int i, state = -1;
 	int fontindex = 0;
 
 	if (debug) Bprint(Bstderr, "readDESC()\n");
 	descfilename = galloc(descfilename, strlen(descnameformat)+strlen(FONTDIR)
-		+strlen(devname)+1, "readdesc");
+		+strlen(devname), "readdesc");
 	sprint(descfilename, descnameformat, FONTDIR, devname);
-	if ((bfd = Bopen(unsharp(descfilename), OREAD)) == 0) {
+	if ((bfd = Bopen(descfilename, OREAD)) == 0) {
 		error(WARNING, "cannot open file %s\n", descfilename);
 		return(0);
 	}
-	Bfd = bfd;
+	Bfd = bfd; /* &(bfd->Biobufhdr); */
 
 	while (Bgetfield(Bfd, 's', token, MAXTOKENSIZE) > 0) {
 		for (i=0; i<NDESCTOKS; i++) {
diff --git a/src/cmd/postscript/tr2post/tr2post.c b/src/cmd/postscript/tr2post/tr2post.c
index d60e0c7..acfe604 100644
--- a/src/cmd/postscript/tr2post/tr2post.c
+++ b/src/cmd/postscript/tr2post/tr2post.c
@@ -23,7 +23,7 @@
 Biobuf *Bstdin, *Bstdout, *Bstderr;
 int debug = 0;
 
-char tmpfilename[MAXTOKENSIZE];
+char tmpfilename[MAXPATHLEN+1];
 char copybuf[BUFSIZ];
 
 
@@ -41,20 +41,20 @@
 	Bprint(Bstdout, "%s %s\n", PAGES, ATEND);
 	Bprint(Bstdout, "%s", ENDCOMMENTS);
 
-	if (cat(unsharp(DPOST))) {
+	if (cat(DPOST)) {
 		Bprint(Bstderr, "can't read %s\n", DPOST);
 		exits("dpost prologue");
 	}
 
 	if (drawflag) {
-		if (cat(unsharp(DRAW))) {
+		if (cat(DRAW)) {
 			Bprint(Bstderr, "can't read %s\n", DRAW);
 			exits("draw prologue");
 		}
 	}
 
 	if (DOROUND)
-		cat(unsharp(ROUNDPAGE));
+		cat(ROUNDPAGE);
 
 	Bprint(Bstdout, "%s", ENDPROLOG);
 	Bprint(Bstdout, "%s", BEGINSETUP);
@@ -70,19 +70,19 @@
 	if (pointsize != 10) Bprint(Bstdout, "/pointsize %d def\n", pointsize);
 	if (xoffset != .25) Bprint(Bstdout, "/xoffset %g def\n", xoffset);
 	if (yoffset != .25) Bprint(Bstdout, "/yoffset %g def\n", yoffset);
-	cat(unsharp(ENCODINGDIR"/Latin1.enc"));
+	cat(ENCODINGDIR"/Latin1.enc");
 	if (passthrough != 0) Bprint(Bstdout, "%s\n", passthrough);
 
 	Bprint(Bstdout, "setup\n");
 	if (formsperpage > 1) {
-		cat(unsharp(FORMFILE));
+		cat(FORMFILE);
 		Bprint(Bstdout, "%d setupforms \n", formsperpage);
 	}
 /* output Build character info from charlib if necessary. */
 
 	for (i=0; i<build_char_cnt; i++) {
 		sprint(charlibname, "%s/%s", CHARLIB, build_char_list[i]->name);
-		if (cat(unsharp(charlibname)))
+		if (cat(charlibname))
 		Bprint(Bstderr, "cannot open %s\n", charlibname);
 	}
 
@@ -95,24 +95,26 @@
 }
 
 main(int argc, char *argv[]) {
+	Biobuf btmp;
 	Biobuf *binp;
-	Biobuf *Binp;
-	int i, tot, ifd;
+	Biobufhdr *Binp;
+	int i, tot, ifd, fd;
 	char *t;
 
 	programname = argv[0];
 	if (Binit(&bstderr, 2, OWRITE) == Beof) {
 		exits("Binit");
 	}
-	Bstderr = &bstderr;
+	Bstderr = &bstderr;  /* &bstderr.Biobufhdr; */
 
-	tmpnam(tmpfilename);
-	if ((bstdout=Bopen(tmpfilename, OWRITE)) == 0) {
+	bstdout = &btmp;
+	fd = safe_tmpnam(tmpfilename);
+	if ((Binit(bstdout, fd, OWRITE)) == Beof) {
 		Bprint(Bstderr, "cannot open temporary file %s\n", tmpfilename);
 		exits("Bopen");
 	}
 	atexit(cleanup);
-	Bstdout = bstdout;
+	Bstdout = bstdout; /* &bstdout->Biobufhdr; */
 	
 	ARGBEGIN{
 		case 'a':			/* aspect ratio */
@@ -169,7 +171,7 @@
 			Bprint(Bstderr, "Binit of <stdin> failed.\n");
 			exits("Binit");
 		}
-		Binp = binp;
+		Binp = binp; /* &(binp->Biobufhdr); */
 		if (debug) Bprint(Bstderr, "using standard input\n");
 		conv(Binp);
 		Bterm(Binp);
@@ -179,7 +181,7 @@
 			Bprint(Bstderr, "cannot open file %s\n", argv[i]);
 			continue;
 		}
-		Binp = binp;
+		Binp = binp; /* &(binp->Biobufhdr); */
 		inputfilename = argv[i];
 		conv(Binp);
 		Bterm(Binp);
@@ -196,7 +198,7 @@
 		Bprint(Bstderr, "Binit of <stdout> failed.\n");
 		exits("Binit");
 	}
-	Bstdout = bstdout;
+	Bstdout = bstdout; /* &(bstdout->Biobufhdr); */
 	prologues();
 	Bflush(Bstdout);
 	tot = 0; i = 0;
diff --git a/src/cmd/postscript/tr2post/tr2post.h b/src/cmd/postscript/tr2post/tr2post.h
index b07e0b1..68299cc 100644
--- a/src/cmd/postscript/tr2post/tr2post.h
+++ b/src/cmd/postscript/tr2post/tr2post.h
@@ -1,6 +1,9 @@
 #define MAXSPECHARS 	512
 #define MAXTOKENSIZE	128
-#define CHARLIB	"#9/sys/lib/troff/font/devutf/charlib"
+#define CHARLIB	FONTDIR "/devutf/charlib"
+
+/* devname clashes with libc on *BSD */
+#define devname		troff_devname
 
 extern int debug;
 extern int fontsize;
diff --git a/src/cmd/postscript/tr2post/utils.c b/src/cmd/postscript/tr2post/utils.c
index 8f58ea4..e9979ff 100644
--- a/src/cmd/postscript/tr2post/utils.c
+++ b/src/cmd/postscript/tr2post/utils.c
@@ -250,7 +250,7 @@
 }
 
 void
-graphfunc(Biobuf *bp) {
+graphfunc(Biobufhdr *bp) {
 }
 
 long