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 3455c8585d4dac2eaf0ca9ec1a68712873b3d307

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-05 20:48
Parent(s): 22120d43615c104fd0c7b50e07cd27614f619c41
Signing key: 99DC5E4DB05F6BE2
Tree: a27ea8f7ccdbf9c9009cdd38a83f8ebc0561e216
File Lines added Lines deleted
ChangeLog 3 0
src/sort.c 18 5
File ChangeLog changed (mode: 100644) (index 5c682cddd..f9ee0fd9a)
82 82 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
83 83 file-system in a Unix environment as a success. Thanks to feekApp. file-system in a Unix environment as a success. Thanks to feekApp.
84 84
85 Fixed odd sorting with musl caused by its buggy strverscmp(). The
86 ordering shouldn't depend on libc in use.
87
85 88 0.14-beta to 0.14 (2025-02-08) 0.14-beta to 0.14 (2025-02-08)
86 89
87 90 Improved documentation on zh/zl menu keys a bit. Improved documentation on zh/zl menu keys a bit.
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