Max Nikulin <maniku...@gmail.com> writes:

> On 07/10/2022 03:15, Rudolf Adamkovič wrote:
>> 
>> If I understand, "a" should be less than "B" when under "C" locale when
>> ignoring case (nil) , right?  Yet, I get the following:
>> 
>> (string-collate-lessp "a" "B" "C" nil)  ; => nil
>
> When case is not ignored (4th argument is nil) locale-dependent 
> collation rules are used, so you get the expected result.
>
> $ printf 'a\nB\n' | LC_COLLATE=C sort
> B
> a
> $ printf 'a\nB\n' | LC_COLLATE=en_US.UTF-8 sort
> a
> B

Should we then modify the test to set locale explicitly?

>> [FYI: If I replace nil with t, the procedure returns nil too.]
>> 
>> Tested on Emacs 29 (adaa2fc90e) and Org 9.5.5 (580f28614).
>
> Strange. Emacs-26, Linux
>
> (string-collate-lessp "a" "B" "C" t)
> t
>
> If libc is sane (assuming that sort is linked to the same libc)
>
> printf 'a\nb\n' | LC_COLLATE=C sort
> printf 'b\na\n' | LC_COLLATE=C sort
> printf 'A\nB\n' | LC_COLLATE=C sort
> printf 'B\nA\n' | LC_COLLATE=C sort
> printf 'a\nb\n' | LC_COLLATE=C.UTF-8 sort
> printf 'b\na\n' | LC_COLLATE=C.UTF-8 sort
> printf 'A\nB\n' | LC_COLLATE=C.UTF-8 sort
> printf 'B\nA\n' | LC_COLLATE=C.UTF-8 sort
>
> then you might face an Emacs bug.

IDK if it is related, but there was a recent (fixed) bug in
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55787

Note that Rudolf is using Emacs 29.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to