From krister@gazonk.net  Wed May 14 03:47:11 2003
Return-Path: <krister@gazonk.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 200BE37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 14 May 2003 03:47:11 -0700 (PDT)
Received: from duronimo.local.gazonk.net (fw1.tcn-catv.ne.jp [219.109.192.74])
	by mx1.FreeBSD.org (Postfix) with ESMTP id E891643F85
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 14 May 2003 03:47:09 -0700 (PDT)
	(envelope-from krister@gazonk.net)
Received: from yuri.local.gazonk.net (yuri.local.gazonk.net [192.168.0.2])
	by duronimo.local.gazonk.net (8.12.9/8.12.9) with ESMTP id h4EAZI5L075085
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 14 May 2003 19:35:18 +0900 (JST)
	(envelope-from krister@duronimo.local.gazonk.net)
Received: from yuri.local.gazonk.net (localhost [127.0.0.1])
	by yuri.local.gazonk.net (8.12.9/8.12.9) with ESMTP id h4EAO6Bb063136
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 14 May 2003 19:24:06 +0900 (JST)
	(envelope-from krister@yuri.local.gazonk.net)
Received: (from krister@localhost)
	by yuri.local.gazonk.net (8.12.9/8.12.9/Submit) id h4EAO5L5063135;
	Wed, 14 May 2003 19:24:05 +0900 (JST)
Message-Id: <200305141024.h4EAO5L5063135@yuri.local.gazonk.net>
Date: Wed, 14 May 2003 19:24:05 +0900 (JST)
From: Krister Joas <krister@gazonk.net>
Reply-To: Krister Joas <krister@gazonk.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: catman compresses with wrong program if source files are uncompressed
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         52213
>Category:       bin
>Synopsis:       catman compresses with wrong program if source files are uncompressed
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 14 03:50:16 PDT 2003
>Closed-Date:    Wed May 21 06:27:42 PDT 2003
>Last-Modified:  Wed May 21 06:27:42 PDT 2003
>Originator:     Krister Joas
>Release:        FreeBSD 5.1-BETA i386
>Organization:
Gazonk
>Environment:
System: FreeBSD yuri.local.gazonk.net 5.1-BETA FreeBSD 5.1-BETA #1: Sun May 11 23:38:06 JST 2003 root@yuri.local.gazonk.net:/usr/obj/usr/src/sys/YURI5 i386


>Description:

If the system is installed with NOMANCOMPRESS=true in /etc/make.conf
so that man pages are installed uncompressed, running catman results
in unusable preformated files in the corresponding cat? directories.
The files are compressed with bzip2 but with the extension .gz.
When running 'man' the files fail to uncompress.

>How-To-Repeat:

Run catman on a directory with uncompressed man-pages.  The files
in the cat? directories are bzip2'ed with extension .gz:

	$ file cat1/write.1.gz
	cat1/write.1.gz: bzip2 compressed data, block size = 900k
	$ man write
	zcat: /home/krister/man/cat1/write.1.gz: not in gzip format

>Fix:

The following patch fixes catman so that if the source file is
compressed the preformatted files are compressed with the same
program as the source and if the source files are uncompressed the
preformatted files are also uncompressed.

Index: catman.c
===================================================================
RCS file: /usr/cvs/freebsd/src/usr.bin/catman/catman.c,v
retrieving revision 1.5
diff -u -r1.5 catman.c
--- catman.c	29 Oct 2002 09:20:22 -0000	1.5
+++ catman.c	14 May 2003 10:06:09 -0000
@@ -461,9 +461,11 @@
 	}
 	snprintf(tmp_file, sizeof tmp_file, "%s.tmp", cat);
 	snprintf(cmd, sizeof cmd,
-	    "%scat %s | tbl | nroff -T%s -man | col | %s -c > %s.tmp",
+	    "%scat %s | tbl | nroff -T%s -man | col | %s > %s.tmp",
 	    zipped == BZIP ? BZ2CAT_CMD : zipped == GZIP ? GZCAT_CMD : "",
-	    src, nroff_device, zipped == GZIP ? GZ_CMD : BZ2_CMD, cat);
+	    src, nroff_device,
+	    zipped == BZIP ? BZ2_CMD : zipped == GZIP ? GZ_CMD : "cat",
+	    cat);
 	if (system(cmd) != 0)
 		err(1, "formatting pipeline");
 	if (rename(tmp_file, cat) < 0)
