From eb7d21ab94be6ffaa14e8b5eb1e4d5836b04dcfe Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 22 Jan 2003 13:13:04 +0000 Subject: [PATCH] Include autoconf-recommended block of dirent/NAMELEN related definitions and includes. Use NAMELEN throughout, rather than _D_EXACT_NAMLEN. [_LIBC]: Define NAMELEN to _D_EXACT_NAMLEN. (stpcpy): Declare, if necessary. (mempcpy): Define, if necessary. [!_LIBC] (__stpcpy, __mempcpy): Define. [!_LIBC] (LXSTAT, XSTAT): Define. --- lib/ftw.c | 53 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/lib/ftw.c b/lib/ftw.c index b7583db12b..3fe76d1cd9 100644 --- a/lib/ftw.c +++ b/lib/ftw.c @@ -22,18 +22,25 @@ # include #endif -#if HAVE_DIRENT_H || defined _LIBC +#if defined _LIBC # include +# define NAMLEN(dirent) _D_EXACT_NAMLEN(dirent) #else -# define dirent direct -# if HAVE_SYS_NDIR_H -# include -# endif -# if HAVE_SYS_DIR_H -# include -# endif -# if HAVE_NDIR_H -# include +# if HAVE_DIRENT_H || defined _LIBC +# include +# define NAMLEN(dirent) strlen ((dirent)->d_name) +# else +# define dirent direct +# define NAMLEN(dirent) (dirent)->d_namlen +# if HAVE_SYS_NDIR_H +# include +# endif +# if HAVE_SYS_DIR_H +# include +# endif +# if HAVE_NDIR_H +# include +# endif # endif #endif @@ -52,6 +59,15 @@ # include #endif +#if ! _LIBC && !HAVE_DECL_STPCPY && !defined stpcpy +char *stpcpy (); +#endif + +#if ! _LIBC && ! defined HAVE_MEMPCPY && ! defined mempcpy +/* Be CAREFUL that there are no side effects in N. */ +# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N))) +#endif + /* #define NDEBUG 1 */ #include @@ -74,6 +90,10 @@ # define __tfind tfind # undef __tsearch # define __tsearch tsearch +# undef __stpcpy +# define __stpcpy stpcpy +# undef __mempcpy +# define __mempcpy mempcpy # undef internal_function # define internal_function /* empty */ # undef dirent64 @@ -92,8 +112,13 @@ # define NFTW_NAME nftw # define INO_T ino_t # define STAT stat -# define LXSTAT __lxstat -# define XSTAT __xstat +# ifdef _LIBC +# define LXSTAT __lxstat +# define XSTAT __xstat +# else +# define LXSTAT(V,f,sb) lstat (f,sb) +# define XSTAT(V,f,sb) stat (f,sb) +# endif # define FTW_FUNC_T __ftw_func_t # define NFTW_FUNC_T __nftw_func_t #endif @@ -220,7 +245,7 @@ open_dir_stream (struct ftw_data *data, struct dir_data *dirp) while ((d = __readdir64 (st)) != NULL) { - size_t this_len = _D_EXACT_NAMLEN (d); + size_t this_len = NAMLEN (d); if (actsize + this_len + 2 >= bufsize) { char *newp; @@ -454,7 +479,7 @@ ftw_dir (struct ftw_data *data, struct STAT *st) while (dir.stream != NULL && (d = __readdir64 (dir.stream)) != NULL) { - result = process_entry (data, &dir, d->d_name, _D_EXACT_NAMLEN (d)); + result = process_entry (data, &dir, d->d_name, NAMLEN (d)); if (result != 0) break; } -- 2.47.2