Mercurial > hg > octave-nkf > gnulib-hg
changeset 11920:79f4b013feab
chown: avoid compilation warning on mingw
* m4/chown.m4 (gl_FUNC_CHOWN): Recognize missing chown.
* lib/chown.c (rpl_chown) [!HAVE_CHOWN]: Always return failure on
mingw.
* lib/lchown.c (lchown) [!HAVE_CHOWN]: Likewise.
* modules/chown (Depends-on): Add errno.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Mon, 31 Aug 2009 09:00:45 -0600 |
parents | 6a1268d2cf2a |
children | c455cd9841a8 |
files | ChangeLog lib/chown.c lib/lchown.c m4/chown.m4 modules/chown |
diffstat | 5 files changed, 33 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-08-31 Eric Blake <ebb9@byu.net> + + chown: avoid compilation warning on mingw + * m4/chown.m4 (gl_FUNC_CHOWN): Recognize missing chown. + * lib/chown.c (rpl_chown) [!HAVE_CHOWN]: Always return failure on + mingw. + * lib/lchown.c (lchown) [!HAVE_CHOWN]: Likewise. + * modules/chown (Depends-on): Add errno. + 2009-08-31 Stefano Lattarini <stefano.lattarini@gmail.com> (tiny change) * gnulib-tool: Fix test whether $CONFIG_SHELL has a working 'echo'
--- a/lib/chown.c +++ b/lib/chown.c @@ -1,7 +1,7 @@ /* provide consistent interface to chown for systems that don't interpret an ID of -1 as meaning `don't change the corresponding ID'. - Copyright (C) 1997, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1997, 2004-2007, 2009 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 @@ -46,7 +46,8 @@ int rpl_chown (const char *file, uid_t uid, gid_t gid) { -#if CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE +#if HAVE_CHOWN +# if CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE if (gid == (gid_t) -1 || uid == (uid_t) -1) { struct stat file_stats; @@ -61,9 +62,9 @@ if (uid == (uid_t) -1) uid = file_stats.st_uid; } -#endif +# endif -#if CHOWN_MODIFIES_SYMLINK +# if CHOWN_MODIFIES_SYMLINK { /* Handle the case in which the system-supplied chown function does *not* follow symlinks. Instead, it changes permissions @@ -97,7 +98,12 @@ else if (errno != EACCES) return -1; } -#endif +# endif return chown (file, uid, gid); + +#else /* !HAVE_CHOWN */ + errno = EOPNOTSUPP; + return -1; +#endif }
--- a/lib/lchown.c +++ b/lib/lchown.c @@ -1,7 +1,7 @@ /* Provide a stub lchown function for systems that lack it. - Copyright (C) 1998, 1999, 2002, 2004, 2006, 2007 Free Software - Foundation, Inc. + Copyright (C) 1998, 1999, 2002, 2004, 2006, 2007, 2009 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 @@ -48,7 +48,8 @@ int lchown (const char *file, uid_t uid, gid_t gid) { -#if ! CHOWN_MODIFIES_SYMLINK +#if HAVE_CHOWN +# if ! CHOWN_MODIFIES_SYMLINK struct stat stats; if (lstat (file, &stats) == 0 && S_ISLNK (stats.st_mode)) @@ -56,7 +57,12 @@ errno = EOPNOTSUPP; return -1; } -#endif +# endif return chown (file, uid, gid); + +#else /* !HAVE_CHOWN */ + errno = EOPNOTSUPP; + return -1; +#endif }
--- a/m4/chown.m4 +++ b/m4/chown.m4 @@ -1,4 +1,4 @@ -# serial 18 +# serial 19 # Determine whether we need the chown wrapper. dnl Copyright (C) 1997-2001, 2003-2005, 2007, 2009 @@ -20,6 +20,7 @@ AC_REQUIRE([AC_TYPE_UID_T]) AC_REQUIRE([AC_FUNC_CHOWN]) AC_REQUIRE([gl_FUNC_CHOWN_FOLLOWS_SYMLINK]) + AC_CHECK_FUNCS_ONCE([chown]) if test $ac_cv_func_chown_works = no; then AC_DEFINE([CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE], [1],