Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Feb 2006 19:27:30 +0100
From:      Jilles Tjoelker <jilles@stack.nl>
To:        Dan Nelson <dnelson@allantgroup.com>
Cc:        hackers@freebsd.org
Subject:   Re: Naive implementation of strverscmp(3)
Message-ID:  <20060215182730.GB20355@stack.nl>
In-Reply-To: <20060215160524.GA70956@dan.emsphone.com>
References:  <20060214212503.GE1107@galgenberg.net> <20060215080532.GB684@turion.vk2pj.dyndns.org> <20060215150237.GA1123@galgenberg.net> <20060215160524.GA70956@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060215182730.GB20355>