Subject: bin/9742: whatis doesn't deal with '.' in manpage names
To: None <netbsd-bugs@netbsd.org>
From: John Darrow <John.P.Darrow@wheaton.edu>
List: netbsd-bugs
Date: 04/05/2000 14:58:20
Date: Fri, 31 Mar 2000 17:16:44 +1200 (NZST)
From: John Hawkinson <jhawk@mit.edu>
Reply-To: jhawk@mit.edu
To: gnats-bugs@gnats.netbsd.org
Subject: whatis doesn't deal with '.' in manpage names


>Number:         9742
>Category:       bin
>Synopsis:       whatis doesn't deal with '.' in manpage names
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 31 16:30:00 PST 2000
>Closed-Date:    
>Last-Modified:  
>Originator:     John Hawkinson
>Release:        NetBSD-1.4.2
>Organization:
	MIT
>Environment:

	
System: NetBSD zorkmid.mit.edu 1.4.2 NetBSD 1.4.2 (ZORKMID) #10: Mon Mar 27 12:33:31 CST 2000 jhawk@zorkmid.mit.edu:/usr/src/sys/arch/i386/compile/ZORKMID i386




>Description:
	whatis doesn't deal with a period inside of the name of a
man page; it fails to find the page.
>How-To-Repeat:

	
zorkmid% whatis mdoc.samples
mdoc.samples: not found


>Fix:
	 I was originalyl going to propose: treat '.' just like '_'
is special-cased. (Is this scalable?)




*** usr.bin/whatis/whatis.c	2000/03/31 05:04:18	1.1
--- usr.bin/whatis/whatis.c	2000/03/31 05:05:38	1.2
***************
*** 210,216 ****
  		if (!*bp)
  			break;
  		for (start = bp++;
! 		    *bp && (*bp == '_' || isdigit(*bp) || isalpha(*bp)); ++bp);
  		if (bp - start == len && !strncasecmp(start, str, len))
  			return(1);
  	}
--- 210,217 ----
  		if (!*bp)
  			break;
  		for (start = bp++;
! 		    *bp && (*bp == '_' || *bp == '.' || isdigit(*bp) ||
! 			isalpha(*bp)); ++bp);
  		if (bp - start == len && !strncasecmp(start, str, len))
  			return(1);
  	}


But this really not OK. It doesn't work with, say, dhclient:


zorkmid% apropos dhclient
dhclient (8) - Dynamic Host Configuration Protocol (DHCP)       Client
dhclient - Dynamic Host Configuration Protocol (DHCP) Client
dhclient-script (8) - DHCP client network configuration script
dhclient-script - DHCP client network configuration script
dhclient.conf (5) - DHCP client configuration file
dhclient.conf - DHCP client configuration file
dhclient.leases (5) - DHCP client lease database
dhclient.leases - DHCP client lease database
zorkmid% whatis dhclient
dhclient (8) - Dynamic Host Configuration Protocol (DHCP)       Client
dhclient - Dynamic Host Configuration Protocol (DHCP) Client
dhclient-script (8) - DHCP client network configuration script
dhclient-script - DHCP client network configuration script
zorkmid% whatis dhclient-script
dhclient-script: not found
zorkmid% whatis dhclient.leases
dhclient.leases (5) - DHCP client lease database
dhclient.leases - DHCP client lease database
zorkmid% 


And, of course, without the patch 'whatis dhclient' would have
shown dhclient.leases. I don't know if that's correct behavior or not.


It's really not clear to me what 'whatis' is trying to do here and why
it doesn't just use !isblank(). Further, the isdigit()||isalpha() references
could certainly be replaced with isalnum().


So my patch is probably not a good idea.


I think a doc update to whatis(1) is in order if anyone understands
what is really supposed to be going on here.


I presume part of the idea is that if you know you want to 'whatis',
say, 'named', you can see both 'named.conf' and 'named'. I don't
know how valuable a feature this is...
>Release-Note:
>Audit-Trail:
>Unformatted: