xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit be3c9262821e8eea2e2590edaaaef462ecbe5664

Fix odd sorting with musl due to buggy strverscmp
A filename without a number should not be considered less than any
filename with a number.

The ordering shouldn't depend on libc in use.
Author: xaizek
Author date (UTC): 2025-05-05 14:52
Committer name: xaizek
Committer date (UTC): 2025-05-06 12:14
Parent(s): 289fab9d9ab3497d65d9bc03aebae7c31f49701f
Signing key: 99DC5E4DB05F6BE2
Tree: aad15abf83a2b0e5206832ebba752b68b1be0564
File Lines added Lines deleted
ChangeLog 3 0
src/sort.c 18 5
File ChangeLog changed (mode: 100644) (index 06567e205..b9e021668)
9 9 Fixed treating a failure to create a trash directory on a read-only Fixed treating a failure to create a trash directory on a read-only
10 10 file-system in a Unix environment as a success. Thanks to feekApp. file-system in a Unix environment as a success. Thanks to feekApp.
11 11
12 Fixed odd sorting with musl caused by its buggy strverscmp(). The
13 ordering shouldn't depend on libc in use.
14
12 15 0.14 to 0.14.1 (2025-05-02) 0.14 to 0.14.1 (2025-05-02)
13 16
14 17 Made documentation on which :commands can have comments a bit more Made documentation on which :commands can have comments a bit more
File src/sort.c changed (mode: 100644) (index f45616526..7398c098d)
... ... TSTATIC int
495 495 strnumcmp(const char s[], const char t[]) strnumcmp(const char s[], const char t[])
496 496 { {
497 497 #if HAVE_STRVERSCMP_FUNC #if HAVE_STRVERSCMP_FUNC
498 const char *new_s = skip_leading_zeros(s);
499 const char *new_t = skip_leading_zeros(t);
500 return strverscmp(new_s, new_t);
501 #else
498 static int buggy_musl = -1;
499 if(buggy_musl < 0)
500 {
501 /* "A" has an empty sequence of digits, so byte sorting should be used. */
502 buggy_musl = (strverscmp("A", "10") < 0);
503 }
504
505 if(!buggy_musl)
506 {
507 const char *new_s = skip_leading_zeros(s);
508 const char *new_t = skip_leading_zeros(t);
509 return strverscmp(new_s, new_t);
510 }
511
512 /* Fall through to the custom implementation which is aligned with the correct
513 * version. */
514 #endif
515
502 516 while(*s != '\0' && *t != '\0') while(*s != '\0' && *t != '\0')
503 517 { {
504 518 if(isdigit(*s) && isdigit(*t)) if(isdigit(*s) && isdigit(*t))
 
... ... strnumcmp(const char s[], const char t[])
528 542 } }
529 543
530 544 return SORT_CMP((unsigned char)*s, (unsigned char)*t); return SORT_CMP((unsigned char)*s, (unsigned char)*t);
531 #endif
532 545 } }
533 546
534 547 #if HAVE_STRVERSCMP_FUNC #if HAVE_STRVERSCMP_FUNC
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master