aboutsummaryrefslogtreecommitdiff
path: root/posix/glob.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-03-01 17:40:28 +0000
committerRoland McGrath <roland@gnu.org>1996-03-01 17:40:28 +0000
commite9607dbeb9bc1bd07bd1782db915b4b21a983801 (patch)
tree00f2489aef393b14cf2afb0728bc1077e88acd3c /posix/glob.c
parent4a9af5c70897a71fe0999a1369146a43dc72414e (diff)
downloadglibc-e9607dbeb9bc1bd07bd1782db915b4b21a983801.tar
glibc-e9607dbeb9bc1bd07bd1782db915b4b21a983801.tar.gz
glibc-e9607dbeb9bc1bd07bd1782db915b4b21a983801.tar.bz2
glibc-e9607dbeb9bc1bd07bd1782db915b4b21a983801.zip
Fri Mar 1 10:09:46 1996 Roland McGrath <roland@charlie-brown.gnu.ai.mit.edu>
* posix/glob.c: Use canonical code from autoconf manual for dirent include. [_D_NAMLEN]: Redefine NAMLEN using this. (glob_in_dir): Use NAMLEN macro. * sysdeps/posix/profil.c: New file. Thu Feb 29 20:55:57 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/m68k/profil-counter.h: New file. * libc-symbols.h [GCC >= 2.8] (strong_alias, weak_alias): Remove `extern' keyword. * time/zic.c, time/zdump.c, time/private.h: Updated from ADO 96e.
Diffstat (limited to 'posix/glob.c')
-rw-r--r--posix/glob.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/posix/glob.c b/posix/glob.c
index c8f2eabc5d..8646bba570 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -76,26 +76,30 @@ extern int errno;
#endif
-#if defined (POSIX) || defined (HAVE_DIRENT_H) || defined (__GNU_LIBRARY__)
-#include <dirent.h>
-#ifndef __GNU_LIBRARY__
-#define D_NAMLEN(d) strlen((d)->d_name)
-#else /* GNU C library. */
-#define D_NAMLEN(d) ((d)->d_namlen)
-#endif /* Not GNU C library. */
-#else /* Not POSIX or HAVE_DIRENT_H. */
-#define direct dirent
-#define D_NAMLEN(d) ((d)->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__. */
+#if defined (HAVE_DIRENT_H) || defined (__GNU_LIBRARY__)
+# 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
@@ -692,12 +696,8 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
break;
if (! REAL_DIR_ENTRY (d))
continue;
+
name = d->d_name;
-#ifdef HAVE_D_NAMLEN
- len = d->d_namlen;
-#else
- len = 0;
-#endif
if (fnmatch (pattern, name,
(!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) |
@@ -705,8 +705,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
{
struct globlink *new
= (struct globlink *) __alloca (sizeof (struct globlink));
- if (len == 0)
- len = strlen (name);
+ len = NAMLEN (d);
new->name
= (char *) malloc (len + 1);
if (new->name == NULL)