summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1996-03-01 17:45:37 +0000
committerRoland McGrath <roland@redhat.com>1996-03-01 17:45:37 +0000
commit490f35dda4ea0b87fe8215b3f2233b7eeb44c585 (patch)
treec20b115e40f7ff689c13d3667aa814002f0aeef9
parenta579af186bbb9bf891286b0940800a88e3e71f9a (diff)
downloadgunmake-490f35dda4ea0b87fe8215b3f2233b7eeb44c585.tar.gz
Fri Mar 1 12:04:47 1996 Roland McGrath <roland@charlie-brown.gnu.ai.mit.edu>
* 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.
-rw-r--r--dir.c53
1 files changed, 25 insertions, 28 deletions
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 <dirent.h>
-#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 <sys/ndir.h>
-#endif /* HAVE_SYS_NDIR_H */
-#ifdef HAVE_SYS_DIR_H
-#include <sys/dir.h>
-#endif /* HAVE_SYS_DIR_H */
-#ifdef HAVE_NDIR_H
-#include <ndir.h>
-#endif /* HAVE_NDIR_H */
-#endif /* POSIX or HAVE_DIRENT_H or __GNU_LIBRARY__. */
+#ifdef HAVE_DIRENT_H
+# include <dirent.h>
+# define NAMLEN(dirent) strlen((dirent)->d_name)
+#else
+# define dirent direct
+# define NAMLEN(dirent) (dirent)->d_namlen
+# ifdef HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif
+# ifdef HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif
+# ifdef HAVE_NDIR_H
+# include <ndir.h>
+# endif
+#endif
+
+/* In GNU systems, <dirent.h> 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);