From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7125 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] conforming strverscmp() implementation Date: Tue, 3 Mar 2015 10:54:11 -0500 Message-ID: <20150303155411.GH23507@brightrain.aerifal.cx> References: <20150303104507.GA5094@zx-spectrum> 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 1425398075 3603 80.91.229.3 (3 Mar 2015 15:54:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 3 Mar 2015 15:54:35 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7138-gllmg-musl=m.gmane.org@lists.openwall.com Tue Mar 03 16:54:34 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YSp9R-0004hu-Nk for gllmg-musl@m.gmane.org; Tue, 03 Mar 2015 16:54:29 +0100 Original-Received: (qmail 18177 invoked by uid 550); 3 Mar 2015 15:54:28 -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 18139 invoked from network); 3 Mar 2015 15:54:23 -0000 Content-Disposition: inline In-Reply-To: <20150303104507.GA5094@zx-spectrum> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:7125 Archived-At: On Tue, Mar 03, 2015 at 12:45:07PM +0200, Sergey Dmitrouk wrote: > Hi, > > Attached is strverscmp() that should conform to what is described in > manual pages. It's not actually a diff as it would be harder to read > in this case. > > The idea is just as described in manuals (once you get what they mean): > > 1. Find point where strings differ as in current code, but keep track > of locations of last seen numbers. > 2. If numbers are both integers (that is they don't start with zero or > it's a single zero) compare as in current implementation. > 3. If only one of numbers is integer, the other one is smaller. > 4. Otherwise, number with longer leading sequence of zeroes is smaller. > 5. If leading zeroes match, compare characters following last zero in > both strings. > > I didn't see much comments in musl, so there is none in this file, but > can add some if requested. > > Implementation is admittedly more sophisticated than current version for > the reason that all simpler approaches I tried fail for at least one of > possible comparison cases. Thanks. This has been an open issue for a while. I haven't looked at your code in detail yet and at this point it will probably be something I do after the 1.1.7 release, and I'd like to allow some time for review. Have you run libc-test against it and checked that it fixes all the test failures there? I would guess it does since they're based on the man page examples but it would be good to double-check anyway if you haven't. Rich