Project/Real_code/gnu/coreutils-5.0/src/ls.c
static void
sort_files (void)
{
  int (*func) (V, V);

  switch (sort_type)
    {
    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 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))
    {
      switch (sort_type)
	{
	case sort_time:
	  switch (time_type)
	    {
	    case time_ctime:
	      func = sort_reverse ? rev_str_ctime : compstr_ctime;
	      break;
	    case time_mtime:
	      func = sort_reverse ? rev_str_mtime : compstr_mtime;
	      break;
	    case time_atime:
	      func = sort_reverse ? rev_str_atime : compstr_atime;
	      break;
	    default:
	      abort ();
	    }
	  break;
	case sort_name:
	  func = sort_reverse ? rev_str_name : compstr_name;
	  break;
	case sort_extension:
	  func = sort_reverse ? rev_str_extension : compstr_extension;
	  break;
	case sort_size:
	  func = sort_reverse ? rev_str_size : compstr_size;
	  break;
	default:
	  abort ();
	}
    }

  qsort (files, files_index, sizeof (struct fileinfo), func);
}
/* Sort the files now in the table.  */
Sort the files now in the table.
Sort the files now in the table .
static void
sort_files (void)
{
  int (*func) (V, V);
  switch (sort_type)
    {
    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 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 ();
    }
  if (setjmp (failed_strcoll))
    {
      switch (sort_type)
	{
	case sort_time:
	  switch (time_type)
	    {
	    case time_ctime:
	      func = sort_reverse ? rev_str_ctime : compstr_ctime;
	      break;
	    case time_mtime:
	      func = sort_reverse ? rev_str_mtime : compstr_mtime;
	      break;
	    case time_atime:
	      func = sort_reverse ? rev_str_atime : compstr_atime;
	      break;
	    default:
	      abort ();
	    }
	  break;
	case sort_name:
	  func = sort_reverse ? rev_str_name : compstr_name;
	  break;
	case sort_extension:
	  func = sort_reverse ? rev_str_extension : compstr_extension;
	  break;
	case sort_size:
	  func = sort_reverse ? rev_str_size : compstr_size;
	  break;
	default:
	  abort ();
	}
    }
  qsort (files, files_index, sizeof (struct fileinfo), func);
}
static void sort_files ( void ) { int ( * func ) ( V , V ) ; switch ( sort_type ) { 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 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 ( ) ; } if ( setjmp ( failed_strcoll ) ) { switch ( sort_type ) { case sort_time : switch ( time_type ) { case time_ctime : func = sort_reverse ? rev_str_ctime : compstr_ctime ; break ; case time_mtime : func = sort_reverse ? rev_str_mtime : compstr_mtime ; break ; case time_atime : func = sort_reverse ? rev_str_atime : compstr_atime ; break ; default : abort ( ) ; } break ; case sort_name : func = sort_reverse ? rev_str_name : compstr_name ; break ; case sort_extension : func = sort_reverse ? rev_str_extension : compstr_extension ; break ; case sort_size : func = sort_reverse ? rev_str_size : compstr_size ; break ; default : abort ( ) ; } } qsort ( files , files_index , sizeof ( struct fileinfo ) , func ) ; }
Sort the files now in the table.
Sort the files now in the table .
/* 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.  */