bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issue with ls -v / sort -V and strverscmp() usage


From: Kamil Dudka
Subject: Re: Issue with ls -v / sort -V and strverscmp() usage
Date: Wed, 17 Sep 2008 11:03:20 +0200
User-agent: KMail/1.9.9

On Sunday 07 September 2008 08:28:11 Jim Meyering wrote:
> IMHO, changing sort -V to produce more intuitively-correct results
> is the way to go.
>
> With ls -v, I'm willing to make the change as well, *assuming*
> no one produces a counterargument.
>
> The question is what ordering function to use.
> The more generally-useful the better.  i.e., I hope
> it can be compatible with both the rpm and deb version sorters.
I made an investigation of existing functions which sort version strings:
strverscmp - from glibc (now with its equivalent in gnulib)
rpmvercmp - from rpm
ververcmp - from dpkg

The main problem of all these functions is dealing with suffixes. So I 
modified them to drop the suffixes. So it is 6 implementations together (3 
original + 3 modified).

Then I ran a few series of tests with all implementations. I think the 
modified version of ververcmp (from dpkg) gives the best results - consider 
attached results of an example - results.tar.bz2

So I propose a new function filevercmp (attachment filevercmp.c) as the 
predicate function for new sort --version-sort.

In the attachment is also the whole "testing framework" which I used to 
compare these functions - strverscmp.tar.bz2 - follow the steps in README 
inside archive. It is developed a bit quickly but I hope it could be 
useful :-)


Kamil

Attachment: filevercmp.c
Description: Text Data

Attachment: results.tar.bz2
Description: application/tbz

Attachment: strverscmp.tar.bz2
Description: application/tbz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]