From a10f729ef9f778f09d8e0995f43551b3990daae7 Mon Sep 17 00:00:00 2001 From: David Adam Date: Thu, 11 Dec 2014 15:24:42 +0800 Subject: use configure to detect dirent.d_type --- configure.ac | 4 ++++ osx/config.h | 18 ++++++++++++++++++ wutil.cpp | 4 ++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 9c5c7262..46b466d0 100644 --- a/configure.ac +++ b/configure.ac @@ -502,6 +502,10 @@ fi AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec]) AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec]) +# +# Check for D_TYPE in dirent, only on BSD and Linux +# +AC_STRUCT_DIRENT_D_TYPE # # Check for presense of various functions used by fish diff --git a/osx/config.h b/osx/config.h index d245f198..fde95a19 100644 --- a/osx/config.h +++ b/osx/config.h @@ -19,6 +19,10 @@ /* Define to 1 if you have the `dcgettext' function. */ /* #undef HAVE_DCGETTEXT */ +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + /* Define to 1 if you have the header file. */ #define HAVE_EXECINFO_H 1 @@ -70,6 +74,9 @@ /* Define to 1 if you have the header file. */ /* #undef HAVE_NCURSES_TERM_H */ +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + /* Define to 1 if realpath accepts null for its second argument. */ #define HAVE_REALPATH_NULL 1 @@ -97,12 +104,23 @@ /* Define to 1 if you have the header file. */ /* #undef HAVE_STROPTS_H */ +/* Define to 1 if `d_type' is a member of `struct dirent'. */ +#define HAVE_STRUCT_DIRENT_D_TYPE 1 + /* Define to 1 if you have the `sysconf' function. */ #define HAVE_SYSCONF 1 +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + /* Define to 1 if you have the header file. */ #define HAVE_SYS_IOCTL_H 1 +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + /* Define to 1 if you have the header file. */ #define HAVE_SYS_RESOURCE_H 1 diff --git a/wutil.cpp b/wutil.cpp index 0c877f36..52373fc8 100644 --- a/wutil.cpp +++ b/wutil.cpp @@ -81,7 +81,7 @@ bool wreaddir_resolving(DIR *dir, const std::wstring &dir_path, std::wstring &ou /* We may be able to skip stat, if the readdir can tell us the file type directly */ bool check_with_stat = true; -#if defined(_DIRENT_HAVE_D_TYPE) || __APPLE__ +#ifdef HAVE_STRUCT_DIRENT_D_TYPE if (d->d_type == DT_DIR) { /* Known directory */ @@ -99,7 +99,7 @@ bool wreaddir_resolving(DIR *dir, const std::wstring &dir_path, std::wstring &ou is_dir = false; check_with_stat = false; } -#endif +#endif // HAVE_STRUCT_DIRENT_D_TYPE if (check_with_stat) { /* We couldn't determine the file type from the dirent; check by stat'ing it */ -- cgit v1.2.3