diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2006-07-11 17:19:48 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2006-07-11 17:19:48 +0000 |
commit | 2b6236d156b394227e41b0d664cf600b69db9403 (patch) | |
tree | 08467d898c62dfb113adbc671fdb9de956159792 /lib | |
parent | 888ee9b8d99f7ed10f04b387eaf6e1477369c0fa (diff) | |
download | coreutils-2b6236d156b394227e41b0d664cf600b69db9403.tar.xz |
Sync from gnulib.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ChangeLog | 8 | ||||
-rw-r--r-- | lib/backupfile.c | 13 | ||||
-rw-r--r-- | lib/dirfd.h | 7 | ||||
-rw-r--r-- | lib/fts.c | 24 | ||||
-rw-r--r-- | lib/getcwd.c | 8 | ||||
-rw-r--r-- | lib/savedir.c | 10 |
6 files changed, 27 insertions, 43 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog index 2f9da0822..5d114117d 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,11 @@ +2006-07-10 Derek R. Price <derek@ximbiot.com> + + * backupfile.c, dirfd.h, fts.c, getcwd.c: + Ignore the obsolescent !HAVE_DIRENT_H case. Consolidate NAMLEN + macros into the GNU _D_EXACT_NAMLEN. + * savedir.c: Likewise. + (savedirstream): Use _D_EXACT_NAMLEN in preference to strlen. + 2006-07-08 Paul Eggert <eggert@cs.ucla.edu> * Makefile.am (stdint.h): FULL_PATH_STDINT_H -> ABSOLUTE_STDINT_H, diff --git a/lib/backupfile.c b/lib/backupfile.c index 13c471583..c24325d8f 100644 --- a/lib/backupfile.c +++ b/lib/backupfile.c @@ -41,15 +41,10 @@ #include <unistd.h> -#if HAVE_DIRENT_H -# include <dirent.h> -# define NLENGTH(direct) strlen ((direct)->d_name) -#else -# define dirent direct -# define NLENGTH(direct) ((size_t) (direct)->d_namlen) -# include <ndir.h> +#include <dirent.h> +#ifndef _D_EXACT_NAMLEN +# define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name) #endif - #if D_INO_IN_DIRENT # define REAL_DIR_ENTRY(dp) ((dp)->d_ino != 0) #else @@ -211,7 +206,7 @@ numbered_backup (char **buffer, size_t buffer_size, size_t filelen) size_t versionlen; size_t new_buflen; - if (! REAL_DIR_ENTRY (dp) || NLENGTH (dp) < baselen + 4) + if (! REAL_DIR_ENTRY (dp) || _D_EXACT_NAMLEN (dp) < baselen + 4) continue; if (memcmp (buf + base_offset, dp->d_name, baselen + 2) != 0) diff --git a/lib/dirfd.h b/lib/dirfd.h index 601332c8b..05b77774f 100644 --- a/lib/dirfd.h +++ b/lib/dirfd.h @@ -19,12 +19,7 @@ #include <sys/types.h> -#if HAVE_DIRENT_H -# include <dirent.h> -#else -# define dirent direct -# include <ndir.h> -#endif +#include <dirent.h> #ifndef HAVE_DECL_DIRFD "this configure-time declaration test was not run" @@ -78,17 +78,9 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; # include "unistd--.h" #endif -#if HAVE_DIRENT_H || _LIBC -# include <dirent.h> -# ifdef _D_EXACT_NAMLEN -# define NAMLEN(dirent) _D_EXACT_NAMLEN (dirent) -# else -# define NAMLEN(dirent) strlen ((dirent)->d_name) -# endif -#else -# define dirent direct -# define NAMLEN(dirent) (dirent)->d_namlen -# include <ndir.h> +#include <dirent.h> +#ifndef _D_EXACT_NAMLEN +# define _D_EXACT_NAMLEN(dirent) strlen ((dirent)->d_name) #endif #ifdef _LIBC @@ -959,11 +951,13 @@ fts_build (register FTS *sp, int type) if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) continue; - if ((p = fts_alloc(sp, dp->d_name, NAMLEN (dp))) == NULL) + if ((p = fts_alloc (sp, dp->d_name, + _D_EXACT_NAMLEN (dp))) == NULL) goto mem1; - if (NAMLEN (dp) >= maxlen) {/* include space for NUL */ + if (_D_EXACT_NAMLEN (dp) >= maxlen) { + /* include space for NUL */ oldaddr = sp->fts_path; - if (! fts_palloc(sp, NAMLEN (dp) + len + 1)) { + if (! fts_palloc(sp, _D_EXACT_NAMLEN (dp) + len + 1)) { /* * No more memory. Save * errno, free up the current structure and the @@ -988,7 +982,7 @@ mem1: saved_errno = errno; maxlen = sp->fts_pathlen - len; } - new_len = len + NAMLEN (dp); + new_len = len + _D_EXACT_NAMLEN (dp); if (new_len < len) { /* * In the unlikely even that we would end up diff --git a/lib/getcwd.c b/lib/getcwd.c index a67dc0c07..614ded18d 100644 --- a/lib/getcwd.c +++ b/lib/getcwd.c @@ -36,13 +36,7 @@ # define __set_errno(val) (errno = (val)) #endif -#if HAVE_DIRENT_H || _LIBC -# include <dirent.h> -#else -# define dirent direct -# define _D_EXACT_NAMLEN(d) (d)->d_namlen -# include <ndir.h> -#endif +#include <dirent.h> #ifndef _D_EXACT_NAMLEN # define _D_EXACT_NAMLEN(d) strlen ((d)->d_name) #endif diff --git a/lib/savedir.c b/lib/savedir.c index c68547054..4b0702480 100644 --- a/lib/savedir.c +++ b/lib/savedir.c @@ -29,11 +29,9 @@ #include <errno.h> -#if HAVE_DIRENT_H -# include <dirent.h> -#else -# define dirent direct -# include <ndir.h> +#include <dirent.h> +#ifndef _D_EXACT_NAMLEN +# define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name) #endif #include <stddef.h> @@ -81,7 +79,7 @@ savedirstream (DIR *dirp) entry = dp->d_name; if (entry[entry[0] != '.' ? 0 : entry[1] != '.' ? 1 : 2] != '\0') { - size_t entry_size = strlen (entry) + 1; + size_t entry_size = _D_EXACT_NAMLEN (dp) + 1; if (used + entry_size < used) xalloc_die (); if (allocated <= used + entry_size) |