GNU bug report logs - #35939
version sort is incorrect with hyphen-minus

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Reported by: Vincent Lefevre <vincent@HIDDEN>; dated Tue, 28 May 2019 00:55:01 UTC; Maintainer for coreutils is bug-coreutils@HIDDEN.

Message received at 35939 <at> debbugs.gnu.org:


Received: (at 35939) by debbugs.gnu.org; 27 Jun 2019 10:25:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 27 06:25:08 2019
Received: from localhost ([127.0.0.1]:37463 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hgRaV-0006D2-Jt
	for submit <at> debbugs.gnu.org; Thu, 27 Jun 2019 06:25:08 -0400
Received: from chiark.greenend.org.uk ([212.13.197.229]:51317
 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ijackson@HIDDEN>) id 1hgRaT-0006Co-Jy
 for 35939 <at> debbugs.gnu.org; Thu, 27 Jun 2019 06:25:06 -0400
Received: by chiark.greenend.org.uk (Debian Exim 4.84_2 #1) with local
 (return-path ijackson@HIDDEN)
 id 1hgRaP-0001nn-6i; Thu, 27 Jun 2019 11:25:01 +0100
From: Ian Jackson <ijackson@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <23828.39293.83303.500219@HIDDEN>
Date: Thu, 27 Jun 2019 11:25:01 +0100
To: Vincent Lefevre <vincent@HIDDEN>
Subject: Re: bug#35939: version sort is incorrect with hyphen-minus
In-Reply-To: <20190627093640.GA415@HIDDEN>
References: <20190528005339.GB5676@HIDDEN>
 <20190626182526.GG22150@HIDDEN>
 <b60b2830-3b1f-bd7b-2687-49ae096670f8@HIDDEN>
 <23828.1151.256520.118973@HIDDEN>
 <23828.1452.399003.306989@HIDDEN>
 <cc603ddd-cb0e-796b-82b7-8b1eb7f78fee@HIDDEN>
 <20190627093640.GA415@HIDDEN>
X-Mailer: VM 8.2.0b under 24.4.1 (i586-pc-linux-gnu)
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 35939
Cc: Assaf Gordon <assafgordon@HIDDEN>, Paul Eggert <eggert@HIDDEN>,
 35939 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Vincent Lefevre writes ("Re: bug#35939: version sort is incorrect with hyphen-minus"):
> On 2019-06-26 18:40:50 -0700, Paul Eggert wrote:
> > Perhaps the coreutils manual could be improved to make this all clearer, and
> > perhaps it should refer to the Debian manual if it doesn't already.
> 
> In this case, there should be a new ordering option to provide
> true numeric sort with strings mixing non-negative integers and
> characters.

I think the Debian algorithm is such an algorithm, but it has a
wrinkle which you are not expecting.  Here is the specification:
  https://www.debian.org/doc/debian-policy/ch-controlfields.html#version

Note in particular
  | The lexical comparison is a comparison of ASCII values modified so
  | that all the letters sort earlier than all the non-letters and so
  | that a tilde sorts before anything, even the end of a part

So in the Debian algorithm, `-' sorts after `a'.  I specified this
rule.  I did it mainly because of versions like `1.0beta3', which is
is probably a prerelease of `1.0' and therefore earlier than `1.0.3'.
So `b' has to sort before `.' and my rule seemed the simplest one to
achieve that.  (The version comparison algorithm is a tradeoff between
complexity, and breadth of support for people's then-existing
practices.)  Nowadays Debian invariably writes `1.0~beta3' but when I
invented this scheme I did not include the (invaluable) `~' feature.

When this is extended to UTF-8, presumably the ordering should be an
ordering of unicode scalar values, with the rule about letters
interpreted as referring to anything which Unicode considers a letter.

If you want to test the Debian algorithm and have access to a copy of
dpkg, you can append -1 to both strings to be the "Debian revision",
and prepend "1:" to be the "epoch", and then the middle part should be
compared the same way as sort -V etc.

Vincent, what is your use case for a comparison algorithm which is
like the Debian one but which sorts letters after punctuation ?

Ian.

-- 
Ian Jackson <ijackson@HIDDEN>   These opinions are my own.

If I emailed you from an address @fyvzl.net or @evade.org.uk, that is
a private address which bypasses my fierce spamfilter.




Information forwarded to bug-coreutils@HIDDEN:
bug#35939; Package coreutils. Full text available.

Message received at 35939 <at> debbugs.gnu.org:


Received: (at 35939) by debbugs.gnu.org; 27 Jun 2019 09:36:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 27 05:36:46 2019
Received: from localhost ([127.0.0.1]:37428 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hgQpi-00050D-Dc
	for submit <at> debbugs.gnu.org; Thu, 27 Jun 2019 05:36:46 -0400
Received: from joooj.vinc17.net ([155.133.131.76]:59178)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <vincent@HIDDEN>) id 1hgQpf-000502-4p
 for 35939 <at> debbugs.gnu.org; Thu, 27 Jun 2019 05:36:44 -0400
Received: from smtp-zira.vinc17.net (128.119.75.86.rev.sfr.net [86.75.119.128])
 by joooj.vinc17.net (Postfix) with ESMTPSA id D29FC2A1;
 Thu, 27 Jun 2019 11:36:40 +0200 (CEST)
Received: by zira.vinc17.org (Postfix, from userid 1000)
 id 7D243C20ECE; Thu, 27 Jun 2019 11:36:40 +0200 (CEST)
Date: Thu, 27 Jun 2019 11:36:40 +0200
From: Vincent Lefevre <vincent@HIDDEN>
To: Paul Eggert <eggert@HIDDEN>
Subject: Re: bug#35939: version sort is incorrect with hyphen-minus
Message-ID: <20190627093640.GA415@HIDDEN>
References: <20190528005339.GB5676@HIDDEN>
 <20190626182526.GG22150@HIDDEN>
 <b60b2830-3b1f-bd7b-2687-49ae096670f8@HIDDEN>
 <23828.1151.256520.118973@HIDDEN>
 <23828.1452.399003.306989@HIDDEN>
 <cc603ddd-cb0e-796b-82b7-8b1eb7f78fee@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <cc603ddd-cb0e-796b-82b7-8b1eb7f78fee@HIDDEN>
X-Mailer-Info: https://www.vinc17.net/mutt/
User-Agent: Mutt/1.12.1+33 (6a74e24e) vl-117499 (2019-06-23)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 35939
Cc: 35939 <at> debbugs.gnu.org, Assaf Gordon <assafgordon@HIDDEN>,
 Ian Jackson <ijackson@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On 2019-06-26 18:40:50 -0700, Paul Eggert wrote:
> Perhaps the coreutils manual could be improved to make this all clearer, and
> perhaps it should refer to the Debian manual if it doesn't already.

In this case, there should be a new ordering option to provide
true numeric sort with strings mixing non-negative integers and
characters.

-- 
Vincent Lefèvre <vincent@HIDDEN> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Information forwarded to bug-coreutils@HIDDEN:
bug#35939; Package coreutils. Full text available.

Message received at 35939 <at> debbugs.gnu.org:


Received: (at 35939) by debbugs.gnu.org; 27 Jun 2019 01:41:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jun 26 21:41:01 2019
Received: from localhost ([127.0.0.1]:37228 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hgJPJ-0007zu-Fc
	for submit <at> debbugs.gnu.org; Wed, 26 Jun 2019 21:41:01 -0400
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:55460)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1hgJPH-0007zf-5e
 for 35939 <at> debbugs.gnu.org; Wed, 26 Jun 2019 21:41:00 -0400
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id ED75A16261D;
 Wed, 26 Jun 2019 18:40:51 -0700 (PDT)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id nwPyxH7o1r8f; Wed, 26 Jun 2019 18:40:51 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 38A3D162624;
 Wed, 26 Jun 2019 18:40:51 -0700 (PDT)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id oI3kmS42sw9G; Wed, 26 Jun 2019 18:40:51 -0700 (PDT)
Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 12A0716261D;
 Wed, 26 Jun 2019 18:40:51 -0700 (PDT)
Subject: Re: bug#35939: version sort is incorrect with hyphen-minus
To: Ian Jackson <ijackson@HIDDEN>, vincent@HIDDEN,
 Assaf Gordon <assafgordon@HIDDEN>, 35939 <at> debbugs.gnu.org
References: <20190528005339.GB5676@HIDDEN>
 <20190626182526.GG22150@HIDDEN>
 <b60b2830-3b1f-bd7b-2687-49ae096670f8@HIDDEN>
 <23828.1151.256520.118973@HIDDEN>
 <23828.1452.399003.306989@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Openpgp: preference=signencrypt
Autocrypt: addr=eggert@HIDDEN; prefer-encrypt=mutual; keydata=
 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
 uNcby4U=
Organization: UCLA Computer Science Department
Message-ID: <cc603ddd-cb0e-796b-82b7-8b1eb7f78fee@HIDDEN>
Date: Wed, 26 Jun 2019 18:40:50 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
 Thunderbird/60.7.2
MIME-Version: 1.0
In-Reply-To: <23828.1452.399003.306989@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 35939
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Thanks for looking into this. Sorry about my confusion between 
strverscmp and filevercmp. As this bug report appears to be about 
filevercmp, glibc is not involved; it's only Gnulib and the utilities 
using Gnulib's filevercmp module.

As I now understand it, Gnulib filevercmp is intended to be consistent 
with Debian's version comparison (this is documented in filevercmp.c), 
so GNU Bug#35939 is therefore based on a misunderstanding, as Gnulib 
filevercmp is implementing the Debian spec correctly for this test case.

Perhaps the coreutils manual could be improved to make this all clearer, 
and perhaps it should refer to the Debian manual if it doesn't already.





Information forwarded to bug-coreutils@HIDDEN:
bug#35939; Package coreutils. Full text available.

Message received at 35939 <at> debbugs.gnu.org:


Received: (at 35939) by debbugs.gnu.org; 26 Jun 2019 23:54:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jun 26 19:54:29 2019
Received: from localhost ([127.0.0.1]:37202 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hgHk9-0000rX-6i
	for submit <at> debbugs.gnu.org; Wed, 26 Jun 2019 19:54:29 -0400
Received: from chiark.greenend.org.uk ([212.13.197.229]:34701
 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ijackson@HIDDEN>) id 1hgHk6-0000rO-Tg
 for 35939 <at> debbugs.gnu.org; Wed, 26 Jun 2019 19:54:23 -0400
Received: by chiark.greenend.org.uk (Debian Exim 4.84_2 #1) with local
 (return-path ijackson@HIDDEN)
 id 1hgHk4-0003Vx-FF; Thu, 27 Jun 2019 00:54:20 +0100
From: Ian Jackson <ijackson@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <23828.1452.399003.306989@HIDDEN>
Date: Thu, 27 Jun 2019 00:54:20 +0100
To: Paul Eggert <eggert@HIDDEN>, vincent@HIDDEN,
 Assaf Gordon <assafgordon@HIDDEN>, 35939 <at> debbugs.gnu.org
Subject: Re: bug#35939: version sort is incorrect with hyphen-minus
In-Reply-To: <23828.1151.256520.118973@HIDDEN>
References: <20190528005339.GB5676@HIDDEN>
 <20190626182526.GG22150@HIDDEN>
 <b60b2830-3b1f-bd7b-2687-49ae096670f8@HIDDEN>
 <23828.1151.256520.118973@HIDDEN>
X-Mailer: VM 8.2.0b under 24.4.1 (i586-pc-linux-gnu)
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 35939
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Ian Jackson writes ("Re: bug#35939: version sort is incorrect with hyphen-minus"):
> Paul Eggert writes ("Re: bug#35939: version sort is incorrect with hyphen-minus"):
> > GNU sort uses the same algorithm as glibc strverscmp, and this algorithm has 
> > changed only once since strverscmp was added to glibc in 1997. The change was 
> > made in 2009, to fix this bug:
> > 
> > https://sourceware.org/bugzilla/show_bug.cgi?id=9913
> > 
> > Has the Debian version-comparison algorithm changed since 1997? If so, could you 
> > give details about the changes to the Debian algorithm? Perhaps glibc should be 
> > changed to stay consistent with Debian.
> 
> Debian introduced a special (and very useful) meaning for ~, many
> years ago now.
> 
> I checked the Debian policy manual and according to its upgrading
> checklist this change was made in 2007.

I have just checked the manpage I have here for strverscmp and it is
far from clear to me that the algorithm described there, and the dpkg
algorithm, produce the same answers.  (Even disregarding ~, and the
fact that the specification of the dpkg algorithm is defined only over
a subset of possible strings even though the unique extension to UTF-8
strings is fairly obvious.)

-- 
Ian Jackson <ijackson@HIDDEN>   These opinions are my own.

If I emailed you from an address @fyvzl.net or @evade.org.uk, that is
a private address which bypasses my fierce spamfilter.




Information forwarded to bug-coreutils@HIDDEN:
bug#35939; Package coreutils. Full text available.

Message received at 35939 <at> debbugs.gnu.org:


Received: (at 35939) by debbugs.gnu.org; 26 Jun 2019 23:49:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jun 26 19:49:26 2019
Received: from localhost ([127.0.0.1]:37188 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hgHfJ-0000hl-Uz
	for submit <at> debbugs.gnu.org; Wed, 26 Jun 2019 19:49:26 -0400
Received: from chiark.greenend.org.uk ([212.13.197.229]:34248
 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ijackson@HIDDEN>) id 1hgHfH-0000hb-5E
 for 35939 <at> debbugs.gnu.org; Wed, 26 Jun 2019 19:49:24 -0400
Received: by chiark.greenend.org.uk (Debian Exim 4.84_2 #1) with local
 (return-path ijackson@HIDDEN)
 id 1hgHfD-0000OW-GL; Thu, 27 Jun 2019 00:49:19 +0100
From: Ian Jackson <ijackson@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <23828.1151.256520.118973@HIDDEN>
Date: Thu, 27 Jun 2019 00:49:19 +0100
To: Paul Eggert <eggert@HIDDEN>
Subject: Re: bug#35939: version sort is incorrect with hyphen-minus
In-Reply-To: <b60b2830-3b1f-bd7b-2687-49ae096670f8@HIDDEN>
References: <20190528005339.GB5676@HIDDEN>
 <20190626182526.GG22150@HIDDEN>
 <b60b2830-3b1f-bd7b-2687-49ae096670f8@HIDDEN>
X-Mailer: VM 8.2.0b under 24.4.1 (i586-pc-linux-gnu)
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 35939
Cc: 35939 <at> debbugs.gnu.org, Assaf Gordon <assafgordon@HIDDEN>,
 vincent@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Paul Eggert writes ("Re: bug#35939: version sort is incorrect with hyphen-minus"):
> GNU sort uses the same algorithm as glibc strverscmp, and this algorithm has 
> changed only once since strverscmp was added to glibc in 1997. The change was 
> made in 2009, to fix this bug:
> 
> https://sourceware.org/bugzilla/show_bug.cgi?id=9913
> 
> Has the Debian version-comparison algorithm changed since 1997? If so, could you 
> give details about the changes to the Debian algorithm? Perhaps glibc should be 
> changed to stay consistent with Debian.

Debian introduced a special (and very useful) meaning for ~, many
years ago now.

I checked the Debian policy manual and according to its upgrading
checklist this change was made in 2007.

Ian.

-- 
Ian Jackson <ijackson@HIDDEN>   These opinions are my own.

If I emailed you from an address @fyvzl.net or @evade.org.uk, that is
a private address which bypasses my fierce spamfilter.




Information forwarded to bug-coreutils@HIDDEN:
bug#35939; Package coreutils. Full text available.

Message received at 35939 <at> debbugs.gnu.org:


Received: (at 35939) by debbugs.gnu.org; 26 Jun 2019 23:01:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jun 26 19:01:39 2019
Received: from localhost ([127.0.0.1]:37166 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hgGv4-0007oO-W8
	for submit <at> debbugs.gnu.org; Wed, 26 Jun 2019 19:01:39 -0400
Received: from mail-pl1-f179.google.com ([209.85.214.179]:46316)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <assafgordon@HIDDEN>) id 1hgGv4-0007oB-0v
 for 35939 <at> debbugs.gnu.org; Wed, 26 Jun 2019 19:01:38 -0400
Received: by mail-pl1-f179.google.com with SMTP id e5so131122pls.13
 for <35939 <at> debbugs.gnu.org>; Wed, 26 Jun 2019 16:01:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=date:from:to:cc:subject:message-id:references:mime-version
 :content-disposition:in-reply-to:user-agent;
 bh=zXs1+lPbFR385lsai0s6OumuUYA0xx4pswDDxH05Ue8=;
 b=L9JjWcJ7MfTGyMpobdGVg/FxWypxmPm/DI3js4+/GXuw43CH3SQLq002munkDXk65N
 sMT+egonKBIPk1to0CJ3efr9MPy7VrBYZn+dzeo9ZbVDzRYMu7uks3wSFdTMFyocwj7v
 3oAqqaAljZ1DSDNFJHljEg67LAFrdu9aa4bMcLFZc6juCCkkXdiZXe5M+WvLG9kIgc2U
 6rdqOcpMSclV5MnCNX0gfSo4NvGRzJAUB3PycQE/MlgSttTIvrbj94/aodlmwwkh//ul
 RHusliaJmlMKeuDVi6PwDqC5hzMfFvJtP4Wd3u57tofMfV4LzKnzK/NTaCVGIqDkIpKg
 SHqQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:date:from:to:cc:subject:message-id:references
 :mime-version:content-disposition:in-reply-to:user-agent;
 bh=zXs1+lPbFR385lsai0s6OumuUYA0xx4pswDDxH05Ue8=;
 b=Q7HCG2YEm9MMUA2kx3WdiEJYPS/uzn3Sc16LvikHOg6EuEmrXWHahPtnr/BfIqB1vD
 4AlXWE2c7cMw9UjBLRcqAoss78hFTZJNTlx6HL1czX8ciQheTE6mDwnQdsZDMj4Y3D1V
 6fjCPOYq0/ggnA8ZPeqZlUe9r80WlS1haFipffU73ts5eJNg6w190iOQKx3hwhcKwhnJ
 j1rwHw2fiQMSMl7bAEFccLUiiq2MPKcG2eNXDGTNGuHhWNAt67A8iH//RMplsY45E0kv
 OZv4M0w5uePQidTa5nLRnBVnxrPFlRupHHJXxY1gXnBemWJcpMj7Lge0WY1EGjJ9G5rK
 53Ew==
X-Gm-Message-State: APjAAAVsoc/ehGH/lbvH3u7dBLDaTOXrNx7BIIP03P/6bxPDaSDBlK9P
 4L3AFSC8HFeeTgQBR5pApqg=
X-Google-Smtp-Source: APXvYqzpFj0GWky7u8vPmitMjw3Uc7B/qZGQuNvPk4R+shge5mpY7hLpcDC/cWoKTIDLbLKTEzL9JA==
X-Received: by 2002:a17:902:8ec7:: with SMTP id
 x7mr649175plo.224.1561590091930; 
 Wed, 26 Jun 2019 16:01:31 -0700 (PDT)
Received: from tomato (moose.housegordon.com. [184.68.105.38])
 by smtp.gmail.com with ESMTPSA id r9sm171732pgv.24.2019.06.26.16.01.29
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Wed, 26 Jun 2019 16:01:30 -0700 (PDT)
Received: by tomato (Postfix, from userid 1000)
 id 2C83A680A50; Wed, 26 Jun 2019 17:01:29 -0600 (MDT)
Date: Wed, 26 Jun 2019 17:01:29 -0600
From: Assaf Gordon <assafgordon@HIDDEN>
To: Paul Eggert <eggert@HIDDEN>
Subject: Re: bug#35939: version sort is incorrect with hyphen-minus
Message-ID: <20190626230129.GH22150@HIDDEN>
References: <20190528005339.GB5676@HIDDEN>
 <20190626182526.GG22150@HIDDEN>
 <b60b2830-3b1f-bd7b-2687-49ae096670f8@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <b60b2830-3b1f-bd7b-2687-49ae096670f8@HIDDEN>
User-Agent: Mutt/1.11.4 (2019-03-13)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 35939
Cc: 35939 <at> debbugs.gnu.org, vincent@HIDDEN,
 Ian Jackson <ijackson@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello Paul,

On Wed, Jun 26, 2019 at 12:57:14PM -0700, Paul Eggert wrote:
> GNU sort uses the same algorithm as glibc strverscmp,

I think that both sort and ls use 'filevercmp' - a simplified version
that does not support locales (and doesn't fail).

The change (from 'strvercmp') was made in:

  commit e505736f8211a608b00dfe75fb186a5211e1a183
  Author: Kamil Dudka <kdudka@HIDDEN>
  Date:   Fri Oct 3 11:03:40 2008 +0200
  ls and sort: use filevercmp instead of strverscmp
  https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=e505736f8211a608b00dfe75fb186a5211e1a183

> Has the Debian version-comparison algorithm changed since 1997? If so, could
> you give details about the changes to the Debian algorithm?

I don't think the algorithm changed in Debian,
and also in gnulib there are only a handful of relevant commits, all 10
years old:

  9121662f1 2008-10-03 filevercmp: new module
  0443c2f39 2009-03-05 filevercmp: Move hidden files up in ordering.
  1721cf06d 2009-03-24 filevercmp: handle simple~ and numbered.~3~ backup suffixes
  4fd008794 2009-04-09 filevercmp: fix regression
  cc96df30d 2009-04-09 filevercmp: correct today's change

I think (also based on Ian's confirmation) that this discrepancy was
from the beginning.

I now notice that there's an additional difference: coreutils/gnulib has
special handling for extension, hidden files and backup files.

As Ian wrote, a documentation improvement is probably the best fix.
I'll try to come up with a suggested change.

-assaf

P.S.

For completion, here are few other threads with details/explanations
about 'version-sort':
https://bugs.gnu.org/18168
https://bugs.gnu.org/22275
https://bugs.gnu.org/22455
https://bugs.gnu.org/33786




Information forwarded to bug-coreutils@HIDDEN:
bug#35939; Package coreutils. Full text available.

Message received at 35939 <at> debbugs.gnu.org:


Received: (at 35939) by debbugs.gnu.org; 26 Jun 2019 21:25:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jun 26 17:25:51 2019
Received: from localhost ([127.0.0.1]:37109 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hgFQM-0002xy-PL
	for submit <at> debbugs.gnu.org; Wed, 26 Jun 2019 17:25:50 -0400
Received: from joooj.vinc17.net ([155.133.131.76]:58648)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <vincent@HIDDEN>) id 1hgFQJ-0002xn-4H
 for 35939 <at> debbugs.gnu.org; Wed, 26 Jun 2019 17:25:49 -0400
Received: from smtp-zira.vinc17.net
 (2a02-8429-80cd-3101-328d-99ff-fe25-ad3f.rev.sfr.net
 [IPv6:2a02:8429:80cd:3101:328d:99ff:fe25:ad3f])
 by joooj.vinc17.net (Postfix) with ESMTPSA id 35BD71254;
 Wed, 26 Jun 2019 23:25:44 +0200 (CEST)
Received: by zira.vinc17.org (Postfix, from userid 1000)
 id 0BB2AC219F1; Wed, 26 Jun 2019 23:25:44 +0200 (CEST)
Date: Wed, 26 Jun 2019 23:25:44 +0200
From: Vincent Lefevre <vincent@HIDDEN>
To: Paul Eggert <eggert@HIDDEN>
Subject: Re: bug#35939: version sort is incorrect with hyphen-minus
Message-ID: <20190626212544.GO7775@HIDDEN>
References: <20190528005339.GB5676@HIDDEN>
 <20190626182526.GG22150@HIDDEN>
 <b60b2830-3b1f-bd7b-2687-49ae096670f8@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <b60b2830-3b1f-bd7b-2687-49ae096670f8@HIDDEN>
X-Mailer-Info: https://www.vinc17.net/mutt/
User-Agent: Mutt/1.12.1+33 (6a74e24e) vl-117499 (2019-06-23)
X-Spam-Score: 0.1 (/)
X-Debbugs-Envelope-To: 35939
Cc: 35939 <at> debbugs.gnu.org, Assaf Gordon <assafgordon@HIDDEN>,
 Ian Jackson <ijackson@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.9 (/)

On 2019-06-26 12:57:14 -0700, Paul Eggert wrote:
> GNU sort uses the same algorithm as glibc strverscmp, and this algorithm has
> changed only once since strverscmp was added to glibc in 1997. The change
> was made in 2009, to fix this bug:
> 
> https://sourceware.org/bugzilla/show_bug.cgi?id=9913

Except that this bug report is wrong. But I've checked that
both "ls -v" and "sort -V" give the expected ordering on the
given example in this bug report:

zira% ls -1v                
B007502280067.gbp.corp.com
B007502357019.GBP.CORP.COM
B0075022800016.gbp.corp.com

zira% printf "%s\n" * | sort -V
B007502280067.gbp.corp.com
B007502357019.GBP.CORP.COM
B0075022800016.gbp.corp.com

-- 
Vincent Lefèvre <vincent@HIDDEN> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Information forwarded to bug-coreutils@HIDDEN:
bug#35939; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 26 Jun 2019 20:15:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jun 26 16:15:14 2019
Received: from localhost ([127.0.0.1]:37083 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hgEK1-0000zb-KL
	for submit <at> debbugs.gnu.org; Wed, 26 Jun 2019 16:15:13 -0400
Received: from lists.gnu.org ([209.51.188.17]:53361)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <vincent@HIDDEN>) id 1hgEK0-0000zS-3K
 for submit <at> debbugs.gnu.org; Wed, 26 Jun 2019 16:15:12 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:38020)
 by lists.gnu.org with esmtp (Exim 4.86_2)
 (envelope-from <vincent@HIDDEN>) id 1hgEJy-000708-S2
 for bug-coreutils@HIDDEN; Wed, 26 Jun 2019 16:15:12 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <vincent@HIDDEN>) id 1hgEJx-0002c0-PL
 for bug-coreutils@HIDDEN; Wed, 26 Jun 2019 16:15:10 -0400
Received: from joooj.vinc17.net ([155.133.131.76]:51800)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <vincent@HIDDEN>) id 1hgEJx-0002Pt-Hp
 for bug-coreutils@HIDDEN; Wed, 26 Jun 2019 16:15:09 -0400
Received: from smtp-zira.vinc17.net (unknown [109.190.253.11])
 by joooj.vinc17.net (Postfix) with ESMTPSA id 6DFEC2DC;
 Wed, 26 Jun 2019 22:14:56 +0200 (CEST)
Received: by zira.vinc17.org (Postfix, from userid 1000)
 id 5A9E3C20088; Wed, 26 Jun 2019 22:14:54 +0200 (CEST)
Date: Wed, 26 Jun 2019 22:14:54 +0200
From: Vincent Lefevre <vincent@HIDDEN>
To: Assaf Gordon <assafgordon@HIDDEN>
Subject: Re: bug#35939: version sort is incorrect with hyphen-minus
Message-ID: <20190626201454.GN7775@HIDDEN>
Mail-Followup-To: Vincent Lefevre <vincent@HIDDEN>,
 Assaf Gordon <assafgordon@HIDDEN>, bug-coreutils@HIDDEN,
 Ian Jackson <ijackson@HIDDEN>
References: <20190528005339.GB5676@HIDDEN>
 <20190626182526.GG22150@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
In-Reply-To: <20190626182526.GG22150@HIDDEN>
X-Mailer-Info: https://www.vinc17.net/mutt/
User-Agent: Mutt/1.12.1+33 (6a74e24e) vl-117499 (2019-06-23)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 155.133.131.76
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
Cc: bug-coreutils@HIDDEN, Ian Jackson <ijackson@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

On 2019-06-26 12:25:26 -0600, Assaf Gordon wrote:
> "ls -v" and "sort -V" (coreutils' version sort) behaves differently tha=
n
> other implementations in regards to minus character:
>=20
>     $ printf "%s\n" abb ab-cd | sort -V
>     abb
>     ab-cd
>=20
>     $ v1=3D"abb"
>     $ v2=3D"ab-cd"
>     $ dpkg --compare-versions "$v1" lt "$v2" && printf "$v1\n$v2\n" || =
printf "$v2\n$v1\n"
>     ab-cd
>     abb
>=20
> If I understand correctly,
> The reason is that in Debian's version comparison algorithm [1], the mi=
nus
> character has a special meaning: it separates the "upstream version"
> part from the "debian revision" part.

Note that I'm not using "ls -v" to sort version numbers, just
filenames (which can contain integers in decimal notation).

--=20
Vincent Lef=E8vre <vincent@HIDDEN> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Information forwarded to bug-coreutils@HIDDEN:
bug#35939; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 26 Jun 2019 20:09:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jun 26 16:09:34 2019
Received: from localhost ([127.0.0.1]:37078 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hgEEX-0000od-SU
	for submit <at> debbugs.gnu.org; Wed, 26 Jun 2019 16:09:34 -0400
Received: from lists.gnu.org ([209.51.188.17]:56109)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ijackson@HIDDEN>) id 1hgEEW-0000oW-CR
 for submit <at> debbugs.gnu.org; Wed, 26 Jun 2019 16:09:33 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:36754)
 by lists.gnu.org with esmtp (Exim 4.86_2)
 (envelope-from <ijackson@HIDDEN>) id 1hgEET-0004ra-QD
 for bug-coreutils@HIDDEN; Wed, 26 Jun 2019 16:09:32 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ijackson@HIDDEN>) id 1hgEEQ-0006XP-Tp
 for bug-coreutils@HIDDEN; Wed, 26 Jun 2019 16:09:29 -0400
Received: from v6.chiark.greenend.org.uk ([2001:ba8:1e3::]:43231
 helo=chiark.greenend.org.uk)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <ijackson@HIDDEN>)
 id 1hgEEQ-0006OX-NX
 for bug-coreutils@HIDDEN; Wed, 26 Jun 2019 16:09:26 -0400
Received: by chiark.greenend.org.uk (Debian Exim 4.84_2 #1) with local
 (return-path ijackson@HIDDEN)
 id 1hgEEF-0003ej-Ja; Wed, 26 Jun 2019 21:09:16 +0100
From: Ian Jackson <ijackson@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <23827.53482.505900.957536@HIDDEN>
Date: Wed, 26 Jun 2019 21:09:14 +0100
To: Assaf Gordon <assafgordon@HIDDEN>
Subject: Re: bug#35939: version sort is incorrect with hyphen-minus
In-Reply-To: <20190626182526.GG22150@HIDDEN>
References: <20190528005339.GB5676@HIDDEN>
 <20190626182526.GG22150@HIDDEN>
X-Mailer: VM 8.2.0b under 24.4.1 (i586-pc-linux-gnu)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:ba8:1e3::
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
Cc: bug-coreutils@HIDDEN, Vincent Lefevre <vincent@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Assaf Gordon writes ("Re: bug#35939: version sort is incorrect with hyphen-minus"):
> Thanks for the report and the clear details.

Hi.  I haven't read the original report, but everything you say about
the behaviour of GNU coreutils and dpkg sounds correct.

This is perhaps an unfortunate wrinkle but I think it is right of
coreutils to use the "upstream part" of the dpkg algorithm.

> I hope this helps explain the differences (I also hope this explanation is
> correct, and I invite others to chime in).

I wonder if this could go in some manual somewhere.

Regards,
Ian.

-- 
Ian Jackson <ijackson@HIDDEN>   These opinions are my own.

If I emailed you from an address @fyvzl.net or @evade.org.uk, that is
a private address which bypasses my fierce spamfilter.




Information forwarded to bug-coreutils@HIDDEN:
bug#35939; Package coreutils. Full text available.

Message received at 35939 <at> debbugs.gnu.org:


Received: (at 35939) by debbugs.gnu.org; 26 Jun 2019 19:57:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jun 26 15:57:25 2019
Received: from localhost ([127.0.0.1]:37074 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hgE2m-0000Qw-JI
	for submit <at> debbugs.gnu.org; Wed, 26 Jun 2019 15:57:24 -0400
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:42784)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1hgE2j-0000QY-US
 for 35939 <at> debbugs.gnu.org; Wed, 26 Jun 2019 15:57:23 -0400
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id E25E0161C47;
 Wed, 26 Jun 2019 12:57:15 -0700 (PDT)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id lLZiHk5eWOJl; Wed, 26 Jun 2019 12:57:15 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2713B161DBD;
 Wed, 26 Jun 2019 12:57:15 -0700 (PDT)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id y9TUQOdeOU-Q; Wed, 26 Jun 2019 12:57:15 -0700 (PDT)
Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com
 [23.242.74.103])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id ECD80161C47;
 Wed, 26 Jun 2019 12:57:14 -0700 (PDT)
Subject: Re: bug#35939: version sort is incorrect with hyphen-minus
To: vincent@HIDDEN
References: <20190528005339.GB5676@HIDDEN>
 <20190626182526.GG22150@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
Message-ID: <b60b2830-3b1f-bd7b-2687-49ae096670f8@HIDDEN>
Date: Wed, 26 Jun 2019 12:57:14 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
 Thunderbird/60.7.1
MIME-Version: 1.0
In-Reply-To: <20190626182526.GG22150@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 35939
Cc: 35939 <at> debbugs.gnu.org, Assaf Gordon <assafgordon@HIDDEN>,
 Ian Jackson <ijackson@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

GNU sort uses the same algorithm as glibc strverscmp, and this algorithm has 
changed only once since strverscmp was added to glibc in 1997. The change was 
made in 2009, to fix this bug:

https://sourceware.org/bugzilla/show_bug.cgi?id=9913

Has the Debian version-comparison algorithm changed since 1997? If so, could you 
give details about the changes to the Debian algorithm? Perhaps glibc should be 
changed to stay consistent with Debian.




Information forwarded to bug-coreutils@HIDDEN:
bug#35939; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 26 Jun 2019 18:25:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jun 26 14:25:39 2019
Received: from localhost ([127.0.0.1]:37039 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hgCbz-0005L5-8f
	for submit <at> debbugs.gnu.org; Wed, 26 Jun 2019 14:25:39 -0400
Received: from lists.gnu.org ([209.51.188.17]:36361)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <assafgordon@HIDDEN>) id 1hgCbx-0005Kw-2I
 for submit <at> debbugs.gnu.org; Wed, 26 Jun 2019 14:25:37 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:43254)
 by lists.gnu.org with esmtp (Exim 4.86_2)
 (envelope-from <assafgordon@HIDDEN>) id 1hgCbv-0008In-NT
 for bug-coreutils@HIDDEN; Wed, 26 Jun 2019 14:25:36 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <assafgordon@HIDDEN>) id 1hgCbu-0005JS-F5
 for bug-coreutils@HIDDEN; Wed, 26 Jun 2019 14:25:35 -0400
Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:35126)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <assafgordon@HIDDEN>)
 id 1hgCbu-0005GF-7u
 for bug-coreutils@HIDDEN; Wed, 26 Jun 2019 14:25:34 -0400
