From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4911 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: src/string/wcsstr.c doesn't work Date: Fri, 18 Apr 2014 17:49:32 -0400 Message-ID: <20140418214932.GO26358@brightrain.aerifal.cx> References: 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 1397857795 8548 80.91.229.3 (18 Apr 2014 21:49:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Apr 2014 21:49:55 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4915-gllmg-musl=m.gmane.org@lists.openwall.com Fri Apr 18 23:49:49 2014 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 1WbGfK-0001mf-OB for gllmg-musl@plane.gmane.org; Fri, 18 Apr 2014 23:49:46 +0200 Original-Received: (qmail 1438 invoked by uid 550); 18 Apr 2014 21:49:45 -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 1426 invoked from network); 18 Apr 2014 21:49:45 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:4911 Archived-At: On Fri, Apr 18, 2014 at 06:41:46PM +0200, Yves Bastide wrote: > Hi, > > twoway_wcsstr doesn't (always) work with periodic needles. With the > attached example > > haystack = L"playing play play play always"; > needle = L"play play play"; > > mem0 = 9, ms = 3; thus, after a left-half mismatch on "playing", mem is 9 and > for (k = ms + 1; k>mem && n[k - 1] == h[k - 1]; k--); > terminates immediately. Thanks! Immediate termination of this loop is correct, but the subsequent conditional should have been treating it as success rather than failure. Fix committed. Rich