Mercurial > hg > octave-lyh > gnulib-hg
changeset 11992:a1e0b2efc812
fchdir: improve use of replacement functions
* m4/fchdir.m4 (gl_FUNC_FCHDIR): Set appropriate witnesses.
* m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Add REPLACE_FSTAT.
* m4/dirent_h.m4 (gl_DIRENT_H_DEFAULTS): Add REPLACE_OPENDIR,
REPLACE_CLOSEDIR.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Add REPLACE_DUP.
* modules/sys_stat (Makefile.am): Substitute correct witness.
* modules/dirent (Makefile.am): Likewise.
* modules/unistd (Makefile.am): Likewise.
* lib/dirent.in.h (opendir, closedir): Use better witnesses.
* lib/unistd.in.h (dup): Likewise.
* lib/sys_stat.in.h (fstat): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Tue, 15 Sep 2009 15:54:43 -0600 |
parents | ae216de20fe6 |
children | 767d867147de |
files | ChangeLog lib/dirent.in.h lib/sys_stat.in.h lib/unistd.in.h m4/dirent_h.m4 m4/fchdir.m4 m4/sys_stat_h.m4 m4/unistd_h.m4 modules/dirent modules/sys_stat modules/unistd |
diffstat | 11 files changed, 42 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2009-09-15 Eric Blake <ebb9@byu.net> + fchdir: improve use of replacement functions + * m4/fchdir.m4 (gl_FUNC_FCHDIR): Set appropriate witnesses. + * m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Add REPLACE_FSTAT. + * m4/dirent_h.m4 (gl_DIRENT_H_DEFAULTS): Add REPLACE_OPENDIR, + REPLACE_CLOSEDIR. + * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Add REPLACE_DUP. + * modules/sys_stat (Makefile.am): Substitute correct witness. + * modules/dirent (Makefile.am): Likewise. + * modules/unistd (Makefile.am): Likewise. + * lib/dirent.in.h (opendir, closedir): Use better witnesses. + * lib/unistd.in.h (dup): Likewise. + * lib/sys_stat.in.h (fstat): Likewise. + maint: ignore gnulib-tool temp files * .gitignore: Ignore files created during gnulib-tool --test.
--- a/lib/dirent.in.h +++ b/lib/dirent.in.h @@ -35,15 +35,11 @@ /* Declare overridden functions. */ -#if @REPLACE_FCHDIR@ -# define opendir rpl_opendir -extern DIR * opendir (const char *); +#if @REPLACE_CLOSEDIR@ # define closedir rpl_closedir extern int closedir (DIR *); #endif -/* Declare other POSIX functions. */ - #if @GNULIB_DIRFD@ # if !@HAVE_DECL_DIRFD@ && !defined dirfd /* Return the file descriptor associated with the given directory stream, @@ -75,6 +71,11 @@ fdopendir (f)) #endif +#if @REPLACE_OPENDIR@ +# define opendir rpl_opendir +extern DIR * opendir (const char *); +#endif + #if @GNULIB_SCANDIR@ /* Scan the directory DIR, calling FILTER on each directory entry. Entries for which FILTER returns nonzero are individually malloc'd,
--- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h @@ -369,7 +369,7 @@ mknodat (f, n, m, d)) #endif -#if @REPLACE_FCHDIR@ +#if @REPLACE_FSTAT@ # define fstat rpl_fstat extern int fstat (int fd, struct stat *buf); #endif
--- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -231,6 +231,10 @@ close (f)) #endif +#if @REPLACE_DUP@ +# define dup rpl_dup +extern int dup (int); +#endif #if @GNULIB_DUP2@ # if @REPLACE_DUP2@ @@ -312,7 +316,6 @@ #if @GNULIB_FCHDIR@ # if @REPLACE_FCHDIR@ - /* Change the process' current working directory to the directory on which the given file descriptor is open. Return 0 if successful, otherwise -1 and errno set. @@ -320,9 +323,6 @@ <http://www.opengroup.org/susv3xsh/fchdir.html>. */ extern int fchdir (int /*fd*/); -# define dup rpl_dup -extern int dup (int); - /* Gnulib internal hooks needed to maintain the fchdir metadata. */ extern int _gl_register_fd (int fd, const char *filename); extern void _gl_unregister_fd (int fd);
--- a/m4/dirent_h.m4 +++ b/m4/dirent_h.m4 @@ -1,4 +1,4 @@ -# dirent_h.m4 serial 4 +# dirent_h.m4 serial 5 dnl Copyright (C) 2008-2009 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -41,5 +41,7 @@ HAVE_FDOPENDIR=1; AC_SUBST([HAVE_FDOPENDIR]) HAVE_SCANDIR=1; AC_SUBST([HAVE_SCANDIR]) HAVE_ALPHASORT=1; AC_SUBST([HAVE_ALPHASORT]) + REPLACE_CLOSEDIR=0; AC_SUBST([REPLACE_CLOSEDIR]) + REPLACE_OPENDIR=0; AC_SUBST([REPLACE_OPENDIR]) DIRENT_H=''; AC_SUBST([DIRENT_H]) ])
--- a/m4/fchdir.m4 +++ b/m4/fchdir.m4 @@ -1,4 +1,4 @@ -# fchdir.m4 serial 9 +# fchdir.m4 serial 10 dnl Copyright (C) 2006-2009 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -16,7 +16,13 @@ gl_PREREQ_FCHDIR AC_DEFINE([REPLACE_FCHDIR], [1], [Define to 1 if gnulib's fchdir() replacement is used.]) + dnl We must also replace anything that can manipulate a directory fd, + dnl to keep our bookkeeping up-to-date. We don't have to replace + dnl fstatat, since no platform has fstatat but lacks fchdir. REPLACE_FSTAT=1 + REPLACE_OPENDIR=1 + REPLACE_CLOSEDIR=1 + REPLACE_DUP=1 gl_REPLACE_OPEN gl_REPLACE_CLOSE gl_REPLACE_DUP2
--- a/m4/sys_stat_h.m4 +++ b/m4/sys_stat_h.m4 @@ -1,4 +1,4 @@ -# sys_stat_h.m4 serial 14 -*- Autoconf -*- +# sys_stat_h.m4 serial 15 -*- Autoconf -*- dnl Copyright (C) 2006-2009 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -63,6 +63,7 @@ HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT]) HAVE_MKFIFOAT=1; AC_SUBST([HAVE_MKFIFOAT]) HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT]) + REPLACE_FSTAT=0; AC_SUBST([REPLACE_FSTAT]) REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT]) REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT]) REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR])
--- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 25 +# unistd_h.m4 serial 26 dnl Copyright (C) 2006-2009 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -88,6 +88,7 @@ HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE]) + REPLACE_DUP=0; AC_SUBST([REPLACE_DUP]) REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR]) REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT])
--- a/modules/dirent +++ b/modules/dirent @@ -32,7 +32,8 @@ -e 's|@''HAVE_FDOPENDIR''@|$(HAVE_FDOPENDIR)|g' \ -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \ -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \ - -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ + -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \ + -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/dirent.in.h; \ } > $@-t && \
--- a/modules/sys_stat +++ b/modules/sys_stat @@ -40,7 +40,7 @@ -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \ -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \ -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \ - -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ + -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \ -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \ -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \ -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
--- a/modules/unistd +++ b/modules/unistd @@ -80,6 +80,7 @@ -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ + -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \