summaryrefslogtreecommitdiff
path: root/src/ls.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2004-12-02 00:31:43 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2004-12-02 00:31:43 +0000
commit29f4f8aff68858d92646a58a67699bf6132fbc97 (patch)
tree495b5ffff28d0f90af4347c03b6cfa0bc7c2566f /src/ls.c
parent782bb54c6b87de8744fa1c6b4fe81e1e34cb05bc (diff)
downloadcoreutils-29f4f8aff68858d92646a58a67699bf6132fbc97.tar.xz
(sort_files): Minor cleanup. Remove an unnecessary
'volatile' on a local variable. Rewrite to avoid unnecessary double-assignment to 'func' in the usual case where strcoll does not fail.
Diffstat (limited to 'src/ls.c')
-rw-r--r--src/ls.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/ls.c b/src/ls.c
index accdffc5d..9b085c455 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -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)
{