bug-coreutils
[Top][All Lists]
Advanced

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

Re: Possible bug in sort -V


From: Pádraig Brady
Subject: Re: Possible bug in sort -V
Date: Wed, 16 Dec 2009 12:47:22 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0

On 16/12/09 01:18, john blair wrote:
cat a | /build/toolchain/lin32/coreutils-8.2/bin/sort -V
kernel-2.6.18-164.2.1.el5.x86_64.rpm
kernel-2.6.18-164.6.1.el5.x86_64.rpm
kernel-2.6.18-164.el5.x86_64.rpm

The result should be
kernel-2.6.18-164.el5.x86_64.rpm
kernel-2.6.18-164.2.1.el5.x86_64.rpm
kernel-2.6.18-164.6.1.el5.x86_64.rpm

Is it a bug is sort -V?

I would expect sort -V to work as you do,
though I'm a bit confused having looked at the code.
It states that it's using the debian version
compare algorithm (though the info doc says strverscmp() ?).
If you look at that spec:
http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version
it says that letters sort before anything (including digits as I read it).
However order() function doesn't do that:
http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/filevercmp.c;hb=HEAD
Also debian itself doesn't seem to match that?
dpkg --compare-versions kernel-2.6.18-164.el5.x86_64.rpm '>' \
kernel-2.6.18-164.2.1.el5.x86_64.rpm && echo "letters after numbers"

Changing order() to match the debian spec fixes your
case and coreutils/tests/misc/sort-version still passes.

--- a/lib/filevercmp.c  2009-12-14 22:47:15.000000000 +0000
+++ b/lib/filevercmp.c  2009-12-16 12:33:11.000000000 +0000
@@ -60,9 +60,7 @@
 static inline int
 order (unsigned char c)
 {
-  if (c_isdigit (c))
-    return 0;
-  else if (c_isalpha (c))
+  if (c_isalpha (c))
     return c;
   else if (c == '~')
     return -1;

I've only looked at this very quickly so that's not for applying.

EBUSY
Pádraig.




reply via email to

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