FreeBSD/bin/ls/ls.c
/*
 * Ordering for mastercmp:
 * If ordering the argv (fts_level = FTS_ROOTLEVEL) return non-directories
 * as larger than directories.  Within either group, use the sort function.
 * All other levels use the sort function.  Error entries remain unsorted.
 */
Ordering for mastercmp:
If ordering the argv (fts_level = FTS_ROOTLEVEL) return non-directories
as larger than directories.  Within either group, use the sort function.
All other levels use the sort function.  Error entries remain unsorted.
Ordering for mastercmp : If ordering the argv ( fts_level = FTS_ROOTLEVEL ) return non - directories as larger than directories . Within either group use the sort function . All other levels use the sort function . Error entries remain unsorted .
static int
mastercmp(const FTSENT * const *a, const FTSENT * const *b)
{
	int a_info, b_info;
	a_info = (*a)->fts_info;
	if (a_info == FTS_ERR)
		return (0);
	b_info = (*b)->fts_info;
	if (b_info == FTS_ERR)
		return (0);
	if (a_info == FTS_NS || b_info == FTS_NS)
		return (namecmp(*a, *b));
	if (a_info != b_info &&
	    (*a)->fts_level == FTS_ROOTLEVEL && !f_listdir) {
		if (a_info == FTS_D)
			return (1);
		if (b_info == FTS_D)
			return (-1);
	}
	return (sortfcn(*a, *b));
}
static int mastercmp ( const FTSENT * const * a , const FTSENT * const * b ) { int a_info , b_info ; a_info = ( * a ) -> fts_info ; if ( a_info == FTS_ERR ) return ( 0 ) ; b_info = ( * b ) -> fts_info ; if ( b_info == FTS_ERR ) return ( 0 ) ; if ( a_info == FTS_NS || b_info == FTS_NS ) return ( namecmp ( * a , * b ) ) ; if ( a_info != b_info && ( * a ) -> fts_level == FTS_ROOTLEVEL && ! f_listdir ) { if ( a_info == FTS_D ) return ( 1 ) ; if ( b_info == FTS_D ) return ( -1 ) ; } return ( sortfcn ( * a , * b ) ) ; }
Ordering for mastercmp:
 If ordering the argv (fts_level = FTS_ROOTLEVEL) return non-directories
 as larger than directories.
Ordering for mastercmp : If ordering the argv ( fts_level = FTS_ROOTLEVEL ) return non - directories as larger than directories .