Subject: bin/714: man(1) ignores the section argument if $MANPATH is set
To: None <gnats-admin@NetBSD.ORG>
From: None <jhawk@MIT.EDU>
List: netbsd-bugs
Date: 01/07/1995 16:35:04
>Number:         714
>Category:       bin
>Synopsis:       man(1) ignores the section argument if $MANPATH is set
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan  7 16:35:02 1995
>Originator:     der Mouse
>Organization:
>Release:        1.0
>Environment:
System: NetBSD lola-granola 1.0 NetBSD 1.0 (LOLA-DDB) #62: Thu Jan 5 20:50:44 EST 1995 jtkohl@lola-granola:/u1/usr/src/sys/arch/i386/compile/LOLA-DDB i386

>Description:
>How-To-Repeat:
>Fix:

*** 1.1	1995/01/07 18:32:36
--- config.c	1995/01/08 00:27:21
***************
*** 29,38 ****
   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   */
  
  #ifndef lint
! static char sccsid[] = "@(#)config.c	8.5 (Berkeley) 11/26/93";
  #endif /* not lint */
  
  #include <sys/types.h>
--- 29,40 ----
   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
+  *
+  *	$NetBSD$
   */
  
  #ifndef lint
! static char sccsid[] = "@(#)config.c	8.7 (Berkeley) 1/3/94";
  #endif /* not lint */
  
  #include <sys/types.h>
