Mercurial > hg > octave-lyh > gnulib-hg
changeset 10688:989b49566cae
Move the lstat() declaration to <sys/stat.h>.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Tue, 21 Oct 2008 01:05:43 +0200 |
parents | 8ddeb7137f43 |
children | 5fbf24129e48 |
files | ChangeLog NEWS lib/fts.c lib/lstat.c lib/lstat.h lib/openat.c lib/sys_stat.in.h m4/lstat.m4 m4/sys_stat_h.m4 modules/lstat modules/sys_stat |
diffstat | 11 files changed, 74 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2008-10-20 Bruno Haible <bruno@clisp.org> + + * lib/fts.c: Don't include lstat.h. + * lib/openat.c: Include <sys/stat.h> instead of lstat.h. + + Move the lstat() declaration to <sys/stat.h>. + * 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 <sys/stat.h> instead of lstat.h. + * modules/sys_stat (Makefile.am): Substitute GNULIB_LSTAT and + REPLACE_LSTAT. + * NEWS: Mention the change. + 2008-10-20 Bruno Haible <bruno@clisp.org> * modules/posix_spawn-tests: New file.
--- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ Date Modules Changes +2008-10-20 lstat The include file is changed from "lstat.h" to + <sys/stat.h>. + 2008-10-20 getaddrinfo The include file is changed from "getaddrinfo.h" to <netdb.h>.
--- a/lib/fts.c +++ b/lib/fts.c @@ -69,7 +69,6 @@ #if ! _LIBC # include "fcntl--.h" -# include "lstat.h" # include "openat.h" # include "unistd--.h" # include "same-inode.h"
--- 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 <config.h> -/* 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 <sys/types.h> #include <sys/stat.h> +#undef __need_system_sys_stat_h + +static inline int +orig_lstat (const char *filename, struct stat *buf) +{ + return lstat (filename, buf); +} + +/* Specification. */ +#include <sys/stat.h> + #include <string.h> #include <errno.h> @@ -47,7 +54,7 @@ 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;
deleted file mode 100644 --- 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 <http://www.gnu.org/licenses/>. */ - -#include <sys/stat.h> - -#if !LSTAT_FOLLOWS_SLASHED_SYMLINK -extern int rpl_lstat (const char *name, struct stat *buf); -# undef lstat -# define lstat rpl_lstat -#endif
--- 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 <stdarg.h> #include <stddef.h> +#include <sys/stat.h> #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"
--- 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 @@ #endif /* _GL_SYS_STAT_H */ #endif /* _GL_SYS_STAT_H */ +#endif
--- 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 @@ 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]) : ])
--- 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_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]) ])
--- a/modules/lstat +++ b/modules/lstat @@ -3,7 +3,6 @@ Files: lib/lstat.c -lib/lstat.h m4/lstat.m4 Depends-on: @@ -11,11 +10,12 @@ configure.ac: gl_FUNC_LSTAT +gl_SYS_STAT_MODULE_INDICATOR([lstat]) Makefile.am: Include: -"lstat.h" +<sys/stat.h> License: LGPL
--- a/modules/sys_stat +++ b/modules/sys_stat @@ -26,8 +26,10 @@ -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; \