Index: share/mk/bsd.own.mk
===================================================================
RCS file: /meow/ncvs/src/share/mk/bsd.own.mk,v
retrieving revision 1.41
diff -U2 -r1.41 bsd.own.mk
--- share/mk/bsd.own.mk	5 Feb 2004 20:48:44 -0000	1.41
+++ share/mk/bsd.own.mk	6 Apr 2005 18:38:37 -0000
@@ -15,5 +15,5 @@
 #		Output is to stdout. [gzip -cn]
 #
-# COMPRESS_EXT	File name extension of ${COMPRESS_CMD} command. [.gz]
+# COMPRESS_EXT	File name extension of ${COMPRESS_CMD} command. [.bz2]
 #
 # BINOWN	Binary owner. [root]
@@ -163,6 +163,6 @@
 .endif
 
-COMPRESS_CMD?=	gzip -cn
-COMPRESS_EXT?=	.gz
+COMPRESS_CMD?=	bzip2 -9c
+COMPRESS_EXT?=	.bz2
 
 .endif !target(__<bsd.own.mk>__)
Index: gnu/usr.bin/man/Makefile.inc
===================================================================
RCS file: /meow/ncvs/src/gnu/usr.bin/man/Makefile.inc,v
retrieving revision 1.21
diff -U2 -r1.21 Makefile.inc
--- gnu/usr.bin/man/Makefile.inc	18 Oct 2002 09:14:13 -0000	1.21
+++ gnu/usr.bin/man/Makefile.inc	6 Apr 2005 18:24:52 -0000
@@ -23,6 +23,8 @@
 pic=			/usr/bin/pic
 zcat=			/usr/bin/zcat
-compress=		/usr/bin/gzip -c
-compext=		.gz
+bzcat=			/usr/bin/bzcat
+bzip2=			/usr/bin/bzip2 -9c
+compress=		${bzip2}
+compext=		.bz2
 
 .if exists(${.OBJDIR}/../lib)
Index: gnu/usr.bin/man/lib/Makefile
===================================================================
RCS file: /meow/ncvs/src/gnu/usr.bin/man/lib/Makefile,v
retrieving revision 1.12.8.1
diff -U2 -r1.12.8.1 Makefile
--- gnu/usr.bin/man/lib/Makefile	13 Feb 2005 07:23:10 -0000	1.12.8.1
+++ gnu/usr.bin/man/lib/Makefile	6 Apr 2005 17:25:09 -0000
@@ -22,5 +22,5 @@
 	    -e 's,%manpath_config_file%,${manpath_config_file},' \
 	    -e 's,%compress%,${compress},' \
-	    -e 's,%compext%,${compext},' \
+	    -e 's,%compext%,${compext},' -e 's,%bzcat%,${bzcat},' \
 	    ${.CURDIR}/config.h_dist > ${.TARGET}
 
Index: gnu/usr.bin/man/lib/config.h_dist
===================================================================
RCS file: /meow/ncvs/src/gnu/usr.bin/man/lib/config.h_dist,v
retrieving revision 1.5
diff -U2 -r1.5 config.h_dist
--- gnu/usr.bin/man/lib/config.h_dist	10 Oct 1998 13:11:39 -0000	1.5
+++ gnu/usr.bin/man/lib/config.h_dist	6 Apr 2005 17:22:39 -0000
@@ -137,4 +137,5 @@
 /* .Z files */
 #define ZCAT "%zcat%"
