From e9e4f97f438cb507be7c24b7624de7ec81e7c2a5 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 21 Oct 2008 01:05:43 +0200 Subject: [PATCH] Move the lstat() declaration to . --- ChangeLog | 22 ++++++++++++++++++++++ NEWS | 3 +++ lib/fts.c | 1 - lib/lstat.c | 23 +++++++++++++++-------- lib/lstat.h | 23 ----------------------- lib/openat.c | 4 ++-- lib/sys_stat.in.h | 19 +++++++++++++++++-- m4/lstat.m4 | 10 ++++++++-- m4/sys_stat_h.m4 | 4 +++- modules/lstat | 4 ++-- modules/sys_stat | 2 ++ 11 files changed, 74 insertions(+), 41 deletions(-) delete mode 100644 lib/lstat.h diff --git a/ChangeLog b/ChangeLog index 54fc51c9c..4b3429dcd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,27 @@ 2008-10-20 Bruno Haible + * lib/fts.c: Don't include lstat.h. + * lib/openat.c: Include instead of lstat.h. + + Move the lstat() declaration to . + * lib/lstat.h: Remove file. + * lib/sys_stat.in.h: Add special invocation convention. + (lstat): New declaration. + * lib/lstat.c (orig_lstat): New function. + (rpl_lstat): Use orig_lstat instead of lstat. + * m4/lstat.m4 (gl_FUNC_LSTAT): Require gl_SYS_STAT_H_DEFAULTS and + AC_C_INLINE. Set REPLACE_LSTAT. + * m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Initialize GNULIB_LSTAT + and REPLACE_LSTAT. + * modules/lstat (Files): Remove lib/lstat.h. + (configure.ac): Invoke gl_SYS_STAT_MODULE_INDICATOR. + (Include): Specify instead of lstat.h. + * modules/sys_stat (Makefile.am): Substitute GNULIB_LSTAT and + REPLACE_LSTAT. + * NEWS: Mention the change. + +2008-10-20 Bruno Haible + * modules/posix_spawn-tests: New file. * tests/test-posix_spawn3.c: New file. diff --git a/NEWS b/NEWS index 8e8931e20..060270536 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ User visible incompatible changes Date Modules Changes +2008-10-20 lstat The include file is changed from "lstat.h" to + . + 2008-10-20 getaddrinfo The include file is changed from "getaddrinfo.h" to . diff --git a/lib/fts.c b/lib/fts.c index 042870620..205486430 100644 --- a/lib/fts.c +++ b/lib/fts.c @@ -69,7 +69,6 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; #if ! _LIBC # include "fcntl--.h" -# include "lstat.h" # include "openat.h" # include "unistd--.h" # include "same-inode.h" diff --git a/lib/lstat.c b/lib/lstat.c index 9dcb4cdc5..3e0727080 100644 --- a/lib/lstat.c +++ b/lib/lstat.c @@ -1,7 +1,6 @@ /* Work around a bug of lstat on some systems - Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free - Software Foundation, Inc. + Copyright (C) 1997-1999, 2000-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 @@ -20,13 +19,21 @@ #include -/* The specification of these functions is in sys_stat.h. But we cannot - include this include file here, because on some systems, a - "#define lstat lstat64" is being used, and sys_stat.h deletes this - definition. */ - +/* Get the original definition of open. It might be defined as a macro. */ +#define __need_system_sys_stat_h #include #include +#undef __need_system_sys_stat_h + +static inline int +orig_lstat (const char *filename, struct stat *buf) +{ + return lstat (filename, buf); +} + +/* Specification. */ +#include + #include #include @@ -47,7 +54,7 @@ int rpl_lstat (const char *file, struct stat *sbuf) { size_t len; - int lstat_result = lstat (file, sbuf); + int lstat_result = orig_lstat (file, sbuf); if (lstat_result != 0 || !S_ISLNK (sbuf->st_mode)) return lstat_result; diff --git a/lib/lstat.h b/lib/lstat.h deleted file mode 100644 index 63b21c89c..000000000 --- a/lib/lstat.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Retrieving information about files. - Copyright (C) 2005 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 . */ - -#include - -#if !LSTAT_FOLLOWS_SLASHED_SYMLINK -extern int rpl_lstat (const char *name, struct stat *buf); -# undef lstat -# define lstat rpl_lstat -#endif diff --git a/lib/openat.c b/lib/openat.c index 73f24b069..0c3267221 100644 --- a/lib/openat.c +++ b/lib/openat.c @@ -1,5 +1,5 @@ /* provide a replacement openat function - Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006, 2007, 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 @@ -22,10 +22,10 @@ #include #include +#include #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ #include "fcntl--.h" -#include "lstat.h" #include "openat-priv.h" #include "save-cwd.h" diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h index fef9dd6cc..aeca760ec 100644 --- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h @@ -21,12 +21,20 @@ incomplete. It is intended to provide definitions and prototypes needed by an application. Start with what the system provides. */ -#ifndef _GL_SYS_STAT_H - #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +#if defined __need_system_sys_stat_h +/* Special invocation convention. */ + +#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _GL_SYS_STAT_H + /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ @@ -272,6 +280,12 @@ #if ! @HAVE_LSTAT@ # define lstat stat #endif +#if @GNULIB_LSTAT@ && @REPLACE_LSTAT@ +# undef lstat +# define lstat rpl_lstat +extern int rpl_lstat (const char *name, struct stat *buf); +#endif + #if @REPLACE_MKDIR@ # undef mkdir @@ -322,3 +336,4 @@ extern int lchmod (const char *filename, mode_t mode); #endif /* _GL_SYS_STAT_H */ #endif /* _GL_SYS_STAT_H */ +#endif diff --git a/m4/lstat.m4 b/m4/lstat.m4 index b9777a6a8..9ac109f67 100644 --- a/m4/lstat.m4 +++ b/m4/lstat.m4 @@ -1,6 +1,6 @@ -#serial 16 +#serial 17 -# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 +# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation @@ -11,7 +11,13 @@ dnl From Jim Meyering. AC_DEFUN([gl_FUNC_LSTAT], [ + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK dnl Note: AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK does AC_LIBOBJ(lstat). + if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then + REPLACE_LSTAT=1 + fi + # Prerequisites of lib/lstat.c. + AC_REQUIRE([AC_C_INLINE]) : ]) diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4 index 3fb6b5c0d..20c82edf9 100644 --- a/m4/sys_stat_h.m4 +++ b/m4/sys_stat_h.m4 @@ -1,4 +1,4 @@ -# sys_stat_h.m4 serial 9 -*- Autoconf -*- +# sys_stat_h.m4 serial 10 -*- Autoconf -*- dnl Copyright (C) 2006-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, @@ -51,7 +51,9 @@ AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR], AC_DEFUN([gl_SYS_STAT_H_DEFAULTS], [ GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD]) + GNULIB_LSTAT=0; AC_SUBST([GNULIB_LSTAT]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD]) + REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT]) REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR]) ]) diff --git a/modules/lstat b/modules/lstat index f2055f916..af416aacf 100644 --- a/modules/lstat +++ b/modules/lstat @@ -3,7 +3,6 @@ lstat() function: return information about a file or symbolic link. Files: lib/lstat.c -lib/lstat.h m4/lstat.m4 Depends-on: @@ -11,11 +10,12 @@ sys_stat configure.ac: gl_FUNC_LSTAT +gl_SYS_STAT_MODULE_INDICATOR([lstat]) Makefile.am: Include: -"lstat.h" + License: LGPL diff --git a/modules/sys_stat b/modules/sys_stat index 84a7f36c1..56a11c247 100644 --- a/modules/sys_stat +++ b/modules/sys_stat @@ -26,8 +26,10 @@ sys/stat.h: sys_stat.in.h -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \ + -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \ -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \ + -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \ -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/sys_stat.in.h; \ -- 2.11.0