From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2797 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: strcasestr.c Date: Thu, 14 Feb 2013 10:23:49 -0500 Message-ID: <20130214152349.GA20323@brightrain.aerifal.cx> References: <201302141459.r1EExuU3024259@core.courtesan.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1360855445 10117 80.91.229.3 (14 Feb 2013 15:24:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Feb 2013 15:24:05 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2798-gllmg-musl=m.gmane.org@lists.openwall.com Thu Feb 14 16:24:26 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1U60fe-0006vX-Db for gllmg-musl@plane.gmane.org; Thu, 14 Feb 2013 16:24:22 +0100 Original-Received: (qmail 25704 invoked by uid 550); 14 Feb 2013 15:24:02 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 25692 invoked from network); 14 Feb 2013 15:24:02 -0000 Content-Disposition: inline In-Reply-To: <201302141459.r1EExuU3024259@core.courtesan.com> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2797 Archived-At: On Thu, Feb 14, 2013 at 09:59:56AM -0500, Todd C. Miller wrote: > When investigating using the musl strstr.c ofr OpenBSD I noticed > that musl only has a stub for strcasestr() that calls strstr(). I > was curious whether the twoway algorithm could be adapted to do a > case-insensitive search. It turned out to be pretty trivial to > just add calls to tolower() in the right places, making sure to > avoid sign extension. > > The changes are mostly mechanical. You might wish to inline > _strcasechr() though the compiler will probably do that for you. Unfortunately, as far as I can tell making this correct is nontrivial; your version only works for ascii, not the rest of ucs. I don't see any easy way to adapt 2way to the case where matching classes contain characters of different lengths... Rich