@@ -541,8 +543,8 @@
 						"warning, %s is uncompressed\n",
 						page_path);
 				}
-				snprintf(cat_path, sizeof cat_path, "%s/%s%s",
-				    cat_section, page_name, GZ_EXT);
+				snprintf(cat_path, sizeof cat_path, "%s/%s",
+				    cat_section, page_name);
 				if (expected != NULL) {
 					asprintf(&expected[nexpected++],
 					    "%s%s", page_name, GZ_EXT);
>Release-Note:
>Audit-Trail:

From: Ruslan Ermilov <ru@FreeBSD.org>
To: Krister Joas <krister@gazonk.net>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/52213: catman compresses with wrong program if source files are uncompressed
Date: Fri, 16 May 2003 12:09:39 +0300

 On Wed, May 14, 2003 at 07:24:05PM +0900, Krister Joas wrote:
 > 
 > The following patch fixes catman so that if the source file is
 > compressed the preformatted files are compressed with the same
 > program as the source and if the source files are uncompressed the
 > preformatted files are also uncompressed.
 > 
 I've cleaned up your patch a bit.
 
 %%%
 Index: catman.c
 ===================================================================
 RCS file: /home/ncvs/src/usr.bin/catman/catman.c,v
 retrieving revision 1.5
 diff -u -p -r1.5 catman.c
 --- catman.c	29 Oct 2002 09:20:22 -0000	1.5
 +++ catman.c	16 May 2003 09:03:22 -0000
 @@ -84,7 +84,7 @@ static const char *locale_device[] = {
  #define	BZ2_CMD		"bzip2"
  #define	BZ2_EXT		".bz2"
  #define	BZ2CAT_CMD	"bz"
 -#define	GZ_CMD		"gzip -n"
 +#define	GZ_CMD		"gzip"
  #define	GZ_EXT		".gz"
  #define	GZCAT_CMD	"z"
  enum Ziptype {NONE, BZIP, GZIP};
 @@ -461,9 +461,11 @@ process_page(char *mandir, char *src, ch
  	}
  	snprintf(tmp_file, sizeof tmp_file, "%s.tmp", cat);
  	snprintf(cmd, sizeof cmd,
 -	    "%scat %s | tbl | nroff -T%s -man | col | %s -c > %s.tmp",
 +	    "%scat %s | tbl | nroff -T%s -man | col | %s > %s.tmp",
  	    zipped == BZIP ? BZ2CAT_CMD : zipped == GZIP ? GZCAT_CMD : "",
 -	    src, nroff_device, zipped == GZIP ? GZ_CMD : BZ2_CMD, cat);
 +	    src, nroff_device,
 +	    zipped == BZIP ? BZ2_CMD : zipped == GZIP ? GZ_CMD : "cat",
 +	    cat);
  	if (system(cmd) != 0)
  		err(1, "formatting pipeline");
  	if (rename(tmp_file, cat) < 0)
 @@ -541,11 +543,11 @@ scan_section(char *mandir, char *section
  						"warning, %s is uncompressed\n",
  						page_path);
  				}
 -				snprintf(cat_path, sizeof cat_path, "%s/%s%s",
 -				    cat_section, page_name, GZ_EXT);
 +				snprintf(cat_path, sizeof cat_path, "%s/%s",
 +				    cat_section, page_name);
  				if (expected != NULL) {
  					asprintf(&expected[nexpected++],
 -					    "%s%s", page_name, GZ_EXT);
 +					    "%s", page_name);
  				}
  				process_page(mandir, page_path, cat_path, NONE);
  			}
 %%%
 
 -- 
 Ruslan Ermilov		Sysadmin and DBA,
 ru@sunbay.com		Sunbay Software AG,
 ru@FreeBSD.org		FreeBSD committer,
 +380.652.512.251	Simferopol, Ukraine
 
 http://www.FreeBSD.org	The Power To Serve
 http://www.oracle.com	Enabling The Information Age
State-Changed-From-To: open->closed 
State-Changed-By: ru 
State-Changed-When: Wed May 21 06:26:58 PDT 2003 
State-Changed-Why:  
Committed with a slight improvement, thanks! 


Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: ru 
Responsible-Changed-When: Wed May 21 06:26:58 PDT 2003 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=52213 
>Unformatted:
