Mercurial > hg > octave-lyh > gnulib-hg
changeset 10664:3eb22f9808e0
Move the lchmod() declaration to <sys/stat.h>.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 19 Oct 2008 12:50:40 +0200 |
parents | 2b0380d48ff6 |
children | 5394a3a10398 |
files | ChangeLog NEWS lib/dirchownmod.c lib/lchmod.h lib/sys_stat.in.h m4/lchmod.m4 m4/sys_stat_h.m4 modules/lchmod modules/sys_stat |
diffstat | 9 files changed, 76 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2008-10-18 Bruno Haible <bruno@clisp.org> + + * lib/dirchownmod.c: Don't include lchmod.h. + + Move the lchmod() declaration to <sys/stat.h>. + * lib/lchmod.h: Remove file. + * lib/sys_stat.in.h: Add placeholder for GL_LINK_WARNING. + (lchmod): New declaration, moved here from lib/lchown.h. + * m4/lchmod.m4 (gl_FUNC_LCHMOD): Require gl_SYS_STAT_H_DEFAULTS and + AC_USE_SYSTEM_EXTENSIONS. Set HAVE_LCHMOD. + * m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Initialize GNULIB_LCHMOD + and HAVE_LCHMOD. + * modules/lchmod (Files): Remove lib/lchmod.h. + (Depends-on): Add sys_stat, extensions. + (configure.ac): Invoke gl_SYS_STAT_MODULE_INDICATOR. + (Include): Specify <sys/stat.h> instead of lchmod.h. + * modules/sys_stat (Depends-on): Add link-warning. + (Makefile.am): Substitute GNULIB_LCHMOD, HAVE_LCHMOD, and the + definition of GL_LINK_WARNING. + * NEWS: Mention the change. + 2008-10-18 Bruno Haible <bruno@clisp.org> * lib/fchdir.c: Don't include dirfd.h.
--- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ Date Modules Changes +2008-10-18 lchmod The include file is changed from "lchmod.h" to + <sys/stat.h>. + 2008-10-18 dirfd The include file is changed from "dirfd.h" to <dirent.h>.
--- a/lib/dirchownmod.c +++ b/lib/dirchownmod.c @@ -1,6 +1,6 @@ /* Change the ownership and mode bits of a directory. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 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 @@ -26,7 +26,6 @@ #include <sys/stat.h> #include <unistd.h> -#include "lchmod.h" #include "stat-macros.h" #ifndef HAVE_FCHMOD
deleted file mode 100644 --- a/lib/lchmod.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Provide a replacement for lchmod on hosts that lack it. - - 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/>. */ - -/* Written by Paul Eggert. */ - -#include <sys/types.h> -#include <sys/stat.h> - -#ifndef HAVE_LCHMOD - -/* The lchmod replacement follows symbolic links. Callers should take - this into account; lchmod should be applied only to arguments that - are known to not be symbolic links. On hosts that lack lchmod, - this can lead to race conditions between the check and the - invocation of lchmod, but we know of no workarounds that are - reliable in general. You might try requesting support for lchmod - from your operating system supplier. */ - -# define lchmod chmod -#endif
--- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h @@ -1,5 +1,5 @@ /* Provide a more complete sys/stat header file. - Copyright (C) 2006-2008 Free Software Foundation, Inc. + Copyright (C) 2005-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 @@ -33,6 +33,8 @@ #ifndef _GL_SYS_STAT_H #define _GL_SYS_STAT_H +/* The definition of GL_LINK_WARNING is copied here. */ + /* Before doing "#define mkdir rpl_mkdir" below, we need to include all headers that may declare mkdir(). */ #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ @@ -291,5 +293,32 @@ # endif #endif + +/* Declare BSD extensions. */ + +#if @GNULIB_LCHMOD@ +/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME + denotes a symbolic link. */ +# if !@HAVE_LCHMOD@ +/* The lchmod replacement follows symbolic links. Callers should take + this into account; lchmod should be applied only to arguments that + are known to not be symbolic links. On hosts that lack lchmod, + this can lead to race conditions between the check and the + invocation of lchmod, but we know of no workarounds that are + reliable in general. You might try requesting support for lchmod + from your operating system supplier. */ +# define lchmod chmod +# endif +# if 0 /* assume already declared */ +extern int lchmod (const char *filename, mode_t mode); +# endif +#elif defined GNULIB_POSIXCHECK +# undef lchmod +# define lchmod(f,m) \ + (GL_LINK_WARNING ("lchmod is unportable - " \ + "use gnulib module lchmod for portability"), \ + lchmod (f, m)) +#endif + #endif /* _GL_SYS_STAT_H */ #endif /* _GL_SYS_STAT_H */
--- a/m4/lchmod.m4 +++ b/m4/lchmod.m4 @@ -1,6 +1,6 @@ -#serial 2 +#serial 3 -dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 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, dnl with or without modifications, as long as this notice is preserved. @@ -10,5 +10,13 @@ AC_DEFUN([gl_FUNC_LCHMOD], [ + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + + dnl Persuade glibc <sys/stat.h> to declare lchmod(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_FUNCS_ONCE([lchmod]) + if test $ac_cv_func_lchmod = no; then + HAVE_LCHMOD=0 + fi ])
--- a/m4/sys_stat_h.m4 +++ b/m4/sys_stat_h.m4 @@ -1,4 +1,4 @@ -# sys_stat_h.m4 serial 8 -*- Autoconf -*- +# sys_stat_h.m4 serial 9 -*- 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, @@ -50,6 +50,8 @@ AC_DEFUN([gl_SYS_STAT_H_DEFAULTS], [ + GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD]) dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD]) REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR]) ])
--- a/modules/lchmod +++ b/modules/lchmod @@ -2,18 +2,20 @@ lchmod that is actually chmod (!) on hosts lacking lchmod Files: -lib/lchmod.h m4/lchmod.m4 Depends-on: +sys_stat +extensions configure.ac: gl_FUNC_LCHMOD +gl_SYS_STAT_MODULE_INDICATOR([lchmod]) Makefile.am: Include: -"lchmod.h" +<sys/stat.h> License: GPL
--- a/modules/sys_stat +++ b/modules/sys_stat @@ -7,6 +7,7 @@ Depends-on: include_next +link-warning configure.ac: gl_HEADER_SYS_STAT_H @@ -24,8 +25,11 @@ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -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|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \ -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/sys_stat.in.h; \ } > $@-t mv $@-t $@