NetBSD Problem Report #9742

Received: (qmail 19873 invoked from network); 1 Apr 2000 00:28:58 -0000
Message-Id: <200003310508.RAA01410@zorkmid.mit.edu>
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
X-Send-Pr-Version: 3.95

>Number:         9742
>Category:       bin
>Synopsis:       whatis doesn't deal with '.' in manpage names
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    perry
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Apr 01 00:30:00 +0000 2000
>Closed-Date:    Wed Sep 27 06:49:20 +0000 2006
>Last-Modified:  Wed Sep 27 06:49:20 +0000 2006
>Originator:     John Hawkinson
>Release:        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:
Responsible-Changed-From-To: bin-bug-people->perry 
Responsible-Changed-By: perry 
Responsible-Changed-When: Sat Apr 5 13:46:57 PST 2003 
Responsible-Changed-Why:  
I'll have a look at this. 
From: Daniel de Kok <danieldk@pobox.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/9742
Date: Mon, 25 Sep 2006 23:57:59 +0200

 --jq0ap7NbKX2Kqbes
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 How about this fix based on OpenBSD whatis(1)?

 -- Daniel

 --jq0ap7NbKX2Kqbes
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="whatis-handle-periods.diff"

 Index: whatis.c
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/whatis/whatis.c,v
 retrieving revision 1.21
 diff -u -r1.21 whatis.c
 --- whatis.c	10 Apr 2006 14:39:06 -0000	1.21
 +++ whatis.c	25 Sep 2006 21:46:44 -0000
 @@ -205,10 +205,20 @@
  		for (; *bp && *bp != '[' && !isalnum((unsigned char)*bp); ++bp);
  		if (!*bp)
  			break;
 -		for (start = bp++;
 -		    *bp && (*bp == '_'  || isalnum((unsigned char)*bp)); ++bp);
 -		if (bp - start == len && !strncasecmp(start, str, len))
 +
 +		/* check for word match first */
 +		for (start = bp++; *bp && (*bp == '_' ||
 +			isalnum((unsigned char) *bp)); ++bp);
 +		if (bp - start == len && strncasecmp(start, str, len) == 0) {
  			return(1);
 +		} else if (*bp && *bp != ',') {
 +			/* check for full string match */
 +			for (bp = start; *bp && *bp != ',' && *bp != '(' &&
 +				!isspace((unsigned char) *bp); ++bp);
 +			if (bp - start == len &&
 +				strncasecmp(start, str, len) == 0)
 +				return(1);
 +		}
  	}
  	return(0);
  }

 --jq0ap7NbKX2Kqbes--

From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, perry@NetBSD.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org, jhawk@mit.edu
Cc: 
Subject: Re: bin/9742
Date: Mon, 25 Sep 2006 18:51:24 -0400

 On Sep 25, 10:00pm, danieldk@pobox.com (Daniel de Kok) wrote:
 -- Subject: Re: bin/9742

 | The following reply was made to PR bin/9742; it has been noted by GNATS.
 | 
 | From: Daniel de Kok <danieldk@pobox.com>
 | To: gnats-bugs@netbsd.org
 | Cc: 
 | Subject: Re: bin/9742
 | Date: Mon, 25 Sep 2006 23:57:59 +0200
 | 
 |  --jq0ap7NbKX2Kqbes
 |  Content-Type: text/plain; charset=us-ascii
 |  Content-Disposition: inline
 |  
 |  How about this fix based on OpenBSD whatis(1)?

 That looks fine to me. I would test it by checking the results before
 and after the fix before committing.

 christos

From: Daniel de Kok <daniel@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: PR/9742 CVS commit: src/usr.bin/whatis
Date: Tue, 26 Sep 2006 04:16:24 +0000 (UTC)

 Module Name:	src
 Committed By:	daniel
 Date:		Tue Sep 26 04:16:24 UTC 2006

 Modified Files:
 	src/usr.bin/whatis: whatis.c

 Log Message:
 PR/9742: whatis doesn't deal with '.' in manpage names (John Hawkinson)

 Use name matching code from OpenBSD (ack christos@).


 To generate a diff of this commit:
 cvs rdiff -r1.21 -r1.22 src/usr.bin/whatis/whatis.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: daniel@netbsd.org
State-Changed-When: Tue, 26 Sep 2006 04:21:55 +0000
State-Changed-Why:
whatis(1) should work properly with the patch that I just committed.


State-Changed-From-To: feedback->closed
State-Changed-By: daniel@netbsd.org
State-Changed-When: Wed, 27 Sep 2006 06:49:20 +0000
State-Changed-Why:
Fixed.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.