From 490f35dda4ea0b87fe8215b3f2233b7eeb44c585 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 1 Mar 1996 17:45:37 +0000 Subject: Fri Mar 1 12:04:47 1996 Roland McGrath * dir.c: Use canonical code from autoconf manual for dirent include. [_D_NAMLEN]: Redefine NAMLEN using this. (dir_contents_file_exists_p): Use NAMLEN macro. (read_dirstream) [_DIRENT_HAVE_D_NAMLEN]: Only set d_namlen #if this. --- dir.c | 53 +++++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) (limited to 'dir.c') diff --git a/dir.c b/dir.c index 30d6752..ba2acc5 100644 --- a/dir.c +++ b/dir.c @@ -1,5 +1,5 @@ /* Directory hashing for GNU Make. -Copyright (C) 1988, 89, 91, 92, 93, 94, 95 Free Software Foundation, Inc. +Copyright (C) 1988, 89, 91, 92, 93, 94, 95, 96 Free Software Foundation, Inc. This file is part of GNU Make. GNU Make is free software; you can redistribute it and/or modify @@ -18,24 +18,28 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "make.h" -#if defined (POSIX) || defined (HAVE_DIRENT_H) || defined (__GNU_LIBRARY__) -#include -#if defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 -#define HAVE_D_NAMLEN -#endif /* GNU C library. */ -#else /* Not POSIX or HAVE_DIRENT_H. */ -#define direct dirent -#define HAVE_D_NAMLEN -#ifdef HAVE_SYS_NDIR_H -#include -#endif /* HAVE_SYS_NDIR_H */ -#ifdef HAVE_SYS_DIR_H -#include -#endif /* HAVE_SYS_DIR_H */ -#ifdef HAVE_NDIR_H -#include -#endif /* HAVE_NDIR_H */ -#endif /* POSIX or HAVE_DIRENT_H or __GNU_LIBRARY__. */ +#ifdef HAVE_DIRENT_H +# include +# define NAMLEN(dirent) strlen((dirent)->d_name) +#else +# define dirent direct +# define NAMLEN(dirent) (dirent)->d_namlen +# ifdef HAVE_SYS_NDIR_H +# include +# endif +# ifdef HAVE_SYS_DIR_H +# include +# endif +# ifdef HAVE_NDIR_H +# include +# endif +#endif + +/* In GNU systems, defines this macro for us. */ +#ifdef _D_NAMLEN +#undef NAMLEN +#define NAMLEN(d) _D_NAMLEN(d) +#endif #if defined (POSIX) && !defined (__GNU_LIBRARY__) /* Posix does not require that the d_ino field be present, and some @@ -295,14 +299,7 @@ dir_contents_file_exists_p (dir, filename) if (!REAL_DIR_ENTRY (d)) continue; -#ifdef HAVE_D_NAMLEN - len = d->d_namlen; - while (d->d_name[len - 1] == '\0') - --len; -#else - len = strlen (d->d_name); -#endif - + len = NAMLEN (d); for (i = 0; i < len; ++i) HASH (newhash, d->d_name[i]); newhash %= DIRFILE_BUCKETS; @@ -619,7 +616,7 @@ read_dirstream (stream) } d = (struct dirent *) buf; FAKE_DIR_ENTRY (d); -#ifdef HAVE_D_NAMLEN +#ifdef _DIRENT_HAVE_D_NAMLEN d->d_namlen = len - 1; #endif memcpy (d->d_name, df->name, len); -- cgit v1.2.3