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 289fab9d9ab3497d65d9bc03aebae7c31f49701f

Simplify #if-defs in sort.c
This is a preparation for updating related code.
Author: xaizek
Author date (UTC): 2025-05-05 14:46
Committer name: xaizek
Committer date (UTC): 2025-05-06 12:14
Parent(s): 9ffd8796d95e461ebe3dc4a7e734007ce95b1d48
Signing key: 99DC5E4DB05F6BE2
Tree: 9895adef42620b19559b8f4bad03b5f582ccf62f
File Lines added Lines deleted
src/sort.c 6 14
File src/sort.c changed (mode: 100644) (index 7e989046f..f45616526)
... ... static char * map_ascii(const char str[], int ignore_case);
96 96 static char * lowerdup(const char str[]); static char * lowerdup(const char str[]);
97 97 static int sort_dir_list(const void *one, const void *two); static int sort_dir_list(const void *one, const void *two);
98 98 TSTATIC int strnumcmp(const char s[], const char t[]); TSTATIC int strnumcmp(const char s[], const char t[]);
99 #if !defined(HAVE_STRVERSCMP_FUNC) || !HAVE_STRVERSCMP_FUNC
100 static int vercmp(const char s[], const char t[]);
101 #else
99 #if HAVE_STRVERSCMP_FUNC
102 100 static char * skip_leading_zeros(const char str[]); static char * skip_leading_zeros(const char str[]);
103 101 #endif #endif
104 102 static int compare_file_names(const dir_entry_t *f, const dir_entry_t *s, static int compare_file_names(const dir_entry_t *f, const dir_entry_t *s,
 
... ... lowerdup(const char str[])
496 494 TSTATIC int TSTATIC int
497 495 strnumcmp(const char s[], const char t[]) strnumcmp(const char s[], const char t[])
498 496 { {
499 #if !defined(HAVE_STRVERSCMP_FUNC) || !HAVE_STRVERSCMP_FUNC
500 return vercmp(s, t);
501 #else
497 #if HAVE_STRVERSCMP_FUNC
502 498 const char *new_s = skip_leading_zeros(s); const char *new_s = skip_leading_zeros(s);
503 499 const char *new_t = skip_leading_zeros(t); const char *new_t = skip_leading_zeros(t);
504 500 return strverscmp(new_s, new_t); return strverscmp(new_s, new_t);
505 #endif
506 }
507
508 #if !defined(HAVE_STRVERSCMP_FUNC) || !HAVE_STRVERSCMP_FUNC
509 static int
510 vercmp(const char s[], const char t[])
511 {
501 #else
512 502 while(*s != '\0' && *t != '\0') while(*s != '\0' && *t != '\0')
513 503 { {
514 504 if(isdigit(*s) && isdigit(*t)) if(isdigit(*s) && isdigit(*t))
 
... ... vercmp(const char s[], const char t[])
538 528 } }
539 529
540 530 return SORT_CMP((unsigned char)*s, (unsigned char)*t); return SORT_CMP((unsigned char)*s, (unsigned char)*t);
531 #endif
541 532 } }
542 #else
533
534 #if HAVE_STRVERSCMP_FUNC
543 535 /* Skips all zeros in front of numbers (correctly handles zero). Returns str, a /* Skips all zeros in front of numbers (correctly handles zero). Returns str, a
544 536 * pointer to '0' or a pointer to non-zero digit. */ * pointer to '0' or a pointer to non-zero digit. */
545 537 static char * static char *
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