GNU bug report logs - #49239
Unexpected results with sort -V

Previous Next

Package: coreutils;

Reported by: Michael <michael.debertol <at> gmail.com>

Date: Sun, 27 Jun 2021 06:37:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #28 received at 49239-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Kamil Dudka <kdudka <at> redhat.com>,
 Michael Debertol <michael.debertol <at> gmail.com>
Cc: 49239-done <at> debbugs.gnu.org, Gnulib bugs <bug-gnulib <at> gnu.org>
Subject: Re: bug#49239: Unexpected results with sort -V
Date: Sat, 12 Feb 2022 21:31:33 -0800
[Message part 1 (text/plain, inline)]
On 6/28/21 10:54, Kamil Dudka wrote:
> You are right.  The matching algorithm was not implemented correctly and
> the patch you attached fixes it.

I looked into Bug#49239 and found some more places where the 
documentation disagreed with the code. I installed the attached patches 
into Gnulib and Coreutils, respectively, which should bring the two into 
agreement and should fix the bugs that Michael reported albeit in a 
different way than his proposed patch. Briefly:

* The code didn't allow file name suffixes to be the entire file name, 
but the documentation did. Here I went with the documentation. I could 
be talked into the other way; it shouldn't matter much either way.

* The code did the preliminary test (without suffixes) using strcmp, the 
documentation said it should use version comparison. Here I went with 
the documentation.

* As Michael mentioned, sort -V mishandled NUL. I fixed this by adding a 
Gnulib function filenvercmp that treats NUL as just another character.

* As Michael also mentioned, filevercmp fell back on strcmp if version 
sort found no difference, which meant sort's --stable flag was 
ineffective. I fixed this by not having filevercmp fall back on strcmp.

* I fixed the two-consecutive dot and trailing-dot bugs Michael 
mentioned, by rewriting the suffix finder to not have that confusing 
READ_ALPHA state variable, and to instead implement the regular 
expression's nested * operators in the usual way with nested loops.

Thanks, Michael, for reporting the problem. I'm boldly closing the 
Coreutils bug report as fixed.
[0001-filevercmp-fix-several-unexpected-results.patch (text/x-patch, attachment)]
[0001-sort-fix-several-version-sort-problems.patch (text/x-patch, attachment)]

This bug report was last modified 3 years and 94 days ago.

Previous Next


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