From hetzels@northstar.hetzel.org  Sat Oct  2 02:59:15 2004
Return-Path: <hetzels@northstar.hetzel.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 2BFB416A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  2 Oct 2004 02:59:15 +0000 (GMT)
Received: from northstar.hetzel.org (tc248.hnet.net [38.119.191.248])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 60D8B43D54
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  2 Oct 2004 02:59:13 +0000 (GMT)
	(envelope-from hetzels@northstar.hetzel.org)
Received: from northstar.hetzel.org (localhost [127.0.0.1])
	by northstar.hetzel.org (8.13.1/8.13.1) with ESMTP id i92319Vw021438;
	Fri, 1 Oct 2004 22:01:10 -0500 (CDT)
	(envelope-from hetzels@northstar.hetzel.org)
Received: (from root@localhost)
	by northstar.hetzel.org (8.13.1/8.13.1/Submit) id i9230D09021422;
	Fri, 1 Oct 2004 22:00:14 -0500 (CDT)
	(envelope-from hetzels)
Message-Id: <200410020300.i9230D09021422@northstar.hetzel.org>
Date: Fri, 1 Oct 2004 22:00:14 -0500 (CDT)
From: "Scot W. Hetzel" <swhetzel@gmail.com>
Reply-To: "Scot W. Hetzel" <swhetzel@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: catman not creating cat pages for machine specifc man pages.
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         72243
>Category:       bin
>Synopsis:       catman not creating cat pages for machine specifc man pages.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 02 03:00:42 GMT 2004
>Closed-Date:    Wed Jan 12 15:29:13 GMT 2005
>Last-Modified:  Wed Jan 12 15:29:13 GMT 2005
>Originator:     Scot W. Hetzel
>Release:        FreeBSD 5.3-BETA6 i386
>Organization:
>Environment:
System: FreeBSD northstar.hetzel.org 5.3-BETA6 FreeBSD 5.3-BETA6 #3: Fri Oct 1 07:25:33 CDT 2004 root@northstar.hetzel.org:/usr/obj/usr/src/5x/sys/GENERIC i386

>Description:
	When you run catman, it fails to populate the machine specific cat pages.

>How-To-Repeat:
	# ls /usr/share/man/{man,cat}8/i386
	/usr/share/man/cat8/i386:

	/usr/share/man/man8/i386:
	apm.8.gz        apmconf.8.gz    apmd.8.gz       sconfig.8.gz    wlconfig.8.gz
	# echo catman | nice -5 su -m man
	# ls /usr/share/man/{man,cat}8/i386
        /usr/share/man/cat8/i386:

        /usr/share/man/man8/i386:
        apm.8.gz        apmconf.8.gz    apmd.8.gz       sconfig.8.gz    wlconfig.8.gz

	No cat pages were created for the man8/i386 man pages

>Fix:

	With the following patch, catman now creates the machine specific cat pages.

	#echo catman | nice -5 su -m man
	# ls /usr/share/man/{man,cat}8/i386
	/usr/share/man/cat8/i386:
	apm.8.gz        apmconf.8.gz    apmd.8.gz       sconfig.8.gz    wlconfig.8.gz

	/usr/share/man/man8/i386:
	apm.8.gz        apmconf.8.gz    apmd.8.gz       sconfig.8.gz    wlconfig.8.gz

	
--- patch begins here ---
Index: catman.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/catman/catman.c,v
retrieving revision 1.9
diff -u -r1.9 catman.c
--- catman.c	10 Jun 2003 02:18:00 -0000	1.9
+++ catman.c	2 Oct 2004 01:44:52 -0000
@@ -64,6 +64,7 @@
 static int rm_junk;		/* -r flag: remove garbage pages */
 static char *locale;		/* user's locale if -L is used */
 static char *lang_locale;	/* short form of locale */
+static char *machine;
 static int exit_code;		/* exit code to use when finished */
 
 /*
@@ -655,7 +656,20 @@
 			return;
 		}
 		for (i = 0; i < nsections; i++) {
+			char machine_dir[MAXPATHLEN];
+			struct stat st;
+
 			process_section(dir_name, entries[i]->d_name);
+
+			snprintf(machine_dir, sizeof machine_dir, "%s/%s/%s",
+				dir_name, entries[i]->d_name, machine);
+
+			if (stat(machine_dir, &st) == 0 && S_ISDIR(st.st_mode)) {
+				snprintf(machine_dir, sizeof machine_dir,
+					"%s/%s", entries[i]->d_name, machine);
+				process_section(dir_name, machine_dir);
+			}
+
 			free(entries[i]);
 		}
 		free(entries);
@@ -789,6 +803,10 @@
 	signal(SIGHUP, trap_signal);
 	signal(SIGQUIT, trap_signal);
 	signal(SIGTERM, trap_signal);
+
+	if ((machine = getenv("MACHINE")) == NULL)
+		machine = MACHINE;
+
 	if (optind == argc) {
 		const char *manpath = getenv("MANPATH");
 		if (manpath == NULL)
--- patch ends here ---
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: ru 
Responsible-Changed-When: Sat Oct 2 07:51:07 GMT 2004 
Responsible-Changed-Why:  
I will look into it, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=72243 
State-Changed-From-To: open->patched 
State-Changed-By: ru 
State-Changed-When: Wed Dec 22 16:05:43 GMT 2004 
State-Changed-Why:  
A slightly modified version of the original patch committed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=72243 
State-Changed-From-To: patched->closed 
State-Changed-By: ru 
State-Changed-When: Wed Jan 12 15:28:57 GMT 2005 
State-Changed-Why:  
Merged into RELENG_5. 

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