* configure.ac: Check whether struct dirent has a d_type field

* src/dir.c (dir_contents_file_exists_p): Use the autoconf macro
HAVE_STRUCT_DIRENT_D_TYPE rather than relying on the GNU libc-
specific _DIRENT_HAVE_D_TYPE.
* lib/glob.c: Set HAVE_D_TYPE if HAVE_STRUCT_DIRENT_D_TYPE.
This commit is contained in:
Paul Smith 2019-09-07 16:59:46 -04:00
parent 34ee9adaed
commit c0cb9c8b3d
3 changed files with 6 additions and 3 deletions

View file

@ -164,6 +164,9 @@ AC_CHECK_FUNCS([strcasecmp strncasecmp strcmpi strncmpi stricmp strnicmp])
AC_FUNC_STRCOLL
AC_FUNC_CLOSEDIR_VOID
# dir.c and our glob.c use dirent.d_type if available
AC_STRUCT_DIRENT_D_TYPE
# See if the user wants to add (or not) GNU Guile support
AC_ARG_WITH([guile], [AS_HELP_STRING([--with-guile],
[Support GNU Guile for embedded scripting])])

View file

@ -117,7 +117,7 @@ extern int errno;
/* When used in the GNU libc the symbol _DIRENT_HAVE_D_TYPE is available
if the `d_type' member for `struct dirent' is available. */
#ifdef _DIRENT_HAVE_D_TYPE
#if defined(_DIRENT_HAVE_D_TYPE) || defined(HAVE_STRUCT_DIRENT_D_TYPE)
# define HAVE_D_TYPE 1
#endif

View file

@ -732,7 +732,7 @@ dir_contents_file_exists_p (struct directory_contents *dir,
#else
df->name = strcache_add_len (d->d_name, len);
#endif
#ifdef _DIRENT_HAVE_D_TYPE
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
df->type = d->d_type;
#endif
df->length = len;
@ -1245,7 +1245,7 @@ read_dirstream (__ptr_t stream)
#ifdef _DIRENT_HAVE_D_NAMLEN
d->d_namlen = len - 1;
#endif
#ifdef _DIRENT_HAVE_D_TYPE
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
d->d_type = df->type;
#endif
memcpy (d->d_name, df->name, len);