]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(sort_files): Minor cleanup. Remove an unnecessary
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 2 Dec 2004 00:31:43 +0000 (00:31 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 2 Dec 2004 00:31:43 +0000 (00:31 +0000)
'volatile' on a local variable.  Rewrite to avoid unnecessary
double-assignment to 'func' in the usual case where strcoll does
not fail.

src/ls.c

index accdffc5d6dbdaccc6cc810dbf0a5dc6e9a2c543..9b085c455e812b373caf424822aeba8c1a50eabc 100644 (file)
--- 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)
        {