Received: by mail-pg1-x52b.google.com with SMTP id s27so1603075pgl.2
 for <bug-coreutils@HIDDEN>; Wed, 26 Jun 2019 11:25:29 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=date:from:to:cc:subject:message-id:references:mime-version
 :content-disposition:in-reply-to:user-agent;
 bh=r5st6THGkOBZANRteXcrD760H/AUkdQS+IvSNBi6Jq8=;
 b=EgNWPSB9VAtCX8EpYnhi2WoMOGR4o6jViFgrpCKybFAZTpA7dcRozPjejVQkRpORIC
 we+tykGxqIHfKyh/xUF/OP2XJQwxt31JSwfoHbZtBJ5r1cqZrSAugFMhLESGqPWXqxQB
 bJHgkdV6iBNONx4SoxZmPlBwK32gAOBAjcQy/45cPSQjPydpvOl6qJbb0XKdVuQqhvy0
 VHx+DD7L1HQYZ/BFkbOmFc43mevAvTjkKRu8owCbbQFwNhhlBqepHAhM6yMqwjk5yH0w
 4pwqPLyFLIZxWwrsGvr0/XNc4I3g27I4FibkLtVC0RWCCheldAl6mb3o90fyBh8CogDz
 SrGg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:date:from:to:cc:subject:message-id:references
 :mime-version:content-disposition:in-reply-to:user-agent;
 bh=r5st6THGkOBZANRteXcrD760H/AUkdQS+IvSNBi6Jq8=;
 b=B8tB0cuR7BMXMM5C6HvNNKQA3uSvTDuN4+EX5B9+ZCE4yYFfPVva3p4eQSdyDhhP51
 QTFggqNwO5WXiieXuSdc6oMbsR2E4/B00cvGgeTvc7+SpVO9wKmR3RvcoL+qDL4se789
 2uLRC46EL1Lz5IEpMjBPehfhSuQmZmW03xuPll+Q/CX/h2dWoZYIr4zNdkbUDrACC+NW
 oqPzWilaSkj7GrIgexjEPRD9TJ1eoyZktpos9ok6g9CgGS0Vs8cU2lRUMtBoFoaxFanf
 GY7BQEJFQC5tow/BHekR78hOanbLkqzUcpvbUMUzZCwVw+kQjwJFL3QTpmL2EUGM3Tn2
 lxkw==
