diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ls.c | 72 |
1 files changed, 36 insertions, 36 deletions
@@ -2871,52 +2871,52 @@ static int rev_str_extension (V a, V b) { return compstr_extension (b, a); } static void sort_files (void) { - /* `func' must be `volatile', so it can't be - clobbered by a `longjmp' into this function. */ - int (* volatile func) (V, V); + int (*func) (V, V); - switch (sort_type) + /* Try strcoll. If it fails, fall back on strcmp. We can't safely + ignore strcoll failures, as a failing strcoll might be a + comparison function that is not a total order, and if we ignored + the failure this might cause qsort to dump core. */ + + if (! setjmp (failed_strcoll)) { - case sort_none: - return; - case sort_time: - switch (time_type) + switch (sort_type) { - case time_ctime: - func = sort_reverse ? rev_cmp_ctime : compare_ctime; + case sort_none: + return; + case sort_time: + switch (time_type) + { + case time_ctime: + func = sort_reverse ? rev_cmp_ctime : compare_ctime; + break; + case time_mtime: + func = sort_reverse ? rev_cmp_mtime : compare_mtime; + break; + case time_atime: + func = sort_reverse ? rev_cmp_atime : compare_atime; + break; + default: + abort (); + } break; - case time_mtime: - func = sort_reverse ? rev_cmp_mtime : compare_mtime; + case sort_name: + func = sort_reverse ? rev_cmp_name : compare_name; + break; + case sort_extension: + func = sort_reverse ? rev_cmp_extension : compare_extension; + break; + case sort_size: + func = sort_reverse ? rev_cmp_size : compare_size; break; - case time_atime: - func = sort_reverse ? rev_cmp_atime : compare_atime; + case sort_version: + func = sort_reverse ? rev_cmp_version : compare_version; break; default: abort (); } - break; - case sort_name: - func = sort_reverse ? rev_cmp_name : compare_name; - break; - case sort_extension: - func = sort_reverse ? rev_cmp_extension : compare_extension; - break; - case sort_size: - func = sort_reverse ? rev_cmp_size : compare_size; - break; - case sort_version: - func = sort_reverse ? rev_cmp_version : compare_version; - break; - default: - abort (); } - - /* Try strcoll. If it fails, fall back on strcmp. We can't safely - ignore strcoll failures, as a failing strcoll might be a - comparison function that is not a total order, and if we ignored - the failure this might cause qsort to dump core. */ - - if (setjmp (failed_strcoll)) + else { switch (sort_type) { |