***************
*** 77,82 ****
--- 79,86 ----
  		err(1, "%s", fname);
  	TAILQ_INIT(&head);
  	for (lcnt = 1; (p = fgetln(cfp, &len)) != NULL; ++lcnt) {
+ 		if (len == 1)			/* Skip empty lines. */
+ 			continue;
  		if (p[len - 1] != '\n') {	/* Skip corrupted lines. */
  			warnx("%s: line %d corrupted", fname, lcnt);
  			continue;
*** 1.1	1995/01/07 18:38:47
--- config.h	1995/01/08 00:27:21
***************
*** 31,37 ****
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   *
!  *	@(#)config.h	8.4 (Berkeley) 12/18/93
   */
  
  typedef struct _tag {
--- 31,38 ----
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   *
!  *	from: @(#)config.h	8.4 (Berkeley) 12/18/93
!  *	$NetBSD$
   */
  
  typedef struct _tag {
*** 1.1	1995/01/07 18:38:47
--- man.1	1995/01/08 00:27:21
***************
*** 29,37 ****
  .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  .\" SUCH DAMAGE.
  .\"
! .\"     @(#)man.1	8.2 (Berkeley) 11/26/93
  .\"
! .Dd November 26, 1993
  .Dt MAN 1
  .Os BSD 4
  .Sh NAME
--- 29,38 ----
  .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  .\" SUCH DAMAGE.
  .\"
! .\"     from:  @(#)man.1	8.2 (Berkeley) 1/2/94
! .\"	$NetBSD$
  .\"
! .Dd January 2, 1994
  .Dt MAN 1
  .Os BSD 4
  .Sh NAME
*** 1.1	1995/01/07 18:32:34
--- man.c	1995/01/08 00:27:21
***************
*** 29,34 ****
--- 29,36 ----
   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
+  *
+  *	$NetBSD$
   */
  
  #ifndef lint
***************
*** 38,44 ****
  #endif /* not lint */
  
  #ifndef lint
! static char sccsid[] = "@(#)man.c	8.13 (Berkeley) 12/20/93";
  #endif /* not lint */
  
  #include <sys/param.h>
--- 40,46 ----
  #endif /* not lint */
  
  #ifndef lint
! static char sccsid[] = "@(#)man.c	8.16 (Berkeley) 4/16/94";
  #endif /* not lint */
  
  #include <sys/param.h>
***************
*** 275,280 ****
--- 277,315 ----
  	}
  
  	/*
+ 	 * 4A: If MANPATH or _M was specified, and a section was also
+ 	 * specified, rewrite the section's paths, and place into
+ 	 * _default.
+ 	 */
+ 	if ( p_path && p_add == NULL && section != NULL) {
+ 		sectnewp = addlist("_section_new");
+ 		for (e_sectp = section->list.tqh_first;
+ 		    e_sectp != NULL; e_sectp = e_sectp->q.tqe_next) {
+ 			if (e_sectp->s[strlen(e_sectp->s) - 1] != '/') {
+ 				(void)snprintf(buf, sizeof(buf),
+ 				    "%s{/%s,}", e_sectp->s, machine);
+ 				if ((ep = malloc(sizeof(ENTRY))) == NULL ||
+ 				    (ep->s = strdup(buf)) == NULL)
+ 					err(1, NULL);
+ 				TAILQ_INSERT_HEAD(&defp->list, ep, q);
+ 				continue;
+ 			}
+ 			e_subp = (subp = getlist("_subdir")) == NULL ?
+ 			    NULL : subp->list.tqh_first;
+ 			for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
+ 				(void)snprintf(buf, sizeof(buf), "%s%s{/%s,}",
+ 				    e_sectp->s, e_subp->s, machine);
+ 				if ((ep = malloc(sizeof(ENTRY))) == NULL ||
+ 				    (ep->s = strdup(buf)) == NULL)
+ 					err(1, NULL);
+ 				TAILQ_INSERT_HEAD(&defp->list, ep, q);
+ 			}
+ 		}
+ 		sectnewp->s = section->s;
+ 	}
+ 	  
+ 
+ 	/*
  	 * 5: Search for the files.  Set up an interrupt handler, so the
  	 *    temporary files go away.
  	 */
***************
*** 731,736 ****
  usage()
  {
  	(void)fprintf(stderr,
!     "usage: man [-ac] [-C file] [-M path] [-m path] [section] title ...\n");
  	exit(1);
  }
--- 766,773 ----
  usage()
  {
  	(void)fprintf(stderr,
!     "usage: man [-achw] [-C file] [-M path] [-m path] [section] title ...\n");
  	exit(1);
  }
+ 
+ /*	$Id: man.c,v 1.2 1995/01/08 00:15:32 jhawk Exp $	*/
*** 1.1	1995/01/07 18:38:47
--- man.conf.5	1995/01/08 00:27:21
***************
*** 29,37 ****
  .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  .\" SUCH DAMAGE.
  .\"
! .\"	@(#)man.conf.5	8.4 (Berkeley) 11/26/93
  .\"
! .Dd November 26, 1993
  .Dt MAN.CONF 5
  .Os
  .Sh NAME
--- 29,38 ----
  .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  .\" SUCH DAMAGE.
  .\"
! .\"	from: @(#)man.conf.5	8.5 (Berkeley) 1/2/94
! .\"	$NetBSD$
  .\"
! .Dd January 2, 1994
  .Dt MAN.CONF 5
  .Os
  .Sh NAME
*** 1.1	1995/01/07 18:38:47
--- pathnames.h	1995/01/08 00:27:21
***************
*** 30,36 ****
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   *
!  *	@(#)pathnames.h	8.3 (Berkeley) 10/13/93
   */
  
  #define	_PATH_MANCONF	"/etc/man.conf"
--- 30,37 ----
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   *
!  *	from: @(#)pathnames.h	8.3 (Berkeley) 1/2/94
!  *	$NetBSD$
   */
  
  #define	_PATH_MANCONF	"/etc/man.conf"

>Audit-Trail:

I just spent some time tracking down these bugs. (I hope this usage of
gnats works). 

I've imported the 4.4lite version of man, which didn't really change
anything significant, and I've fixed the problem of MANPATH breaking
the section usage.

I would like an explanation from someone (CSRG?) as to why the whatis
file has been renamed. MIT has an established base of 4.3 machines
and trees for them with other architectures wherein it is significantly
annoying to have to create or link whatis to whatis.db. Further,
the whatis.db name seems to imply that the file is a db file, which
it certainly doesn't seem to be. catman also seems to be broken...

My current fix prepends the PATH for the relevent section to the TAILQ
default search path. It seems to work fine in all cases, except the

	man 5 termcap 3 termcap

-type thing. I gather multiple section numbers just aren't supported,
anyway.

>Unformatted: