Naive implementation of strverscmp(3)

Jilles Tjoelker jilles at stack.nl
Wed Feb 15 10:27:33 PST 2006


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


More information about the freebsd-hackers mailing list