bug-gnulib
[Top][All Lists]
Advanced

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

Re: bug#49239: Unexpected results with sort -V


From: Paul Eggert
Subject: Re: bug#49239: Unexpected results with sort -V
Date: Sat, 12 Feb 2022 21:31:33 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0

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.

Attachment: 0001-filevercmp-fix-several-unexpected-results.patch
Description: Text Data

Attachment: 0001-sort-fix-several-version-sort-problems.patch
Description: Text Data


reply via email to

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