X-Gm-Message-State: APjAAAXchJJaa5JViklyr0R2hPnk+8oN3X6PI0XFAZ9X8V9fkmYuCLaF
 FUV3zlmLXwvzE0bjgpeP3/Q=
X-Google-Smtp-Source: APXvYqxM4r5eh0A5+f4rqb0Snq4vy12SkabrlIpquHkWuwHAA4HYX/5NMqGUcbxVKTrcK3sPVrrYCw==
X-Received: by 2002:a63:d24f:: with SMTP id t15mr3860126pgi.301.1561573528572; 
 Wed, 26 Jun 2019 11:25:28 -0700 (PDT)
Received: from tomato (moose.housegordon.com. [184.68.105.38])
 by smtp.gmail.com with ESMTPSA id k6sm21033906pfi.12.2019.06.26.11.25.27
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Wed, 26 Jun 2019 11:25:27 -0700 (PDT)
Received: by tomato (Postfix, from userid 1000)
 id 9182F680A50; Wed, 26 Jun 2019 12:25:26 -0600 (MDT)
Date: Wed, 26 Jun 2019 12:25:26 -0600
From: Assaf Gordon <assafgordon@HIDDEN>
To: Vincent Lefevre <vincent@HIDDEN>, bug-coreutils@HIDDEN
Subject: Re: bug#35939: version sort is incorrect with hyphen-minus
Message-ID: <20190626182526.GG22150@HIDDEN>
References: <20190528005339.GB5676@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20190528005339.GB5676@HIDDEN>
User-Agent: Mutt/1.11.4 (2019-03-13)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2607:f8b0:4864:20::52b
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
Cc: Ian Jackson <ijackson@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

