From 2b6236d156b394227e41b0d664cf600b69db9403 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 11 Jul 2006 17:19:48 +0000 Subject: [PATCH] Sync from gnulib. --- lib/ChangeLog | 8 ++++++++ lib/backupfile.c | 13 ++++--------- lib/dirfd.h | 7 +------ lib/fts.c | 24 +++++++++--------------- lib/getcwd.c | 8 +------- lib/savedir.c | 10 ++++------ m4/ChangeLog | 12 ++++++++++++ m4/absolute-header.m4 | 7 ++++--- m4/backupfile.m4 | 3 +-- m4/d-ino.m4 | 10 ++-------- m4/d-type.m4 | 10 ++-------- m4/dirfd.m4 | 24 +++++++++--------------- m4/fts.m4 | 4 ++-- m4/getcwd.m4 | 1 - m4/savedir.m4 | 5 +---- 15 files changed, 60 insertions(+), 86 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index 2f9da08..5d11411 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,11 @@ +2006-07-10 Derek R. Price + + * 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 * Makefile.am (stdint.h): FULL_PATH_STDINT_H -> ABSOLUTE_STDINT_H, diff --git a/lib/backupfile.c b/lib/backupfile.c index 13c4715..c24325d 100644 --- a/lib/backupfile.c +++ b/lib/backupfile.c @@ -41,15 +41,10 @@ #include -#if HAVE_DIRENT_H -# include -# define NLENGTH(direct) strlen ((direct)->d_name) -#else -# define dirent direct -# define NLENGTH(direct) ((size_t) (direct)->d_namlen) -# include +#include +#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 601332c..05b7777 100644 --- a/lib/dirfd.h +++ b/lib/dirfd.h @@ -19,12 +19,7 @@ #include -#if HAVE_DIRENT_H -# include -#else -# define dirent direct -# include -#endif +#include #ifndef HAVE_DECL_DIRFD "this configure-time declaration test was not run" diff --git a/lib/fts.c b/lib/fts.c index 3b577a8..c78f018 100644 --- a/lib/fts.c +++ b/lib/fts.c @@ -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 -# 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 +#include +#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 a67dc0c..614ded1 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 -#else -# define dirent direct -# define _D_EXACT_NAMLEN(d) (d)->d_namlen -# include -#endif +#include #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 c685470..4b07024 100644 --- a/lib/savedir.c +++ b/lib/savedir.c @@ -29,11 +29,9 @@ #include -#if HAVE_DIRENT_H -# include -#else -# define dirent direct -# include +#include +#ifndef _D_EXACT_NAMLEN +# define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name) #endif #include @@ -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) diff --git a/m4/ChangeLog b/m4/ChangeLog index cb3bdae..abeddd2 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,15 @@ +2006-07-11 Eric Blake + + * absolute-header.m4: Fix comments to match recent change. + +2006-07-10 Derek R. Price + and Paul Eggert + + * backupfile.m4, d-ino.m4, d-type.m4, dirfd.m4, fts.m4, getcwd.m4: + * savedir.m4: + Ignore the obsolescent !HAVE_DIRENT_H case. Consolidate NAMLEN + macros into the GNU _D_EXACT_NAMLEN. + 2006-07-10 Paul Eggert * stdint.m4 (gl_STDINT_H): Like yesterday's change to diff --git a/m4/absolute-header.m4 b/m4/absolute-header.m4 index 6f0fd2a..c649df0 100644 --- a/m4/absolute-header.m4 +++ b/m4/absolute-header.m4 @@ -1,4 +1,4 @@ -# absolute-header.m4 serial 5 +# absolute-header.m4 serial 6 dnl Copyright (C) 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,11 +10,12 @@ dnl From Derek Price. # --------------------------------------- # Find the absolute name of a header file, assuming the header exists. # If the header were sys/inttypes.h, this macro would define -# ABSOLUTE_SYS_INTTYPES_H to the `<>' quoted absolute name of sys/inttypes.h +# ABSOLUTE_SYS_INTTYPES_H to the `""' quoted absolute name of sys/inttypes.h # in config.h -# (e.g. `#define ABSOLUTE_SYS_INTTYPES_H '). +# (e.g. `#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"'). # The three "///" are to pacify Sun C 5.8, which otherwise would say # "warning: #include of /usr/include/... may be non-portable". +# Use `""', not `<>', so that the /// cannot be confused with a C99 comment. AC_DEFUN([gl_ABSOLUTE_HEADER], [AC_LANG_PREPROC_REQUIRE()dnl AC_FOREACH([gl_HEADER_NAME], [$1], diff --git a/m4/backupfile.m4 b/m4/backupfile.m4 index 04b2556..6e08f72 100644 --- a/m4/backupfile.m4 +++ b/m4/backupfile.m4 @@ -1,4 +1,4 @@ -# backupfile.m4 serial 10 +# backupfile.m4 serial 11 dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,7 +10,6 @@ AC_DEFUN([gl_BACKUPFILE], AC_LIBOBJ([backupfile]) dnl Prerequisites of lib/backupfile.c. - AC_CHECK_HEADERS_ONCE([dirent.h]) AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO]) AC_REQUIRE([gl_AC_DOS]) AC_REQUIRE([AC_SYS_LONG_FILE_NAMES]) diff --git a/m4/d-ino.m4 b/m4/d-ino.m4 index c86f7bb..d87b4db 100644 --- a/m4/d-ino.m4 +++ b/m4/d-ino.m4 @@ -13,18 +13,12 @@ dnl # with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO], - [AC_CHECK_HEADERS_ONCE([dirent.h])dnl - AC_CACHE_CHECK([for d_ino member in directory struct], + [AC_CACHE_CHECK([for d_ino member in directory struct], jm_cv_struct_dirent_d_ino, [AC_TRY_LINK(dnl [ #include -#ifdef HAVE_DIRENT_H -# include -#else -# define dirent direct -# include -#endif +#include ], [struct dirent dp; dp.d_ino = 0;], diff --git a/m4/d-type.m4 b/m4/d-type.m4 index f4be1ce..7675dd2 100644 --- a/m4/d-type.m4 +++ b/m4/d-type.m4 @@ -13,18 +13,12 @@ dnl # with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE], - [AC_CHECK_HEADERS_ONCE([dirent.h])dnl - AC_CACHE_CHECK([for d_type member in directory struct], + [AC_CACHE_CHECK([for d_type member in directory struct], jm_cv_struct_dirent_d_type, [AC_TRY_LINK(dnl [ #include -#ifdef HAVE_DIRENT_H -# include -#else -# define dirent direct -# include -#endif +#include ], [struct dirent dp; dp.d_type = 0;], diff --git a/m4/dirfd.m4 b/m4/dirfd.m4 index 9e26d52..c377b87 100644 --- a/m4/dirfd.m4 +++ b/m4/dirfd.m4 @@ -1,4 +1,4 @@ -#serial 12 -*- Autoconf -*- +#serial 13 -*- Autoconf -*- dnl Find out how to get the file descriptor associated with an open DIR*. @@ -17,22 +17,16 @@ AC_DEFUN([gl_FUNC_DIRFD], dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57. AC_REQUIRE([AC_PROG_CPP]) AC_REQUIRE([AC_PROG_EGREP]) - AC_CHECK_HEADERS_ONCE([dirent.h])dnl - - dirfd_headers=' -#if HAVE_DIRENT_H -# include -#else -# define dirent direct -# include -#endif -' AC_CHECK_FUNCS(dirfd) - AC_CHECK_DECLS([dirfd], , , $dirfd_headers) + AC_CHECK_DECLS([dirfd], , , + [#include + #include ]) AC_CACHE_CHECK([whether dirfd is a macro], gl_cv_func_dirfd_macro, - [AC_EGREP_CPP([dirent_header_defines_dirfd], [$dirfd_headers + [AC_EGREP_CPP([dirent_header_defines_dirfd], [ +#include +#include #ifdef dirfd dirent_header_defines_dirfd #endif], @@ -53,8 +47,8 @@ AC_DEFUN([gl_FUNC_DIRFD], CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr" AC_TRY_COMPILE( - [$dirfd_headers - ], + [#include + #include ], [DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;], dir_fd_found=yes ) diff --git a/m4/fts.m4 b/m4/fts.m4 index 74595e3..ebb2498 100644 --- a/m4/fts.m4 +++ b/m4/fts.m4 @@ -1,4 +1,4 @@ -#serial 8 +#serial 10 dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -30,5 +30,5 @@ AC_DEFUN([gl_FUNC_FTS_CORE], AC_REQUIRE([gl_FUNC_OPENAT]) # Checks for header files. - AC_CHECK_HEADERS_ONCE([dirent.h sys/param.h])dnl + AC_CHECK_HEADERS_ONCE([sys/param.h])dnl ]) diff --git a/m4/getcwd.m4 b/m4/getcwd.m4 index 730ed42..2a19a08 100644 --- a/m4/getcwd.m4 +++ b/m4/getcwd.m4 @@ -61,7 +61,6 @@ AC_DEFUN([gl_FUNC_GETCWD], AC_DEFUN([gl_PREREQ_GETCWD], [ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_CHECK_HEADERS_ONCE([dirent.h])dnl AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO]) : ]) diff --git a/m4/savedir.m4 b/m4/savedir.m4 index e207123..b6968eb 100644 --- a/m4/savedir.m4 +++ b/m4/savedir.m4 @@ -1,4 +1,4 @@ -# savedir.m4 serial 7 +# savedir.m4 serial 8 dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -8,7 +8,4 @@ AC_DEFUN([gl_SAVEDIR], [ AC_LIBSOURCES([savedir.c, savedir.h]) AC_LIBOBJ([savedir]) - - dnl Prerequisites of lib/savedir.c. - AC_CHECK_HEADERS_ONCE([dirent.h])dnl ]) -- 2.7.4