+#define BZCAT "%bzcat%"
 
 /*
Index: gnu/usr.bin/man/man/Makefile
===================================================================
RCS file: /meow/ncvs/src/gnu/usr.bin/man/man/Makefile,v
retrieving revision 1.33
diff -U2 -r1.33 Makefile
--- gnu/usr.bin/man/man/Makefile	15 Jan 2002 14:11:05 -0000	1.33
+++ gnu/usr.bin/man/man/Makefile	6 Apr 2005 19:24:36 -0000
@@ -2,18 +2,13 @@
 #
 
-MAN_LIBZ=YES
-
 PROG=	man
 SRCS=	man.c manpath.c glob.c
 
-CFLAGS+= -I${LIBDESTDIR}
+CFLAGS+= -O0 -g -I${LIBDESTDIR}
 DPADD=	${LIBMAN}
 LDADD=	${LIBMAN}
 
-.if defined(MAN_LIBZ) && !empty(MAN_LIBZ)
-DPADD+=	${LIBZ}
-LDADD+=	-lz
-CFLAGS+=-DHAVE_LIBZ=1
-.endif
+DPADD+=	${LIBBZ2}
+LDADD+=	-lbz2
 
 CFLAGS+= -I${.CURDIR}/../lib -DSTDC_HEADERS -DPOSIX -DHAS_TROFF
Index: gnu/usr.bin/man/man/man.c
===================================================================
RCS file: /meow/ncvs/src/gnu/usr.bin/man/man/man.c,v
retrieving revision 1.62
diff -U2 -r1.62 man.c
--- gnu/usr.bin/man/man/man.c	26 Oct 2003 06:40:37 -0000	1.62
+++ gnu/usr.bin/man/man/man.c	6 Apr 2005 19:32:33 -0000
@@ -34,7 +34,5 @@
 #include <string.h>
 #include <signal.h>
-#if HAVE_LIBZ > 0
-#include <zlib.h>
-#endif
+#include <bzlib.h>
 #include "config.h"
 #include "gripes.h"
@@ -616,8 +614,17 @@
  * or a name of the form ...man/cat1/name.1 to ...man/man1/name.1
  */
+static const struct known_exts {
+  const char	*ext;
+  size_t	 len;
+} known_exts[] = {
+  { COMPRESS_EXT,	sizeof(COMPRESS_EXT) - 1 },
+  { ".gz",	3 },
+  { ".Z",	2 },
+  { NULL }
+};
+
 char *
-convert_name (name, to_cat)
-     register char *name;
-     register int to_cat;
+convert_name (name)
+     const char *name;
 {
   register char *to_name;
@@ -625,25 +632,17 @@
   register char *t2 = NULL;
 
-#ifdef DO_COMPRESS
-  if (to_cat)
-    {
-      int olen = strlen(name);
-      int cextlen = strlen(COMPRESS_EXT);
-      int len = olen + cextlen;
-
-      to_name = malloc (len+1);
-      if (to_name == NULL)
-	gripe_alloc (len+1, "to_name");
-      strcpy (to_name, name);
-      olen -= cextlen;
-      /* Avoid tacking it on twice */
-      if (olen >= 1 && strcmp(name + olen, COMPRESS_EXT) != 0)
-      	strcat (to_name, COMPRESS_EXT);
-    }
-  else
-    to_name = strdup (name);
-#else
-  to_name = strdup (name);
-#endif
+  int olen = strlen(name);
+  int len = olen + sizeof(COMPRESS_EXT);
+  const struct known_exts *ext;
+
+  for (ext = known_exts; ext->ext; ext++)
+    if (olen > ext->len && strcmp(name + olen - ext->len, ext->ext) == 0) {
+      len -= ext->len;
+      break;
+    }
+  to_name = malloc (len);
+  if (to_name == NULL)
+    gripe_alloc (len, "to_name");
+  sprintf(to_name, "%.*s" COMPRESS_EXT, olen - ext->len, name);
 
   t1 = strrchr (to_name, '/');
@@ -665,16 +664,8 @@
 
   if (t2 == NULL)
-    gripe_converting_name (name, to_cat);
+    gripe_converting_name (name, 1);
 
-  if (to_cat)
-    {
-      *(++t2) = 'c';
-      *(t2+2) = 't';
-    }
-  else
-    {
-      *(++t2) = 'm';
-      *(t2+2) = 'n';
-    }
+  *(++t2) = 'c';
+  *(t2+2) = 't';
 
   if (debug)
@@ -811,4 +802,8 @@
     return ZCAT;
 #endif	/* ZCAT */
+#ifdef BZCAT
+  if (!strcmp(end, "bz2"))
+    return BZCAT;
+#endif	/* BZCAT */
   return NULL;
 }