(Adding Ian Jackson for dpkg/debian-version details)

Hello,

On Tue, May 28, 2019 at 02:53:39AM +0200, Vincent Lefevre wrote:
> With GNU coreutils 8.30 under Debian/unstable, I get:
> 
> $ LC_ALL=C ls
> ab-cd  abb  abe
> $ LC_ALL=C ls -v
> abb  abe  ab-cd
> 
> The hyphen-minus character should still be regarded as being less
> than the letters (there are no digits, so both are expected to be
> equivalent). The GNU coreutils manual says:
> 
[...]

Thanks for the report and the clear details.

To summarize,
"ls -v" and "sort -V" (coreutils' version sort) behaves differently than
other implementations in regards to minus character:

    $ printf "%s\n" abb ab-cd | sort -V
    abb
    ab-cd

    $ v1="abb"
    $ v2="ab-cd"
    $ dpkg --compare-versions "$v1" lt "$v2" && printf "$v1\n$v2\n" || printf "$v2\n$v1\n"
    ab-cd
    abb

If I understand correctly,
The reason is that in Debian's version comparison algorithm [1], the minus
character has a special meaning: it separates the "upstream version"
part from the "debian revision" part.

In Debian's implementation [2], a version string is first split into three
parts (epoch, upstream version, debian revision) using ":" for epoch
delimiter and "-" for revision delimiter. Only then the three parts are
compared, separately [3].

[1] https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
[2] https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/lib/dpkg/parsehelp.c#n191
[3] https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/lib/dpkg/version.c#n140

On ther other hand, coreutils' implementation (from gnulib [4]) does not
break version string into three parts - it treats the entire string as a
single "upstream version" part.
The rules for sorting the "upstream version" string say:

  "... The lexical comparison is a comparison of ASCII values modified so
  that all the letters sort earlier than all the non-letters and so that a
  tilde sorts before anything" (from [1])

[4] https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/filevercmp.c

Therefore, dpkg first seprates "ab" from "cd", then compares "ab" to
"abb" - and 'ab' comes first;
Coreutils compare "ab-cd" to "abb" (or technically, just "ab-" to
"abb"), and because "letters sort earlier than all non-letters", "abb"
comes first.

I hope this helps explain the differences (I also hope this explanation is
correct, and I invite others to chime in).


regards,
 - assaf





Information forwarded to bug-coreutils@HIDDEN:
bug#35939; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 28 May 2019 00:54:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 27 20:54:03 2019
Received: from localhost ([127.0.0.1]:54574 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hVQNO-0001EP-N8
	for submit <at> debbugs.gnu.org; Mon, 27 May 2019 20:54:02 -0400
Received: from eggs.gnu.org ([209.51.188.92]:57791)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <vincent@HIDDEN>) id 1hVQNK-0001Dt-U8
 for submit <at> debbugs.gnu.org; Mon, 27 May 2019 20:53:59 -0400
Received: from lists.gnu.org ([209.51.188.17]:53392)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <vincent@HIDDEN>) id 1hVQNF-0000Ez-ON
 for submit <at> debbugs.gnu.org; Mon, 27 May 2019 20:53:53 -0400
