From 38ab7ab2fbd83c0c62e4b78302b5fe89da0cb79e Mon Sep 17 00:00:00 2001 From: Akira TAGOH Date: Thu, 27 Jun 2013 13:10:27 +0900 Subject: [PATCH] Fix a incompatible pointer warning on NetBSD --- configure.ac | 29 +++++++++++++++++++++++++++++ src/fcstat.c | 10 ++++++++++ 2 files changed, 39 insertions(+) diff --git a/configure.ac b/configure.ac index 0f129db..a2b1c72 100644 --- a/configure.ac +++ b/configure.ac @@ -161,6 +161,35 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([[ AC_MSG_RESULT([yes]) AC_DEFINE([HAVE_POSIX_FADVISE], [1], [Define to 1 if you have the 'posix_fadvise' function.]) ],[AC_MSG_RESULT([no])]) +AC_MSG_CHECKING([for scandir]) +AC_LINK_IFELSE([AC_LANG_SOURCE([[ + #include + int comp(const struct dirent **, const struct dirent **); + int comp(const struct dirent **a, const struct dirent **b) { return 0; } + int main(void) { + struct dirent **d; + return scandir(".", &d, 0, &comp) >= 0; + } + ]])],[ + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_SCANDIR], [1], [Define to 1 if you have the 'scandir' function.]) + ],[ + AC_LINK_IFELSE([AC_LANG_SOURCE([[ + #include + int comp(const void *, const void *); + int comp(const void *a, const void *b) { return 0; } + int main(void) { + struct dirent **d; + return scandir(".", &d, 0, &comp) >= 0; + } + ]])],[ + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_SCANDIR_VOID_P], [1], [Define to 1 if you have the 'scandir' function with int (* compar)(const void *, const void *)]) + ],[ + AC_MSG_ERROR([ +*** No scandir function available.]) + ]) + ]) CFLAGS="$fc_saved_CFLAGS" # diff --git a/src/fcstat.c b/src/fcstat.c index 390f45c..ab56aca 100644 --- a/src/fcstat.c +++ b/src/fcstat.c @@ -164,11 +164,21 @@ FcDirChecksumScandirFilter(const struct dirent *entry) } #endif +#ifdef HAVE_SCANDIR static int FcDirChecksumScandirSorter(const struct dirent **lhs, const struct dirent **rhs) { return strcmp((*lhs)->d_name, (*rhs)->d_name); } +#elif HAVE_SCANDIR_VOID_P +static int +FcDirChecksumScandirSorter(const void *a, const void *b) +{ + const struct dirent *lhs = a, *rhs = b; + + return strcmp(lhs->d_name, rhs->d_name); +} +#endif static int FcDirChecksum (const FcChar8 *dir, time_t *checksum)