>> Bill Middleton(wjm) wrote on Sat, 14 Aug 1993 20:29:28 -0500:
Following are context diffs to enable Tom Christiansen's
<tchrist@convex.com> `man' perl script to use GNU zip (gzip). 

I have only been able to test the changes on a SUN running SUNOS4.1.3,
but they are relatively simple enough that they should work on any
other platform man currently runs on. Please let me know if these
modifications break anything!

I only use individually compressed man pages (e.g., man1/who.1.gz)
instead of the compressed directory (e.g., man1.Z/who.1) referred to
by Tom. Thus, I have not changed the compressed directory portion. In
particular, `man' and `makewhatis' will only use gzip on the former
individually compressed files.

The individually compressed man pages may have suffixes `.gz', `.z'
(old style gzip) or `.Z' (compress(1L)).

Mark Borges
<mdb@noaacrd.colorado.edu>

diff -C3 man-orig/CHANGES man-fix/CHANGES
*** man-orig/CHANGES	Sun Aug 15 23:25:08 1993
--- man-fix/CHANGES	Mon Aug 16 10:25:00 1993
***************
*** 1,3 ****
--- 1,5 ----
+ 16 Aug 93: Modified by Mark Borges <mdb@noaacrd.colorado.edu> to
+            handle GNU zip (gzip) compressed files. 
  
      *   extra utils
  
diff -C3 man-orig/README man-fix/README
*** man-orig/README	Sun Aug 15 23:25:07 1993
--- man-fix/README	Mon Aug 16 10:23:23 1993
***************
*** 16,18 ****
--- 16,25 ----
  
  copying is ok, just don't remove my name or try to sell it.
  read the man pages first.
+ -------------------------------------------------------------------------------
+ Notes on GNU zip (gzip) modifications by Mark Borges <mdb@noaacrd.colorado.edu>
+ 
+ 1) You will need to obtain gzip version 1.2.3 or later for GNU archive sites.
+ 
+ 2) `zcat' is presumed to be that distributed with gzip; specifically, GNU 
+     zcat *must* come before /usr/ucb/zcat.
diff -C3 man-orig/catman man-fix/catman
*** man-orig/catman	Sun Aug 15 23:25:06 1993
--- man-fix/catman	Mon Aug 16 09:22:59 1993
***************
*** 12,18 ****
  $EQN	    = "neqn";
  # $MAKEWHATIS = "/usr/lib/makewhatis";
  $MAKEWHATIS = "/usr/local/lib/makewhatis";
! $COMPRESS   = "compress";
  $NROFF	    = "nroff";
  $COL 	    = "col";
  $CAT	    = "cat";
--- 12,18 ----
  $EQN	    = "neqn";
  # $MAKEWHATIS = "/usr/lib/makewhatis";
  $MAKEWHATIS = "/usr/local/lib/makewhatis";
! $COMPRESS   = "gzip";
  $NROFF	    = "nroff";
  $COL 	    = "col";
  $CAT	    = "cat";
***************
*** 98,116 ****
  	    } 
  
  	    ($catpage = $manpage) 
! 		=~ s,^(.*)/man([^\.]*)(\.Z)?/([^/]*)$,$1/cat$2$3/$4,;
  
  	    ($catdir = $catpage) =~ s#/[^/]*$##;
  	    next manpage unless -d $catdir && -w _;
  
  	    if ((stat(_))[9] > (stat($catpage))[9]) {
! 		$command = (($manpage =~ m:\.Z:) ? $ZCAT : $CAT)
  			    . " < $manpage | $CATSET";
  
  		$command = &insert_filters($command, $manpage);
  		$command =~ s,-man,$path/tmac.an, if -e "$path/tmac.an";
  
! 		$command .= "| $COMPRESS " if $catpage =~ /\.Z/;
  
  		$command .= "> $catpage";
  
--- 98,116 ----
  	    } 
  
  	    ($catpage = $manpage) 
! 		=~ s,^(.*)/man([^\.]*)(\.(g?z|Z))?/([^/]*)$,$1/cat$2$3/$4,;
  
  	    ($catdir = $catpage) =~ s#/[^/]*$##;
  	    next manpage unless -d $catdir && -w _;
  
  	    if ((stat(_))[9] > (stat($catpage))[9]) {
! 		$command = (($manpage =~ m:\.(g?z|Z):) ? $ZCAT : $CAT)
  			    . " < $manpage | $CATSET";
  
  		$command = &insert_filters($command, $manpage);
  		$command =~ s,-man,$path/tmac.an, if -e "$path/tmac.an";
  
! 		$command .= "| $COMPRESS " if $catpage =~ /\.(g?z|Z)/;
  
  		$command .= "> $catpage";
  
diff -C3 man-orig/makewhatis man-fix/makewhatis
*** man-orig/makewhatis	Sun Aug 15 23:25:08 1993
--- man-fix/makewhatis	Mon Aug 16 11:01:46 1993
***************
*** 14,20 ****
  
  ($program = $0) =~ s,.*/,,;
  
! $UNCOMPRESS = "uncompress";
  
  $MAXWHATISLEN =  300;   
  $MAXDATUM     = 1024; 	# DBM is such a pain
--- 14,20 ----
  
  ($program = $0) =~ s,.*/,,;
  
! $UNCOMPRESS = "gunzip";
  
  $MAXWHATISLEN =  300;   
  $MAXDATUM     = 1024; 	# DBM is such a pain
***************
*** 119,125 ****
  	}
  
  	($dirext) = $mandir =~ /man(.*)$/;
! 	$dirext =~ s/\.Z$//;
  
  	print "subdir is $mandir\n" if $debug;
  
--- 119,125 ----
  	}
  
  	($dirext) = $mandir =~ /man(.*)$/;
! 	$dirext =~ s/\.(g?z|Z)$//;
  
  	print "subdir is $mandir\n" if $debug;
  
***************
*** 131,137 ****
  	# read each file in directory.  use readdir not globbing
  	# because we don't want to blow up on huge directories
  FILE:	while ($FILE = readdir(mandir)) {
! 	    $compressed = $mandir =~ m:.*\.Z:;
  	    next FILE if $FILE =~ /^\.{1,2}/;
  
  	    if ($FILE !~ /\S\.[^Z\s]/) {
--- 131,137 ----
  	# read each file in directory.  use readdir not globbing
  	# because we don't want to blow up on huge directories
  FILE:	while ($FILE = readdir(mandir)) {
! 	    $compressed = $mandir =~ m:.*\.(g?z|Z):;
  	    next FILE if $FILE =~ /^\.{1,2}/;
  
  	    if ($FILE !~ /\S\.[^Z\s]/) {
***************
*** 140,162 ****
  	    } 
  
  	    # this will be optimized into a case statement
! 	    if      ($FILE =~ /\.old(\.Z)?$/i) {
  		next;
! 	    } elsif ($FILE =~ /\.bak(\.Z)?$/i) {
  		next;
! 	    } elsif ($FILE =~ /\.out(\.Z)?$/i) {
  		next;
! 	    } elsif ($FILE =~ /~(\.Z)?$/) {
  		next;
  	    }
  
! 	    ($tmpfile = $FILE) =~ s/\.Z$//;
  
  	    ($filenam, $filext) = 
  		$tmpfile =~ /^(\S+)\.([^.]+)$/;
  
! 	    #if ($filext eq '.Z') {
! 		#($filenam, $filext) = $filenam =~ /^(\S+)\.([^.]+)(\.Z)?$/;
  	    #}
  
  	    if ($filext !~ /^${dirext}.*/ && $mandir ne 'mano') {
--- 140,165 ----
  	    } 
  
  	    # this will be optimized into a case statement
! 	    if      ($FILE =~ /\.old(\.(g?z|Z))?$/i) {
  		next;
! 	    } elsif ($FILE =~ /\.bak(\.(g?z|Z))?$/i) {
  		next;
! 	    } elsif ($FILE =~ /\.out(\.(g?z|Z))?$/i) {
  		next;
! 	    } elsif ($FILE =~ /~(\.(g?z|Z))?$/) {
  		next;
  	    }
  
! 	    ($tmpfile = $FILE) =~ s/\.(g?z|Z)$//;
  
  	    ($filenam, $filext) = 
  		$tmpfile =~ /^(\S+)\.([^.]+)$/;
  
! # Tom has the following commented out, so I'll follow suit <mdb>.
! 
! 	    #if ($filext eq '.Z' || $filext eq '.gz' || $filext eq '.z' )
! 	    #{
! 		#($filenam, $filext) = $filenam =~ /^(\S+)\.([^.]+)(\.(g?z|Z))?$/;
  	    #}
  
  	    if ($filext !~ /^${dirext}.*/ && $mandir ne 'mano') {
***************
*** 183,196 ****
  		&chopext($page = $FILE);
  		unless ($WHATIS{$page}) {
  		    print "forgot $page\n" if $debug;
! 		    $apage =~ s/\.Z$//;
  		    &store_indirect($page, $apage);
  		}
  		next FILE;
  	    } 
  	    $seen{$st_dev,$st_ino} = $FILE;
  
! 	    $compressed |= $FILE =~ /\.Z$/;
  	    
  	    if (!open(FILE, $compressed ? "$UNCOMPRESS < $FILE |" : $FILE)) {
  		warn "can't open $FILE: $!\n";
--- 186,199 ----
  		&chopext($page = $FILE);
  		unless ($WHATIS{$page}) {
  		    print "forgot $page\n" if $debug;
! 		    $apage =~ s/\.(g?z|Z)$//;
  		    &store_indirect($page, $apage);
  		}
  		next FILE;
  	    } 
  	    $seen{$st_dev,$st_ino} = $FILE;
  
! 	    $compressed |= $FILE =~ /\.(g?z|Z)$/;
  	    
  	    if (!open(FILE, $compressed ? "$UNCOMPRESS < $FILE |" : $FILE)) {
  		warn "can't open $FILE: $!\n";
***************
*** 273,280 ****
  	$indirect = $1;
  	($page)  = $FILE     =~ m:([^.]+)\.[^.]*$:;
  	($page2) = $indirect =~ m:.*/([^/]+)$:;
! 	($indirect2 = $indirect) =~ s!/!.Z/!;
! 	if (-e "../$indirect" || -e "../$indirect.Z" || -e $indirect2) {
  	    $so{$page} = $page2;
  	    print "$FILE: .so alias for $indirect\n" if $debug;
  	} else {
--- 276,283 ----
  	$indirect = $1;
  	($page)  = $FILE     =~ m:([^.]+)\.[^.]*$:;
  	($page2) = $indirect =~ m:.*/([^/]+)$:;
! 	($indirect2 = $indirect) =~ s!/!.z/!;
! 	if (-e "../$indirect" || -e "../$indirect.z" || -e $indirect2) {
  	    $so{$page} = $page2;
  	    print "$FILE: .so alias for $indirect\n" if $debug;
  	} else {
***************
*** 338,344 ****
  		$cmdlist = substr($cmdlist,0,$MAXWHATISLEN) . "...";
  	    } 
  
! 	    ($tmpfile = $FILE) =~ s/\.Z$//;
  	    ($page, $section) = $tmpfile =~ /^(\S+)\.(\S+)$/;
  	    $cmdlist = $page if $needcmdlist; 
  
--- 341,347 ----
  		$cmdlist = substr($cmdlist,0,$MAXWHATISLEN) . "...";
  	    } 
  
! 	    ($tmpfile = $FILE) =~ s/\.(g?z|Z)$//;
  	    ($page, $section) = $tmpfile =~ /^(\S+)\.(\S+)$/;
  	    $cmdlist = $page if $needcmdlist; 
  
***************
*** 367,373 ****
      }  
      unless ($foundname) {
  	print STDERR "$FILE: no NAME lines, so has no whatis description!\n";
! 	($tmpfile = $FILE) =~ s/\.Z$//;
  	($page, $section) = $tmpfile =~ /^(\S+)\.(\S+)$/;
  	&store_direct($page, $page, $tmpfile, $dirext, 'NO DESCRIPTION');
      } 
--- 370,376 ----
      }  
      unless ($foundname) {
  	print STDERR "$FILE: no NAME lines, so has no whatis description!\n";
! 	($tmpfile = $FILE) =~ s/\.(g?z|Z)$//;
  	($page, $section) = $tmpfile =~ /^(\S+)\.(\S+)$/;
  	&store_direct($page, $page, $tmpfile, $dirext, 'NO DESCRIPTION');
      } 
***************
*** 387,393 ****
  
  
  sub chopext {
!     $_[0] =~ s/\.Z$//;
      $_[0] =~ s/\.[^.]+$//;
  } 
  
--- 390,396 ----
  
  
  sub chopext {
!     $_[0] =~ s/\.(g?z|Z)$//;
      $_[0] =~ s/\.[^.]+$//;
  } 
  
diff -C3 man-orig/makewhatis.8 man-fix/makewhatis.8
*** man-orig/makewhatis.8	Sun Aug 15 23:25:05 1993
--- man-fix/makewhatis.8	Mon Aug 16 10:16:33 1993
***************
*** 143,151 ****
  if the name of the subdirectory itself ends in \fB.Z\fP, as in \fBman8.Z\fP,
  then all its files are assumed to have been compressed with 
  .M compress 1L .
! Alternatively, individual files ending in \fB.Z\fP are also 
! considered to be compressed.
! Compressed files are processed with 
  .M zcat 1L .  
  .SH EXAMPLES
  .ft TA
--- 143,153 ----
  if the name of the subdirectory itself ends in \fB.Z\fP, as in \fBman8.Z\fP,
  then all its files are assumed to have been compressed with 
  .M compress 1L .
! Alternatively, individual files ending in \fB.gz\fP, \fB.z\fP, or \fB.Z\fP are
! also considered to be compressed. These compressed files are processed with 
! the GNU zip 
! .M gzip 1L 
! version of
  .M zcat 1L .  
  .SH EXAMPLES
  .ft TA
***************
*** 171,176 ****
--- 173,179 ----
  apropos(1),
  perl(1),
  compress(1L),
+ gzip(1L),
  dbm(3X),
  man(7),
  catman(8)
***************
*** 350,356 ****
  takes much longer to run if man pages are stored in compressed form.
  .SH BUGS
  Not all systems have 
! .I compress
  installed on them.
  .SH AUTHOR
  Tom Christiansen 
--- 353,361 ----
  takes much longer to run if man pages are stored in compressed form.
  .SH BUGS
  Not all systems have 
! .I compress 
! or
! .I gzip
  installed on them.
  .SH AUTHOR
  Tom Christiansen 
diff -C3 man-orig/man man-fix/man
*** man-orig/man	Sun Aug 15 23:25:10 1993
--- man-fix/man	Mon Aug 16 10:40:53 1993
***************
*** 6,11 ****
--- 6,13 ----
  # Copyright 1990 Convex Computer Corporation.
  # All rights reserved.
  #
+ # Revised 16 Aug 1993 by Mark Borges <mdb@noaacrd.colorado.edu>
+ # to handle GNU zip (gzip) *individually* compressed man pages.
  # --------------------------------------------------------------------------
  # begin configuration section
  #
***************
*** 58,71 ****
  $UL	  = '';		# set to '' if you haven't got ul
  die 'need either $UL or $COL' unless $UL || $COL;
  
! # need these for .Z files or dirs
! $COMPRESS = 'compress';
  $ZCAT	  = 'zcat';
  $CAT	  = 'cat';
  
  # define COMPRESS_DIR if pages might have moved to manX.Z/page.X (like HPs)
! $COMPRESS_DIR = 1;
! # define COMPRESS_PAGE if pages might have moved to manX/page.X.Z  (better)
  $COMPRESS_PAGE = 1;
  
  # Command to format man pages to be viewed on a tty or printed on a line printer
--- 60,75 ----
  $UL	  = '';		# set to '' if you haven't got ul
  die 'need either $UL or $COL' unless $UL || $COL;
  
! # need these for Gzip'ed files or dirs
! # $ZCAT must point to the gzip-supplied `zcat'. <mdb>
! $COMPRESS = 'gunzip';
  $ZCAT	  = 'zcat';
  $CAT	  = 'cat';
  
  # define COMPRESS_DIR if pages might have moved to manX.Z/page.X (like HPs)
! # This has *not* been hacked to work with GZIP <mdb>.
! $COMPRESS_DIR = 0;
! # define COMPRESS_PAGE if pages might have moved to manX/page.X.gz  (better)
  $COMPRESS_PAGE = 1;
  
  # Command to format man pages to be viewed on a tty or printed on a line printer
***************
*** 79,85 ****
  
  # flags: GNU likes -i, BSD doesn't; both like -h, but BSD doesn't document it
  # if you don't put -i here, i'll make up for it later the hard way
! $EGREP = '/usr/local/bin/egrep';	
  if (-x $EGREP) {
      $EGREP .= ' -i -h';
  } else {
--- 83,90 ----
  
  # flags: GNU likes -i, BSD doesn't; both like -h, but BSD doesn't document it
  # if you don't put -i here, i'll make up for it later the hard way
! #$EGREP = '/usr/local/bin/egrep';	
! $EGREP = '/gfdl2/mdb/gnu/bin/egrep';	
  if (-x $EGREP) {
      $EGREP .= ' -i -h';
  } else {
***************
*** 459,466 ****
  	printed (if -d flag) and -h will be assumed for that \$manroot only.
      * If \$manroot/tmac.an exists, it will be used for formatting 
  	instead of the normal -man macros.
!     * Man pages may be compressed either in (for example) man1.Z/who.1 
!         or man1/who.1.Z; cat pages will go into corresponding places.
      * If the man page contains .EQ or .TS directives, eqn and/or tbl
          will be invoked as needed at format time.
  USAGE
--- 464,472 ----
  	printed (if -d flag) and -h will be assumed for that \$manroot only.
      * If \$manroot/tmac.an exists, it will be used for formatting 
  	instead of the normal -man macros.
!     * Man pages may be compressed in (for example) man1/who.1.gz,
!       man1/who.1.z, or man1/who.1.Z; cat pages will go into corresponding
!       places.
      * If the man page contains .EQ or .TS directives, eqn and/or tbl
          will be invoked as needed at format time.
  USAGE
***************
*** 776,784 ****
      return $path if -f $path;
  
      if ($COMPRESS_PAGE) {
! 	$path .= '.Z';
  	return $path if -f $path;
! 	$path =~ s/.Z//;
      } 
  
      if ($COMPRESS_DIR) {
--- 782,794 ----
      return $path if -f $path;
  
      if ($COMPRESS_PAGE) {
! 	$path = join('',$orig,'.gz');
  	return $path if -f $path;
! 	$path = join('',$orig,'.z');
! 	return $path if -f $path;
! 	$path = join('',$orig,'.Z');
! 	return $path if -f $path;
! #	$path =~ s/.Z//;
      } 
  
      if ($COMPRESS_DIR) {
***************
*** 816,823 ****
  sub bysection {
      local ($e1, $e2, $p1, $p2, $s1, $s2);
  
!     ($s1, $e1) = $a =~ m:.*/man([^/]+)/.*\.([^.]+)(\.Z)?$:;
!     ($s2, $e2) = $b =~ m:.*/man([^/]+)/.*\.([^.]+)(\.Z)?$:;
  
      $e1 = $s1 if $e1 !~ /^${s1}.*/;
      $e2 = $s2 if $e2 !~ /^${s2}.*/;
--- 826,833 ----
  sub bysection {
      local ($e1, $e2, $p1, $p2, $s1, $s2);
  
!     ($s1, $e1) = $a =~ m:.*/man([^/]+)/.*\.([^.]+)(\.(g?z|Z))?$:;
!     ($s2, $e2) = $b =~ m:.*/man([^/]+)/.*\.([^.]+)(\.(g?z|Z))?$:;
  
      $e1 = $s1 if $e1 !~ /^${s1}.*/;
      $e2 = $s2 if $e2 !~ /^${s2}.*/;
***************
*** 863,871 ****
      local ($manroot);
      local ($macros);
  
!     ($manroot) = $file =~ m,^(.*)/man([^\.]*)(\.Z)?/([^/]*),;
  
!     $command = ((($file =~ m:\.Z:) 
  			? $ZCAT 
  			: $CAT) 
  		. " < $file | $TYPESET");
--- 873,881 ----
      local ($manroot);
      local ($macros);
  
!     ($manroot) = $file =~ m,^(.*)/man([^\.]*)(\.(g?z|Z))?/([^/]*),;
  
!     $command = ((($file =~ m:\.(g?z|Z):) 
  			? $ZCAT 
  			: $CAT) 
  		. " < $file | $TYPESET");
***************
*** 899,905 ****
  	return;
      } 
      if ($fromfile) {
! 	$command = (($manpage =~ m:\.Z/:) ? $ZCAT : $CAT)
  			. " < $manpage | $CATSET";
  	&insert_filters($command, $manpage);
      } else {
--- 909,915 ----
  	return;
      } 
      if ($fromfile) {
! 	$command = (($manpage =~ m:\.(g?z|Z):) ? $ZCAT : $CAT)
  			. " < $manpage | $CATSET";
  	&insert_filters($command, $manpage);
      } else {
***************
*** 908,914 ****
  
  
  	($catpage = $manpage) 
! 	    =~ s,^(.*)/man([^\.]*)(\.Z)?/([^/]*)$,$1/cat$2/$4,;
  
  	$manroot = $1;
  
--- 918,924 ----
  
  
  	($catpage = $manpage) 
! 	    =~ s,^(.*)/man([^\.]*)(\.(g?z|Z))?/([^/]*)$,$1/cat$2/$4,;
  
  	$manroot = $1;
  
***************
*** 940,946 ****
  
  	if ($st_cat[$ST_MTIME] < $st_man[$ST_MTIME]) {
  
! 	    $command = (($manpage =~ m:\.Z:) ? $ZCAT : $CAT)
  			. " < $manpage | $CATSET";
  
  	    $command = &insert_filters($command, $manpage);
--- 950,956 ----
  
  	if ($st_cat[$ST_MTIME] < $st_man[$ST_MTIME]) {
  
! 	    $command = (($manpage =~ m:\.(g?z|Z):) ? $ZCAT : $CAT)
  			. " < $manpage | $CATSET";
  
  	    $command = &insert_filters($command, $manpage);
***************
*** 962,968 ****
  
  	    printf STDERR "Reformatting page.  Please wait ... " if $isatty;
  
! 	    $command .= "| $COMPRESS" if $catpage =~ /\.Z/;
  	    $command .= "> $tmppage";
  
  	    $SIG{'INT'} = $SIG{'QUIT'} = $SIG{'HUP'} = $SIG{'TERM'}  
--- 972,978 ----
  
  	    printf STDERR "Reformatting page.  Please wait ... " if $isatty;
  
! 	    $command .= "| $COMPRESS" if $catpage =~ /\.(g?z|Z)/;
  	    $command .= "> $tmppage";
  
  	    $SIG{'INT'} = $SIG{'QUIT'} = $SIG{'HUP'} = $SIG{'TERM'}  
***************
*** 994,1000 ****
  		$SIG{'PIPE'} = 'DEFAULT';
  
  	} 
! 	$command = (($catpage =~ m:\.Z:)
  			? $ZCAT
  			: $CAT)
  		    . " < $catpage";
--- 1004,1010 ----
  		$SIG{'PIPE'} = 'DEFAULT';
  
  	} 
! 	$command = (($catpage =~ m:\.(g?z|Z):)
  			? $ZCAT
  			: $CAT)
  		    . " < $catpage";
***************
*** 1088,1099 ****
      local($c, $PAGE) = @_;
      local($page,$sect, $prs, $prdir);
  
!     ( $page = $PAGE ) =~ s/\.Z//;
      ($prdir = $page) =~ s#/[^/]*$##;
      $prdir =~ s#man([^/]*)$#pr$1#;
      $page =~ s#.*/([^/]+)$#$1#;
  
!     $PAGE = "$ZCAT < $PAGE|" if $PAGE =~ /\.Z/;
  
      (open PAGE) || die ("$program: can't open $PAGE to check filters: $!\n");
      warn "open $PAGE to check for filters in $_[0]\n" if $debug;
--- 1098,1109 ----
      local($c, $PAGE) = @_;
      local($page,$sect, $prs, $prdir);
  
!     ( $page = $PAGE ) =~ s/\.(g?z|Z)//;
      ($prdir = $page) =~ s#/[^/]*$##;
      $prdir =~ s#man([^/]*)$#pr$1#;
      $page =~ s#.*/([^/]+)$#$1#;
  
!     $PAGE = "$ZCAT < $PAGE|" if $PAGE =~ /\.(g?z|Z)/;
  
      (open PAGE) || die ("$program: can't open $PAGE to check filters: $!\n");
      warn "open $PAGE to check for filters in $_[0]\n" if $debug;
***************
*** 1226,1233 ****
      local(@retlist, $maxlen, $header, @idx , @st_man, @st_idx);
      # global no_idx_file, idx_file
  
!     ( $idx_file = $manpage ) =~ s:/man(\w+)(\.Z)?/:/idx$1/:;
!     $idx_file =~ s/\.Z//;
  
      require 'stat.pl' unless defined &Stat;
  
--- 1236,1243 ----
      local(@retlist, $maxlen, $header, @idx , @st_man, @st_idx);
      # global no_idx_file, idx_file
  
!     ( $idx_file = $manpage ) =~ s:/man(\w+)(\.(g?z|Z))?/:/idx$1/:;
!     $idx_file =~ s/\.(g?z|Z)//;
  
      require 'stat.pl' unless defined &Stat;
  
***************
*** 1244,1250 ****
  	return @saveidx = @retlist;
      } 
  
!     if (!open(manpage, $manpage =~ /\.Z/ ? "$ZCAT < $manpage|" : $manpage)) {
      	warn "$program: can't open $manpage: $!\n";
  	return ();
      }
--- 1254,1260 ----
  	return @saveidx = @retlist;
      } 
  
!     if (!open(manpage, $manpage =~ /\.(g?z|Z)/ ? "$ZCAT < $manpage|" : $manpage)) {
      	warn "$program: can't open $manpage: $!\n";
  	return ();
      }
***************
*** 1483,1489 ****
  		    print "skipping non-man file: $path\n" if $debug;
  		    next;
  		} 
! 		if ($FILE =~ /\.Z$/ || $dir =~ /\.Z$/) {
  		    $FILE = "$ZCAT $FILE|";
  		} 
  		print STDERR "grepping $path\n" if $debug;
--- 1493,1499 ----
  		    print "skipping non-man file: $path\n" if $debug;
  		    next;
  		} 
! 		if ($FILE =~ /\.(g?z|Z)$/ || $dir =~ /\.(g?z|Z)$/) {
  		    $FILE = "$ZCAT $FILE|";
  		} 
  		print STDERR "grepping $path\n" if $debug;
diff -C3 man-orig/man.1 man-fix/man.1
*** man-orig/man.1	Sun Aug 15 23:25:06 1993
--- man-fix/man.1	Sun Aug 15 23:39:17 1993
***************
*** 481,489 ****
  .B \-g
  Grep through all man pages for one or more 
  .I perl
! expressions.  Compressed man pages will be 
! correctly processed
! by 
  .M zcat 1L .
  .TP
  .B \-t
--- 481,488 ----
  .B \-g
  Grep through all man pages for one or more 
  .I perl
! expressions.  Compressed man pages will be correctly processed
! by the GNU zip (Gzip) version of 
  .M zcat 1L .
  .TP
  .B \-t
***************
*** 724,729 ****
--- 723,729 ----
  .M nroff 1 ,
  .M troff 1L ,
  .M compress 1L ,
+ .M gzip 1L ,
  .M dbm 3X ,
  .M man 7 ,
  .M catman 8 ,
***************
*** 777,785 ****
  \fIul\fP,
  \fIcol\fP,
  \fIegrep\fP, and
! \fIcompress\fP
  .IP \(bu 5
! whether you have compressed man pages and how they are stored
  .IP \(bu 5
  which section aliases you want (as in 
  .B public
--- 777,785 ----
  \fIul\fP,
  \fIcol\fP,
  \fIegrep\fP, and
! \fIgzip\fP
  .IP \(bu 5
! whether you have gziped man pages and how they are stored
  .IP \(bu 5
  which section aliases you want (as in 
  .B public
***************
*** 794,806 ****
  .PP 
  To save disk space at the expense of execution time, a site may 
  wish to run 
! .M compress 1L 
  on the manual entries where available.  The
  .I man
  program
! understands how to read compressed man 
! pages, and knows to create a compressed cat page if the source
! man page was compressed to start with.
  .PP 
  When running on slow \s-1CPU\s0s, the start-up time for parsing the
  script may be annoying.  These sites can skip this parsing phase
--- 794,806 ----
  .PP 
  To save disk space at the expense of execution time, a site may 
  wish to run 
! .M gzip 1L 
  on the manual entries where available.  The
  .I man
  program
! understands how to read gziped man 
! pages, and knows to create a gziped cat page if the source
! man page was gziped to start with.
  .PP 
  When running on slow \s-1CPU\s0s, the start-up time for parsing the
  script may be annoying.  These sites can skip this parsing phase
***************
*** 941,947 ****
  .IR troff .
  .PP
  Not all systems have 
! .I compress
  installed on them.
  .SH AUTHOR
  Tom Christiansen
--- 941,947 ----
  .IR troff .
  .PP
  Not all systems have 
! .I gzip
  installed on them.
  .SH AUTHOR
  Tom Christiansen

>> Bill Middleton(wjm) wrote on Thu, 2 Sep 1993 15:58:04 -0500:
wjm> Yes please.  
Appended below.

Mark

---------- 8< ---------- 8< ---------- 8< ---------- 8< ---------- 8< --------
diff -C3 man-orig/CHANGES man-fix/CHANGES
*** man-orig/CHANGES	Sun Aug 15 23:25:08 1993
--- man-fix/CHANGES	Mon Aug 16 10:25:00 1993
***************
*** 1,3 ****
--- 1,5 ----
+ 16 Aug 93: Modified by Mark Borges <mdb@noaacrd.colorado.edu> to
+            handle GNU zip (gzip) compressed files. 
  
      *   extra utils
  
diff -C3 man-orig/README man-fix/README
*** man-orig/README	Sun Aug 15 23:25:07 1993
--- man-fix/README	Thu Sep  2 15:13:57 1993
***************
*** 16,18 ****
--- 16,49 ----
  
  copying is ok, just don't remove my name or try to sell it.
  read the man pages first.
+ -------------------------------------------------------------------------------
+ Notes on GNU zip (gzip) modifications by Mark Borges <mdb@noaacrd.colorado.edu>
+ 
+ 1) You will need to obtain gzip version 1.2.3 or later from GNU archive sites.
+ 
+ 2) $ZCAT is presumed to be that distributed with gzip; specifically, GNU 
+     zcat *must* come before /usr/ucb/zcat. By default, $ZCAT = zcat;
+     you may want to change it to $ZCAT = gzcat; if necessary.
+  
+ 3) COMPRESS_DIR is disabled by default. I don't use it, and I don't
+    know how to fix it.
+ 
+ 4) There is a known inconsistency in the creation of compressed
+    cat-pages from compressed man-pages. This is because:
+ 
+ 	a) provision is made for only one COMPRESS program (gzip by
+ 	   default);
+ 
+ 	b) gzip can only write gzip files, not compress files.
+ 
+    As a consequence, compressed cat-pages created from compressed
+    man-pages by gzip, may be misleading, e.g., 
+ 
+ 	man/man1/who.1.Z -> man/cat1/who.1.Z, if possible
+ 
+    but man1/who.1.Z is compressed, while cat1/who.1.Z is gzip'd. This
+    is not a problem if you use the gzip version of zcat (it ignores
+    the suffix anyway). If someone wants to take the time to fix this,
+    please e-mail me any patches.
+ 
+    
diff -C3 man-orig/catman man-fix/catman
*** man-orig/catman	Sun Aug 15 23:25:06 1993
--- man-fix/catman	Thu Sep  2 15:32:59 1993
***************
*** 12,18 ****
  $EQN	    = "neqn";
  # $MAKEWHATIS = "/usr/lib/makewhatis";
  $MAKEWHATIS = "/usr/local/lib/makewhatis";
! $COMPRESS   = "compress";
  $NROFF	    = "nroff";
  $COL 	    = "col";
  $CAT	    = "cat";
--- 12,18 ----
  $EQN	    = "neqn";
  # $MAKEWHATIS = "/usr/lib/makewhatis";
  $MAKEWHATIS = "/usr/local/lib/makewhatis";
! $COMPRESS   = "gzip";
  $NROFF	    = "nroff";
  $COL 	    = "col";
  $CAT	    = "cat";
***************
*** 93,116 ****
  	    } 
  
  	    if (!-e $manpage) {
! 		$manpage .= '.Z';
  		next unless -e $manpage;
  	    } 
  
  	    ($catpage = $manpage) 
! 		=~ s,^(.*)/man([^\.]*)(\.Z)?/([^/]*)$,$1/cat$2$3/$4,;
  
  	    ($catdir = $catpage) =~ s#/[^/]*$##;
  	    next manpage unless -d $catdir && -w _;
  
  	    if ((stat(_))[9] > (stat($catpage))[9]) {
! 		$command = (($manpage =~ m:\.Z:) ? $ZCAT : $CAT)
  			    . " < $manpage | $CATSET";
  
  		$command = &insert_filters($command, $manpage);
  		$command =~ s,-man,$path/tmac.an, if -e "$path/tmac.an";
  
! 		$command .= "| $COMPRESS " if $catpage =~ /\.Z/;
  
  		$command .= "> $catpage";
  
--- 93,122 ----
  	    } 
  
  	    if (!-e $manpage) {
! 		if (-e "${manpage}.gz") {
! 		    $manpage .= '.gz';
! 		} elsif (-e "${manpage}.z") {
! 		    $manpage .= '.z';
! 		} elsif (-e "${manpage}.Z") {
! 		    $manpage .= '.Z';
! 		}
  		next unless -e $manpage;
  	    } 
  
  	    ($catpage = $manpage) 
! 		=~ s,^(.*)/man([^\.]*)(\.(g?z|Z))?/([^/]*)$,$1/cat$2$3/$5,;
  
  	    ($catdir = $catpage) =~ s#/[^/]*$##;
  	    next manpage unless -d $catdir && -w _;
  
  	    if ((stat(_))[9] > (stat($catpage))[9]) {
! 		$command = (($manpage =~ m:\.(g?z|Z):) ? $ZCAT : $CAT)
  			    . " < $manpage | $CATSET";
  
  		$command = &insert_filters($command, $manpage);
  		$command =~ s,-man,$path/tmac.an, if -e "$path/tmac.an";
  
! 		$command .= "| $COMPRESS " if $catpage =~ /\.(g?z|Z)/;
  
  		$command .= "> $catpage";
  
***************
*** 136,142 ****
      local($command, $PAGE) = @_;
  
  
!     $PAGE = "$ZCAT < $PAGE|" if $PAGE =~ /\.Z/;
  
      (open PAGE) || die ("can't open $page to check filters: $!\n");
  
--- 142,148 ----
      local($command, $PAGE) = @_;
  
  
!     $PAGE = "$ZCAT < $PAGE|" if $PAGE =~ /(\.(g?z|Z))/;
  
      (open PAGE) || die ("can't open $page to check filters: $!\n");
  
diff -C3 man-orig/makewhatis man-fix/makewhatis
*** man-orig/makewhatis	Sun Aug 15 23:25:08 1993
--- man-fix/makewhatis	Mon Aug 16 11:01:46 1993
***************
*** 14,20 ****
  
  ($program = $0) =~ s,.*/,,;
  
! $UNCOMPRESS = "uncompress";
  
  $MAXWHATISLEN =  300;   
  $MAXDATUM     = 1024; 	# DBM is such a pain
--- 14,20 ----
  
  ($program = $0) =~ s,.*/,,;
  
! $UNCOMPRESS = "gunzip";
  
  $MAXWHATISLEN =  300;   
  $MAXDATUM     = 1024; 	# DBM is such a pain
***************
*** 119,125 ****
  	}
  
  	($dirext) = $mandir =~ /man(.*)$/;
! 	$dirext =~ s/\.Z$//;
  
  	print "subdir is $mandir\n" if $debug;
  
--- 119,125 ----
  	}
  
  	($dirext) = $mandir =~ /man(.*)$/;
! 	$dirext =~ s/\.(g?z|Z)$//;
  
  	print "subdir is $mandir\n" if $debug;
  
***************
*** 131,137 ****
  	# read each file in directory.  use readdir not globbing
  	# because we don't want to blow up on huge directories
  FILE:	while ($FILE = readdir(mandir)) {
! 	    $compressed = $mandir =~ m:.*\.Z:;
  	    next FILE if $FILE =~ /^\.{1,2}/;
  
  	    if ($FILE !~ /\S\.[^Z\s]/) {
--- 131,137 ----
  	# read each file in directory.  use readdir not globbing
  	# because we don't want to blow up on huge directories
  FILE:	while ($FILE = readdir(mandir)) {
! 	    $compressed = $mandir =~ m:.*\.(g?z|Z):;
  	    next FILE if $FILE =~ /^\.{1,2}/;
  
  	    if ($FILE !~ /\S\.[^Z\s]/) {
***************
*** 140,162 ****
  	    } 
  
  	    # this will be optimized into a case statement
! 	    if      ($FILE =~ /\.old(\.Z)?$/i) {
  		next;
! 	    } elsif ($FILE =~ /\.bak(\.Z)?$/i) {
  		next;
! 	    } elsif ($FILE =~ /\.out(\.Z)?$/i) {
  		next;
! 	    } elsif ($FILE =~ /~(\.Z)?$/) {
  		next;
  	    }
  
! 	    ($tmpfile = $FILE) =~ s/\.Z$//;
  
  	    ($filenam, $filext) = 
  		$tmpfile =~ /^(\S+)\.([^.]+)$/;
  
! 	    #if ($filext eq '.Z') {
! 		#($filenam, $filext) = $filenam =~ /^(\S+)\.([^.]+)(\.Z)?$/;
  	    #}
  
  	    if ($filext !~ /^${dirext}.*/ && $mandir ne 'mano') {
--- 140,165 ----
  	    } 
  
  	    # this will be optimized into a case statement
! 	    if      ($FILE =~ /\.old(\.(g?z|Z))?$/i) {
  		next;
! 	    } elsif ($FILE =~ /\.bak(\.(g?z|Z))?$/i) {
  		next;
! 	    } elsif ($FILE =~ /\.out(\.(g?z|Z))?$/i) {
  		next;
! 	    } elsif ($FILE =~ /~(\.(g?z|Z))?$/) {
  		next;
  	    }
  
! 	    ($tmpfile = $FILE) =~ s/\.(g?z|Z)$//;
  
  	    ($filenam, $filext) = 
  		$tmpfile =~ /^(\S+)\.([^.]+)$/;
  
! # Tom has the following commented out, so I'll follow suit <mdb>.
! 
! 	    #if ($filext eq '.Z' || $filext eq '.gz' || $filext eq '.z' )
! 	    #{
! 		#($filenam, $filext) = $filenam =~ /^(\S+)\.([^.]+)(\.(g?z|Z))?$/;
  	    #}
  
  	    if ($filext !~ /^${dirext}.*/ && $mandir ne 'mano') {
***************
*** 183,196 ****
  		&chopext($page = $FILE);
  		unless ($WHATIS{$page}) {
  		    print "forgot $page\n" if $debug;
! 		    $apage =~ s/\.Z$//;
  		    &store_indirect($page, $apage);
  		}
  		next FILE;
  	    } 
  	    $seen{$st_dev,$st_ino} = $FILE;
  
! 	    $compressed |= $FILE =~ /\.Z$/;
  	    
  	    if (!open(FILE, $compressed ? "$UNCOMPRESS < $FILE |" : $FILE)) {
  		warn "can't open $FILE: $!\n";
--- 186,199 ----
  		&chopext($page = $FILE);
  		unless ($WHATIS{$page}) {
  		    print "forgot $page\n" if $debug;
! 		    $apage =~ s/\.(g?z|Z)$//;
  		    &store_indirect($page, $apage);
  		}
  		next FILE;
  	    } 
  	    $seen{$st_dev,$st_ino} = $FILE;
  
! 	    $compressed |= $FILE =~ /\.(g?z|Z)$/;
  	    
  	    if (!open(FILE, $compressed ? "$UNCOMPRESS < $FILE |" : $FILE)) {
  		warn "can't open $FILE: $!\n";
***************
*** 273,280 ****
  	$indirect = $1;
  	($page)  = $FILE     =~ m:([^.]+)\.[^.]*$:;
  	($page2) = $indirect =~ m:.*/([^/]+)$:;
! 	($indirect2 = $indirect) =~ s!/!.Z/!;
! 	if (-e "../$indirect" || -e "../$indirect.Z" || -e $indirect2) {
  	    $so{$page} = $page2;
  	    print "$FILE: .so alias for $indirect\n" if $debug;
  	} else {
--- 276,283 ----
  	$indirect = $1;
  	($page)  = $FILE     =~ m:([^.]+)\.[^.]*$:;
  	($page2) = $indirect =~ m:.*/([^/]+)$:;
! 	($indirect2 = $indirect) =~ s!/!.z/!;
! 	if (-e "../$indirect" || -e "../$indirect.z" || -e $indirect2) {
  	    $so{$page} = $page2;
  	    print "$FILE: .so alias for $indirect\n" if $debug;
  	} else {
***************
*** 338,344 ****
  		$cmdlist = substr($cmdlist,0,$MAXWHATISLEN) . "...";
  	    } 
  
! 	    ($tmpfile = $FILE) =~ s/\.Z$//;
  	    ($page, $section) = $tmpfile =~ /^(\S+)\.(\S+)$/;
  	    $cmdlist = $page if $needcmdlist; 
  
--- 341,347 ----
  		$cmdlist = substr($cmdlist,0,$MAXWHATISLEN) . "...";
  	    } 
  
! 	    ($tmpfile = $FILE) =~ s/\.(g?z|Z)$//;
  	    ($page, $section) = $tmpfile =~ /^(\S+)\.(\S+)$/;
  	    $cmdlist = $page if $needcmdlist; 
  
***************
*** 367,373 ****
      }  
      unless ($foundname) {
  	print STDERR "$FILE: no NAME lines, so has no whatis description!\n";
! 	($tmpfile = $FILE) =~ s/\.Z$//;
  	($page, $section) = $tmpfile =~ /^(\S+)\.(\S+)$/;
  	&store_direct($page, $page, $tmpfile, $dirext, 'NO DESCRIPTION');
      } 
--- 370,376 ----
      }  
      unless ($foundname) {
  	print STDERR "$FILE: no NAME lines, so has no whatis description!\n";
! 	($tmpfile = $FILE) =~ s/\.(g?z|Z)$//;
  	($page, $section) = $tmpfile =~ /^(\S+)\.(\S+)$/;
  	&store_direct($page, $page, $tmpfile, $dirext, 'NO DESCRIPTION');
      } 
***************
*** 387,393 ****
  
  
  sub chopext {
!     $_[0] =~ s/\.Z$//;
      $_[0] =~ s/\.[^.]+$//;
  } 
  
--- 390,396 ----
  
  
  sub chopext {
!     $_[0] =~ s/\.(g?z|Z)$//;
      $_[0] =~ s/\.[^.]+$//;
  } 
  
diff -C3 man-orig/makewhatis.8 man-fix/makewhatis.8
*** man-orig/makewhatis.8	Sun Aug 15 23:25:05 1993
--- man-fix/makewhatis.8	Mon Aug 16 10:16:33 1993
***************
*** 143,151 ****
  if the name of the subdirectory itself ends in \fB.Z\fP, as in \fBman8.Z\fP,
  then all its files are assumed to have been compressed with 
  .M compress 1L .
! Alternatively, individual files ending in \fB.Z\fP are also 
! considered to be compressed.
! Compressed files are processed with 
  .M zcat 1L .  
  .SH EXAMPLES
  .ft TA
--- 143,153 ----
  if the name of the subdirectory itself ends in \fB.Z\fP, as in \fBman8.Z\fP,
  then all its files are assumed to have been compressed with 
  .M compress 1L .
! Alternatively, individual files ending in \fB.gz\fP, \fB.z\fP, or \fB.Z\fP are
! also considered to be compressed. These compressed files are processed with 
! the GNU zip 
! .M gzip 1L 
! version of
  .M zcat 1L .  
  .SH EXAMPLES
  .ft TA
***************
*** 171,176 ****
--- 173,179 ----
  apropos(1),
  perl(1),
  compress(1L),
+ gzip(1L),
  dbm(3X),
  man(7),
  catman(8)
***************
*** 350,356 ****
  takes much longer to run if man pages are stored in compressed form.
  .SH BUGS
  Not all systems have 
! .I compress
  installed on them.
  .SH AUTHOR
  Tom Christiansen 
--- 353,361 ----
  takes much longer to run if man pages are stored in compressed form.
  .SH BUGS
  Not all systems have 
! .I compress 
! or
! .I gzip
  installed on them.
  .SH AUTHOR
  Tom Christiansen 
diff -C3 man-orig/man man-fix/man
*** man-orig/man	Sun Aug 15 23:25:10 1993
--- man-fix/man	Thu Sep  2 13:57:46 1993
***************
*** 6,11 ****
--- 6,13 ----
  # Copyright 1990 Convex Computer Corporation.
  # All rights reserved.
  #
+ # Revised 16 Aug 1993 by Mark Borges <mdb@noaacrd.colorado.edu>
+ # to handle GNU zip (gzip) *individually* compressed man pages.
  # --------------------------------------------------------------------------
  # begin configuration section
  #
***************
*** 58,71 ****
  $UL	  = '';		# set to '' if you haven't got ul
  die 'need either $UL or $COL' unless $UL || $COL;
  
! # need these for .Z files or dirs
! $COMPRESS = 'compress';
  $ZCAT	  = 'zcat';
  $CAT	  = 'cat';
  
  # define COMPRESS_DIR if pages might have moved to manX.Z/page.X (like HPs)
! $COMPRESS_DIR = 1;
! # define COMPRESS_PAGE if pages might have moved to manX/page.X.Z  (better)
  $COMPRESS_PAGE = 1;
  
  # Command to format man pages to be viewed on a tty or printed on a line printer
--- 60,75 ----
  $UL	  = '';		# set to '' if you haven't got ul
  die 'need either $UL or $COL' unless $UL || $COL;
  
! # need these for Gzip'ed files or dirs
! # $ZCAT must point to the gzip-supplied `zcat'. <mdb>
! $COMPRESS = 'gzip';
  $ZCAT	  = 'zcat';
  $CAT	  = 'cat';
  
  # define COMPRESS_DIR if pages might have moved to manX.Z/page.X (like HPs)
! # This has *not* been hacked to work with GZIP <mdb>.
! $COMPRESS_DIR = 0;
! # define COMPRESS_PAGE if pages might have moved to manX/page.X.gz  (better)
  $COMPRESS_PAGE = 1;
  
  # Command to format man pages to be viewed on a tty or printed on a line printer
***************
*** 79,85 ****
  
  # flags: GNU likes -i, BSD doesn't; both like -h, but BSD doesn't document it
  # if you don't put -i here, i'll make up for it later the hard way
! $EGREP = '/usr/local/bin/egrep';	
  if (-x $EGREP) {
      $EGREP .= ' -i -h';
  } else {
--- 83,90 ----
  
  # flags: GNU likes -i, BSD doesn't; both like -h, but BSD doesn't document it
  # if you don't put -i here, i'll make up for it later the hard way
! #$EGREP = '/usr/local/bin/egrep';	
! $EGREP = '/gfdl2/mdb/gnu/bin/egrep';	
  if (-x $EGREP) {
      $EGREP .= ' -i -h';
  } else {
***************
*** 459,466 ****
  	printed (if -d flag) and -h will be assumed for that \$manroot only.
      * If \$manroot/tmac.an exists, it will be used for formatting 
  	instead of the normal -man macros.
!     * Man pages may be compressed either in (for example) man1.Z/who.1 
!         or man1/who.1.Z; cat pages will go into corresponding places.
      * If the man page contains .EQ or .TS directives, eqn and/or tbl
          will be invoked as needed at format time.
  USAGE
--- 464,475 ----
  	printed (if -d flag) and -h will be assumed for that \$manroot only.
      * If \$manroot/tmac.an exists, it will be used for formatting 
  	instead of the normal -man macros.
!     * Man pages may be compressed in (for example) man1/who.1.gz,
!       man1/who.1.z, or man1/who.1.Z; cat pages will go into corresponding
!       places. *** But***, as gzip only supports one ouput format, 
!       man1/who.1.Z will be gzip'd, not compressed as the extension may
!       indicate. I'd call this a bug, but it still works iff you have 
!       gzip's `zcat' filter.
      * If the man page contains .EQ or .TS directives, eqn and/or tbl
          will be invoked as needed at format time.
  USAGE
***************
*** 776,784 ****
      return $path if -f $path;
  
      if ($COMPRESS_PAGE) {
! 	$path .= '.Z';
  	return $path if -f $path;
! 	$path =~ s/.Z//;
      } 
  
      if ($COMPRESS_DIR) {
--- 785,797 ----
      return $path if -f $path;
  
      if ($COMPRESS_PAGE) {
! 	$path = join('',$orig,'.gz');
  	return $path if -f $path;
! 	$path = join('',$orig,'.z');
! 	return $path if -f $path;
! 	$path = join('',$orig,'.Z');
! 	return $path if -f $path;
! #	$path =~ s/.Z//;
      } 
  
      if ($COMPRESS_DIR) {
***************
*** 816,823 ****
  sub bysection {
      local ($e1, $e2, $p1, $p2, $s1, $s2);
  
!     ($s1, $e1) = $a =~ m:.*/man([^/]+)/.*\.([^.]+)(\.Z)?$:;
!     ($s2, $e2) = $b =~ m:.*/man([^/]+)/.*\.([^.]+)(\.Z)?$:;
  
      $e1 = $s1 if $e1 !~ /^${s1}.*/;
      $e2 = $s2 if $e2 !~ /^${s2}.*/;
--- 829,836 ----
  sub bysection {
      local ($e1, $e2, $p1, $p2, $s1, $s2);
  
!     ($s1, $e1) = $a =~ m:.*/man([^/]+)/.*\.([^.]+)(\.(g?z|Z))?$:;
!     ($s2, $e2) = $b =~ m:.*/man([^/]+)/.*\.([^.]+)(\.(g?z|Z))?$:;
  
      $e1 = $s1 if $e1 !~ /^${s1}.*/;
      $e2 = $s2 if $e2 !~ /^${s2}.*/;
***************
*** 863,871 ****
      local ($manroot);
      local ($macros);
  
!     ($manroot) = $file =~ m,^(.*)/man([^\.]*)(\.Z)?/([^/]*),;
  
!     $command = ((($file =~ m:\.Z:) 
  			? $ZCAT 
  			: $CAT) 
  		. " < $file | $TYPESET");
--- 876,884 ----
      local ($manroot);
      local ($macros);
  
!     ($manroot) = $file =~ m,^(.*)/man([^\.]*)(\.(g?z|Z))?/([^/]*),;
  
!     $command = ((($file =~ m:\.(g?z|Z):) 
  			? $ZCAT 
  			: $CAT) 
  		. " < $file | $TYPESET");
***************
*** 899,905 ****
  	return;
      } 
      if ($fromfile) {
! 	$command = (($manpage =~ m:\.Z/:) ? $ZCAT : $CAT)
  			. " < $manpage | $CATSET";
  	&insert_filters($command, $manpage);
      } else {
--- 912,918 ----
  	return;
      } 
      if ($fromfile) {
! 	$command = (($manpage =~ m:\.(g?z|Z):) ? $ZCAT : $CAT)
  			. " < $manpage | $CATSET";
  	&insert_filters($command, $manpage);
      } else {
***************
*** 908,914 ****
  
  
  	($catpage = $manpage) 
! 	    =~ s,^(.*)/man([^\.]*)(\.Z)?/([^/]*)$,$1/cat$2/$4,;
  
  	$manroot = $1;
  
--- 921,927 ----
  
  
  	($catpage = $manpage) 
! 	    =~ s,^(.*)/man([^\.]*)(\.(g?z|Z))?/([^/]*)$,$1/cat$2/$5,;
  
  	$manroot = $1;
  
***************
*** 940,946 ****
  
  	if ($st_cat[$ST_MTIME] < $st_man[$ST_MTIME]) {
  
! 	    $command = (($manpage =~ m:\.Z:) ? $ZCAT : $CAT)
  			. " < $manpage | $CATSET";
  
  	    $command = &insert_filters($command, $manpage);
--- 953,959 ----
  
  	if ($st_cat[$ST_MTIME] < $st_man[$ST_MTIME]) {
  
! 	    $command = (($manpage =~ m:\.(g?z|Z):) ? $ZCAT : $CAT)
  			. " < $manpage | $CATSET";
  
  	    $command = &insert_filters($command, $manpage);
***************
*** 962,968 ****
  
  	    printf STDERR "Reformatting page.  Please wait ... " if $isatty;
  
! 	    $command .= "| $COMPRESS" if $catpage =~ /\.Z/;
  	    $command .= "> $tmppage";
  
  	    $SIG{'INT'} = $SIG{'QUIT'} = $SIG{'HUP'} = $SIG{'TERM'}  
--- 975,981 ----
  
  	    printf STDERR "Reformatting page.  Please wait ... " if $isatty;
  
! 	    $command .= "| $COMPRESS" if $catpage =~ /\.(g?z|Z)/;
  	    $command .= "> $tmppage";
  
  	    $SIG{'INT'} = $SIG{'QUIT'} = $SIG{'HUP'} = $SIG{'TERM'}  
***************
*** 994,1000 ****
  		$SIG{'PIPE'} = 'DEFAULT';
  
  	} 
! 	$command = (($catpage =~ m:\.Z:)
  			? $ZCAT
  			: $CAT)
  		    . " < $catpage";
--- 1007,1013 ----
  		$SIG{'PIPE'} = 'DEFAULT';
  
  	} 
! 	$command = (($catpage =~ m:\.(g?z|Z):)
  			? $ZCAT
  			: $CAT)
  		    . " < $catpage";
***************
*** 1088,1099 ****
      local($c, $PAGE) = @_;
      local($page,$sect, $prs, $prdir);
  
!     ( $page = $PAGE ) =~ s/\.Z//;
      ($prdir = $page) =~ s#/[^/]*$##;
      $prdir =~ s#man([^/]*)$#pr$1#;
      $page =~ s#.*/([^/]+)$#$1#;
  
!     $PAGE = "$ZCAT < $PAGE|" if $PAGE =~ /\.Z/;
  
      (open PAGE) || die ("$program: can't open $PAGE to check filters: $!\n");
      warn "open $PAGE to check for filters in $_[0]\n" if $debug;
--- 1101,1112 ----
      local($c, $PAGE) = @_;
      local($page,$sect, $prs, $prdir);
  
!     ( $page = $PAGE ) =~ s/\.(g?z|Z)//;
      ($prdir = $page) =~ s#/[^/]*$##;
      $prdir =~ s#man([^/]*)$#pr$1#;
      $page =~ s#.*/([^/]+)$#$1#;
  
!     $PAGE = "$ZCAT < $PAGE|" if $PAGE =~ /\.(g?z|Z)/;
  
      (open PAGE) || die ("$program: can't open $PAGE to check filters: $!\n");
      warn "open $PAGE to check for filters in $_[0]\n" if $debug;
***************
*** 1226,1233 ****
      local(@retlist, $maxlen, $header, @idx , @st_man, @st_idx);
      # global no_idx_file, idx_file
  
!     ( $idx_file = $manpage ) =~ s:/man(\w+)(\.Z)?/:/idx$1/:;
!     $idx_file =~ s/\.Z//;
  
      require 'stat.pl' unless defined &Stat;
  
--- 1239,1246 ----
      local(@retlist, $maxlen, $header, @idx , @st_man, @st_idx);
      # global no_idx_file, idx_file
  
!     ( $idx_file = $manpage ) =~ s:/man(\w+)(\.(g?z|Z))?/:/idx$1/:;
!     $idx_file =~ s/\.(g?z|Z)//;
  
      require 'stat.pl' unless defined &Stat;
  
***************
*** 1244,1250 ****
  	return @saveidx = @retlist;
      } 
  
!     if (!open(manpage, $manpage =~ /\.Z/ ? "$ZCAT < $manpage|" : $manpage)) {
      	warn "$program: can't open $manpage: $!\n";
  	return ();
      }
--- 1257,1263 ----
  	return @saveidx = @retlist;
      } 
  
!     if (!open(manpage, $manpage =~ /\.(g?z|Z)/ ? "$ZCAT < $manpage|" : $manpage)) {
      	warn "$program: can't open $manpage: $!\n";
  	return ();
      }
***************
*** 1483,1489 ****
  		    print "skipping non-man file: $path\n" if $debug;
  		    next;
  		} 
! 		if ($FILE =~ /\.Z$/ || $dir =~ /\.Z$/) {
  		    $FILE = "$ZCAT $FILE|";
  		} 
  		print STDERR "grepping $path\n" if $debug;
--- 1496,1502 ----
  		    print "skipping non-man file: $path\n" if $debug;
  		    next;
  		} 
! 		if ($FILE =~ /\.(g?z|Z)$/ || $dir =~ /\.(g?z|Z)$/) {
  		    $FILE = "$ZCAT $FILE|";
  		} 
  		print STDERR "grepping $path\n" if $debug;
diff -C3 man-orig/man.1 man-fix/man.1
*** man-orig/man.1	Sun Aug 15 23:25:06 1993
--- man-fix/man.1	Sun Aug 15 23:39:17 1993
***************
*** 481,489 ****
  .B \-g
  Grep through all man pages for one or more 
  .I perl
! expressions.  Compressed man pages will be 
! correctly processed
! by 
  .M zcat 1L .
  .TP
  .B \-t
--- 481,488 ----
  .B \-g
  Grep through all man pages for one or more 
  .I perl
! expressions.  Compressed man pages will be correctly processed
! by the GNU zip (Gzip) version of 
  .M zcat 1L .
  .TP
  .B \-t
***************
*** 724,729 ****
--- 723,729 ----
  .M nroff 1 ,
  .M troff 1L ,
  .M compress 1L ,
+ .M gzip 1L ,
  .M dbm 3X ,
  .M man 7 ,
  .M catman 8 ,
***************
*** 777,785 ****
  \fIul\fP,
  \fIcol\fP,
  \fIegrep\fP, and
! \fIcompress\fP
  .IP \(bu 5
! whether you have compressed man pages and how they are stored
  .IP \(bu 5
  which section aliases you want (as in 
  .B public
--- 777,785 ----
  \fIul\fP,
  \fIcol\fP,
  \fIegrep\fP, and
! \fIgzip\fP
  .IP \(bu 5
! whether you have gziped man pages and how they are stored
  .IP \(bu 5
  which section aliases you want (as in 
  .B public
***************
*** 794,806 ****
  .PP 
  To save disk space at the expense of execution time, a site may 
  wish to run 
! .M compress 1L 
  on the manual entries where available.  The
  .I man
  program
! understands how to read compressed man 
! pages, and knows to create a compressed cat page if the source
! man page was compressed to start with.
  .PP 
  When running on slow \s-1CPU\s0s, the start-up time for parsing the
  script may be annoying.  These sites can skip this parsing phase
--- 794,806 ----
  .PP 
  To save disk space at the expense of execution time, a site may 
  wish to run 
! .M gzip 1L 
  on the manual entries where available.  The
  .I man
  program
! understands how to read gziped man 
! pages, and knows to create a gziped cat page if the source
! man page was gziped to start with.
  .PP 
  When running on slow \s-1CPU\s0s, the start-up time for parsing the
  script may be annoying.  These sites can skip this parsing phase
***************
*** 941,947 ****
  .IR troff .
  .PP
  Not all systems have 
! .I compress
  installed on them.
  .SH AUTHOR
  Tom Christiansen
--- 941,947 ----
  .IR troff .
  .PP
  Not all systems have 
! .I gzip
  installed on them.
  .SH AUTHOR
  Tom Christiansen

