1 Looking at FreeBSD's manual page, it appears that FreeBSD 5.2 changed
2 the signature of the comparison function:
3 
4         FTS * fts_open(char * const *path_argv, int options,
5                 int (*compar)(const FTSENT * const *, const FTSENT * const *));
6 
7 --- ls/ls.c.orig	2009-03-01 22:58:20 UTC
8 +++ ls/ls.c
9 @@ -73,7 +73,14 @@ static void	 display(FTSENT *, FTSENT *);
10  #include "extern.h"
11 
12  static void	 display(FTSENT *, FTSENT *);
13 +
14 +/* workaround FreeBSD <fts.h> changing fts_open()'s compar signature */
15 +#if defined(__FreeBSD__) && defined(USE_FTS_H)
16 +static int	 mastercmp(const FTSENT * const *, const FTSENT * const *);
17 +#else
18  static int	 mastercmp(const FTSENT **, const FTSENT **);
19 +#endif
20 +
21  static void	 traverse(int, char **, int);
22 
23  static void (*printfcn)(DISPLAY *);
24 @@ -595,7 +602,11 @@ static int
25   * All other levels use the sort function.  Error entries remain unsorted.
26   */
27  static int
28 +#if defined(__FreeBSD__) && defined(USE_FTS_H)
29 +mastercmp(const FTSENT * const *a, const FTSENT * const *b)
30 +#else
31  mastercmp(const FTSENT **a, const FTSENT **b)
32 +#endif
33  {
34  	int a_info, b_info;
35 
36