diff options
author | Bruno Haible <bruno@clisp.org> | 2008-10-19 12:47:52 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2008-10-19 12:47:52 +0200 |
commit | 2cf6b078ffb5955943be20eec0a1d6742b118c5e (patch) | |
tree | c4e0c192f121d65c81c346744d361fa4421e03e1 | |
parent | cded3d983ba2d3e0c76bc1c721c78333fa31b385 (diff) | |
download | gnulib-2cf6b078ffb5955943be20eec0a1d6742b118c5e.tar.gz |
Move the dirfd() declaration to <dirent.h>.
-rw-r--r-- | ChangeLog | 26 | ||||
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | lib/dirent.in.h | 20 | ||||
-rw-r--r-- | lib/dirfd.c | 4 | ||||
-rw-r--r-- | lib/dirfd.h | 28 | ||||
-rw-r--r-- | lib/fchdir.c | 3 | ||||
-rw-r--r-- | lib/fts.c | 1 | ||||
-rw-r--r-- | lib/getcwd.c | 4 | ||||
-rw-r--r-- | lib/glob.c | 4 | ||||
-rw-r--r-- | m4/dirent_h.m4 | 6 | ||||
-rw-r--r-- | m4/dirfd.m4 | 14 | ||||
-rw-r--r-- | modules/dirent | 4 | ||||
-rw-r--r-- | modules/dirfd | 6 |
13 files changed, 76 insertions, 47 deletions
@@ -1,5 +1,31 @@ 2008-10-18 Bruno Haible <bruno@clisp.org> + * lib/fchdir.c: Don't include dirfd.h. + * lib/fts.c: Likewise. + * lib/getcwd.c: Likewise. + * lib/glob.c: Likewise. + + Move the dirfd() declaration to <dirent.h>. + * lib/dirfd.h: Remove file. + * lib/dirent.in.h: Add placeholder for GL_LINK_WARNING. + (dirfd): New declaration. + * lib/dirfd.c: Include <dirent.h> instead of dirfd.h. + * m4/dirfd.m4 (gl_FUNC_DIRFD): Require gl_DIRENT_H_DEFAULTS and + AC_USE_SYSTEM_EXTENSIONS. Invoke gl_REPLACE_DIRENT_H. Set + HAVE_DECL_DIRFD. + * m4/dirent_h.m4 (gl_DIRENT_H_DEFAULTS): Initialize GNULIB_DIRFD and + HAVE_DECL_DIRFD. + * modules/dirfd (Files): Remove lib/dirfd.h. + (Depends-on): Add dirent, extensions. + (configure.ac): Invoke gl_DIRENT_MODULE_INDICATOR. + (Include): Specify <dirent.h> instead of dirfd.h. + * modules/dirent (Depends-on): Add link-warning. + (Makefile.am): Substitute GNULIB_DIRFD, HAVE_DECL_DIRFD, and + definition of GL_LINK_WARNING. + * NEWS: Mention the change. + +2008-10-18 Bruno Haible <bruno@clisp.org> + Move the euidaccess() declaration to <unistd.h>. * lib/euidaccess.h: Remove file. * lib/unistd.in.h (euidaccess): New declaration. @@ -6,6 +6,9 @@ User visible incompatible changes Date Modules Changes +2008-10-18 dirfd The include file is changed from "dirfd.h" to + <dirent.h>. + 2008-10-18 euidaccess The include file is changed from "euidaccess.h" to <unistd.h>. diff --git a/lib/dirent.in.h b/lib/dirent.in.h index 170a2fda2b..2b1d0a52a2 100644 --- a/lib/dirent.in.h +++ b/lib/dirent.in.h @@ -26,13 +26,15 @@ #ifndef _GL_DIRENT_H #define _GL_DIRENT_H +/* The definition of GL_LINK_WARNING is copied here. */ -/* Declare overridden functions. */ #ifdef __cplusplus extern "C" { #endif +/* Declare overridden functions. */ + #if @REPLACE_FCHDIR@ # define opendir rpl_opendir extern DIR * opendir (const char *); @@ -40,6 +42,22 @@ extern DIR * opendir (const char *); extern int closedir (DIR *); #endif +/* Declare GNU extensions. */ + +#if @GNULIB_DIRFD@ +# if !@HAVE_DECL_DIRFD@ && !defined dirfd +/* Return the file descriptor associated with the given directory stream, + or -1 if none exists. */ +extern int dirfd (DIR const *dir); +# endif +#elif defined GNULIB_POSIXCHECK +# undef dirfd +# define dirfd(d) \ + (GL_LINK_WARNING ("dirfd is unportable - " \ + "use gnulib module dirfd for portability"), \ + dirfd (d)) +#endif + #ifdef __cplusplus } #endif diff --git a/lib/dirfd.c b/lib/dirfd.c index 18f5154a06..3458e99b20 100644 --- a/lib/dirfd.c +++ b/lib/dirfd.c @@ -1,6 +1,6 @@ /* dirfd.c -- return the file descriptor associated with an open DIR* - Copyright (C) 2001, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2006, 2008 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ #include <config.h> -#include "dirfd.h" +#include <dirent.h> int dirfd (DIR const *dir_p) diff --git a/lib/dirfd.h b/lib/dirfd.h deleted file mode 100644 index 2c2b21d235..0000000000 --- a/lib/dirfd.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Declare dirfd, if necessary. - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - Written by Jim Meyering. */ - -#include <sys/types.h> - -#include <dirent.h> - -#ifndef HAVE_DECL_DIRFD -"this configure-time declaration test was not run" -#endif -#if !HAVE_DECL_DIRFD && !defined dirfd -int dirfd (DIR const *); -#endif diff --git a/lib/fchdir.c b/lib/fchdir.c index 84d6546879..969e984c95 100644 --- a/lib/fchdir.c +++ b/lib/fchdir.c @@ -19,6 +19,7 @@ /* Specification. */ #include <unistd.h> +#include <dirent.h> #include <errno.h> #include <fcntl.h> #include <stdarg.h> @@ -26,10 +27,8 @@ #include <string.h> #include <sys/types.h> #include <sys/stat.h> -#include <dirent.h> #include "canonicalize.h" -#include "dirfd.h" /* This replacement assumes that a directory is not renamed while opened through a file descriptor. */ @@ -62,7 +62,6 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; #endif #include <fcntl.h> #include <errno.h> -#include "dirfd.h" #include <stdbool.h> #include <stdlib.h> #include <string.h> diff --git a/lib/getcwd.c b/lib/getcwd.c index 2397c08c83..b9e57d31a9 100644 --- a/lib/getcwd.c +++ b/lib/getcwd.c @@ -1,5 +1,4 @@ -/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2004,2005,2006,2007 Free Software - Foundation, Inc. +/* Copyright (C) 1991-1999, 2004-2008 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -18,7 +17,6 @@ #if !_LIBC # include <config.h> # include <unistd.h> -# include "dirfd.h" #endif #include <errno.h> diff --git a/lib/glob.c b/lib/glob.c index c38ee4c3dd..40cc9b3de5 100644 --- a/lib/glob.c +++ b/lib/glob.c @@ -153,10 +153,6 @@ #include <fnmatch.h> -#ifndef _LIBC -# include "dirfd.h" -#endif - #ifdef _SC_GETPW_R_SIZE_MAX # define GETPW_R_SIZE_MAX() sysconf (_SC_GETPW_R_SIZE_MAX) #else diff --git a/m4/dirent_h.m4 b/m4/dirent_h.m4 index 93cfbdc1f4..a72fc36297 100644 --- a/m4/dirent_h.m4 +++ b/m4/dirent_h.m4 @@ -1,4 +1,4 @@ -# dirent_h.m4 serial 1 +# dirent_h.m4 serial 2 dnl Copyright (C) 2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -32,6 +32,8 @@ AC_DEFUN([gl_DIRENT_MODULE_INDICATOR], AC_DEFUN([gl_DIRENT_H_DEFAULTS], [ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR + GNULIB_DIRFD=0; AC_SUBST([GNULIB_DIRFD]) dnl Assume proper GNU behavior unless another module says otherwise. - DIRENT_H=''; AC_SUBST([DIRENT_H]) + HAVE_DECL_DIRFD=1; AC_SUBST([HAVE_DECL_DIRFD]) + DIRENT_H=''; AC_SUBST([DIRENT_H]) ]) diff --git a/m4/dirfd.m4 b/m4/dirfd.m4 index 125966b1a0..baab4dddad 100644 --- a/m4/dirfd.m4 +++ b/m4/dirfd.m4 @@ -1,8 +1,8 @@ -#serial 14 -*- Autoconf -*- +#serial 15 -*- Autoconf -*- dnl Find out how to get the file descriptor associated with an open DIR*. -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 Free Software # Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -12,13 +12,23 @@ dnl From Jim Meyering AC_DEFUN([gl_FUNC_DIRFD], [ + AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) + gl_REPLACE_DIRENT_H + + dnl Persuade glibc <dirent.h> to declare dirfd(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + 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_FUNCS(dirfd) AC_CHECK_DECLS([dirfd], , , [#include <sys/types.h> #include <dirent.h>]) + if test $ac_cv_have_decl_dirfd = no; then + HAVE_DECL_DIRFD=0 + fi AC_CACHE_CHECK([whether dirfd is a macro], gl_cv_func_dirfd_macro, diff --git a/modules/dirent b/modules/dirent index baeba57063..bf6063b1f5 100644 --- a/modules/dirent +++ b/modules/dirent @@ -8,6 +8,7 @@ m4/unistd_h.m4 Depends-on: include_next +link-warning configure.ac: gl_DIRENT_H @@ -23,7 +24,10 @@ dirent.h: dirent.in.h sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \ + -e 's|@''GNULIB_DIRFD''@|$(GNULIB_DIRFD)|g' \ + -e 's|@''HAVE_DECL_DIRFD''@|$(HAVE_DECL_DIRFD)|g' \ -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/dirent.in.h; \ } > $@-t mv $@-t $@ diff --git a/modules/dirfd b/modules/dirfd index 6769a7740f..25450bd6e4 100644 --- a/modules/dirfd +++ b/modules/dirfd @@ -2,19 +2,21 @@ Description: Retrieving the file descriptor of an open directory stream. (Unportable.) Files: -lib/dirfd.h lib/dirfd.c m4/dirfd.m4 Depends-on: +dirent +extensions configure.ac: gl_FUNC_DIRFD +gl_DIRENT_MODULE_INDICATOR([dirfd]) Makefile.am: Include: -"dirfd.h" +<dirent.h> License: LGPLv2+ |