From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 15 18:27:33 2006 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 218BF16A420 for ; Wed, 15 Feb 2006 18:27:33 +0000 (GMT) (envelope-from jilles@stack.nl) Received: from mailhost.stack.nl (vaak.stack.nl [131.155.140.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id B6D0F43D55 for ; Wed, 15 Feb 2006 18:27:31 +0000 (GMT) (envelope-from jilles@stack.nl) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mailhost.stack.nl (Postfix) with ESMTP id F2ACBA300F; Wed, 15 Feb 2006 19:27:30 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id DCDDA228B3; Wed, 15 Feb 2006 19:27:30 +0100 (CET) Date: Wed, 15 Feb 2006 19:27:30 +0100 From: Jilles Tjoelker To: Dan Nelson Message-ID: <20060215182730.GB20355@stack.nl> References: <20060214212503.GE1107@galgenberg.net> <20060215080532.GB684@turion.vk2pj.dyndns.org> <20060215150237.GA1123@galgenberg.net> <20060215160524.GA70956@dan.emsphone.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060215160524.GA70956@dan.emsphone.com> X-Operating-System: FreeBSD 5.4-RELEASE i386 User-Agent: Mutt/1.5.11 Cc: hackers@freebsd.org Subject: Re: Naive implementation of strverscmp(3) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Feb 2006 18:27:33 -0000 On Wed, Feb 15, 2006 at 10:05:24AM -0600, Dan Nelson wrote: > Your function is simpler than the C implementation on that site, but > falls over when a run of numbers exceeds 2^31 (raise it to 2^64 if you > use strtoull, but that's as high as you can yet). That problem can be avoided fairly easily. First skip the leading zeroes on both sides, then strspn for digits; the longest run of digits is greater, otherwise strncmp it. -- Jilles Tjoelker