Received: from eggs.gnu.org ([209.51.188.92]:43934)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <vincent@HIDDEN>) id 1hVQNE-0000W8-Ln
 for bug-coreutils@HIDDEN; Mon, 27 May 2019 20:53:53 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <vincent@HIDDEN>) id 1hVQND-0000Do-5f
 for bug-coreutils@HIDDEN; Mon, 27 May 2019 20:53:52 -0400
Received: from joooj.vinc17.net ([2001:4b99:1:3:216:3eff:fe20:ac98]:46584)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <vincent@HIDDEN>) id 1hVQND-00009I-07
 for bug-coreutils@HIDDEN; Mon, 27 May 2019 20:53:51 -0400
Received: from smtp-zira.vinc17.net
 (2a02-8429-80cd-3101-328d-99ff-fe25-ad3f.rev.sfr.net
 [IPv6:2a02:8429:80cd:3101:328d:99ff:fe25:ad3f])
 by joooj.vinc17.net (Postfix) with ESMTPSA id DF7C961;
 Tue, 28 May 2019 02:53:39 +0200 (CEST)
Received: by zira.vinc17.org (Postfix, from userid 1000)
 id 6394EC20372; Tue, 28 May 2019 02:53:39 +0200 (CEST)
Date: Tue, 28 May 2019 02:53:39 +0200
From: Vincent Lefevre <vincent@HIDDEN>
To: bug-coreutils@HIDDEN
Subject: version sort is incorrect with hyphen-minus
Message-ID: <20190528005339.GB5676@HIDDEN>
Mail-Followup-To: Vincent Lefevre <vincent@HIDDEN>, bug-coreutils@HIDDEN
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
X-Mailer-Info: https://www.vinc17.net/mutt/
User-Agent: Mutt/1.12+5 (cd30526c) vl-117499 (2019-05-26)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2001:4b99:1:3:216:3eff:fe20:ac98
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

