Subject: Re: bin/9742
To: None <perry@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,>
From: Daniel de Kok <danieldk@pobox.com>
List: netbsd-bugs
Date: 09/25/2006 22:00:06
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)?
 
 -- 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--