From e9607dbeb9bc1bd07bd1782db915b4b21a983801 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 1 Mar 1996 17:40:28 +0000 Subject: Fri Mar 1 10:09:46 1996 Roland McGrath * 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 * 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. --- posix/glob.c | 53 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) (limited to 'posix/glob.c') diff --git a/posix/glob.c b/posix/glob.c index c8f2eab..8646bba 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 -#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 -#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__. */ +#if defined (HAVE_DIRENT_H) || defined (__GNU_LIBRARY__) +# 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 @@ -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) -- cgit v1.1