With GNU coreutils 8.30 under Debian/unstable, I get:

$ LC_ALL=3DC ls
ab-cd  abb  abe
$ LC_ALL=3DC ls -v
abb  abe  ab-cd

The hyphen-minus character should still be regarded as being less
than the letters (there are no digits, so both are expected to be
equivalent). The GNU coreutils manual says:

10.1.3 Sorting the output
-------------------------
[...]
=E2=80=98-v=E2=80=99
=E2=80=98--sort=3Dversion=E2=80=99
     Sort by version name and number, lowest first.  It behaves like a
     default sort, except that each sequence of decimal digits is
     treated numerically as an index/version number.  (*Note Details
     about version sort::.)

(which is exactly what I expect).

The "sort -V" command has the same issue.

Note: If I add two more files and compare with zsh:

zira% export LC_ALL=3DC
zira% ls
ab-cd  ab10  ab2  abb  abe
zira% ls -v
ab2  ab10  abb  abe  ab-cd
zira% echo *
ab-cd ab10 ab2 abb abe
zira% echo *(n)
ab-cd ab2 ab10 abb abe

one can see that zsh is correct, but Coreutils has an issue with the
hyphen-minus character.

--=20
Vincent Lef=C3=A8vre <vincent@HIDDEN> - Web: <https://www.vinc17.net/=
>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Acknowledgement sent to Vincent Lefevre <vincent@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#35939; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 27 Jun 2019 10:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.