@@ -1056,9 +1051,5 @@
      char *file;
 {
-#if HAVE_LIBZ > 0
-  gzFile fp;
-#else
-  FILE *fp;
-#endif
+  BZFILE *fp;
   char line [BUFSIZ];
   static char buf [BUFSIZ];
@@ -1080,18 +1071,10 @@
     }
 
-#if HAVE_LIBZ > 0
-  if ((fp = gzopen (file, "r")) != NULL)
-#else
-  if ((fp = fopen (file, "r")) != NULL)
-#endif
+  if ((fp = BZ2_bzopen (file, "r")) != NULL)
     {
       cp = line;
-#if HAVE_LIBZ > 0
-      gzgets (fp, line, BUFSIZ);
-      gzclose(fp);
-#else
-      fgets (line, BUFSIZ, fp);
-      fclose(fp);
-#endif
+      BZ2_bzread(fp, line, sizeof(line) - 1);
+      BZ2_bzclose(fp);
+
       if (*cp++ == '\'' && *cp++ == '\\' && *cp++ == '"' && *cp++ == ' ')
 	{
@@ -1180,10 +1163,5 @@
 {
   int s, f;
-  FILE *pp;
-#if defined(HAVE_LIBZ) && defined(DO_COMPRESS)
-  gzFile fp;
-#else
-  FILE *fp;
-#endif
+  FILE *pp, *fp;
   char *roff_command;
   char command[FILENAME_MAX];
@@ -1195,9 +1173,5 @@
   snprintf(temp, sizeof(temp), "%s.tmpXXXXXX", cat_file);
   if ((f = mkstemp(temp)) >= 0 && 
-#if defined(HAVE_LIBZ) && defined(DO_COMPRESS)
-      (fp = gzdopen(f, "w")) != NULL)
-#else
       (fp = fdopen(f, "w")) != NULL)
-#endif
     {
       set_sigs();
@@ -1212,5 +1186,5 @@
 	fprintf (stderr, "mode of %s is now %o\n", temp, CATMODE);
 
-      snprintf (command, sizeof(command), "(cd %s ; %s)", path,
+      snprintf (command, sizeof(command), "(cd %s ; %s) | " COMPRESSOR, path,
 		roff_command);
 
@@ -1237,9 +1211,5 @@
 	  unlink(temp);
 	  restore_sigs();
-#if defined(HAVE_LIBZ) && defined(DO_COMPRESS)
-	  gzclose(fp);
-#else
 	  fclose(fp);
-#endif
 	  return 0;
 	}
@@ -1251,9 +1221,5 @@
 	f = 0;
 	while ((s = getc(pp)) != EOF) {
-#if defined(HAVE_LIBZ) && defined(DO_COMPRESS)
-	  gzputc(fp, s);
-#else
-	  putc(s, fp);
-#endif
+	  putc(s, fp);
 	  f++;
 	}
@@ -1267,9 +1233,5 @@
 	  unlink(temp);
 	  restore_sigs();
-#if defined(HAVE_LIBZ) && defined(DO_COMPRESS)
-	  gzclose(fp);
-#else
 	  fclose(fp);
-#endif
 	  return 0;
 	}
@@ -1280,9 +1242,5 @@
 	  unlink(temp);
 	  restore_sigs();
-#if defined(HAVE_LIBZ) && defined(DO_COMPRESS)
-	  gzclose(fp);
-#else
 	  fclose(fp);
-#endif
 	  return 0;
 	}
@@ -1300,18 +1258,10 @@
 	unlink(temp);
 	restore_sigs();
-#if defined(HAVE_LIBZ) && defined(DO_COMPRESS)
-	gzclose(fp);
-#else
 	fclose(fp);
-#endif
 	return 0;
       }
       restore_sigs();
 
-#if defined(HAVE_LIBZ) && defined(DO_COMPRESS)
-      if (gzclose(fp)) {
-#else
       if (fclose(fp)) {
-#endif
 	s = errno;
 	if (!debug)
@@ -1563,7 +1513,5 @@
 	  if (!troff)
 	    {
-	      to_cat = 1;
-
-	      cat_file = convert_name (man_file, to_cat);
+	      cat_file = convert_name (man_file);
 
 	      if (debug)
