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 * |