]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Include autoconf-recommended block of dirent/NAMELEN
authorJim Meyering <jim@meyering.net>
Wed, 22 Jan 2003 13:13:04 +0000 (13:13 +0000)
committerJim Meyering <jim@meyering.net>
Wed, 22 Jan 2003 13:13:04 +0000 (13:13 +0000)
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

index b7583db12b35d0f1857e26265027d901609829a3..3fe76d1cd99913f77406d07e89c2efbf315efac7 100644 (file)
--- a/lib/ftw.c
+++ b/lib/ftw.c
 # include <config.h>
 #endif
 
-#if HAVE_DIRENT_H || defined _LIBC
+#if defined _LIBC
 # include <dirent.h>
+# define NAMLEN(dirent) _D_EXACT_NAMLEN(dirent)
 #else
-# define dirent direct
-# if HAVE_SYS_NDIR_H
-#  include <sys/ndir.h>
-# endif
-# if HAVE_SYS_DIR_H
-#  include <sys/dir.h>
-# endif
-# if HAVE_NDIR_H
-#  include <ndir.h>
+# if HAVE_DIRENT_H || defined _LIBC
+#  include <dirent.h>
+#  define NAMLEN(dirent) strlen ((dirent)->d_name)
+# else
+#  define dirent direct
+#  define NAMLEN(dirent) (dirent)->d_namlen
+#  if HAVE_SYS_NDIR_H
+#   include <sys/ndir.h>
+#  endif
+#  if HAVE_SYS_DIR_H
+#   include <sys/dir.h>
+#  endif
+#  if HAVE_NDIR_H
+#   include <ndir.h>
+#  endif
 # endif
 #endif
 
 # include <sys/stat.h>
 #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 <assert.h>
 
 # 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
 # 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;
     }