summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2004-06-01 20:27:08 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2004-06-01 20:27:08 +0000
commitc4da5fc90ff7ff8ef395c84be4b14e0a3d404cbb (patch)
treeeb102a95303840f938cc59c1aa2841afc95f4eb5
parentfc55c5ccc855a96c977197101ba1d0af02adbb97 (diff)
downloadgnulib-c4da5fc90ff7ff8ef395c84be4b14e0a3d404cbb.tar.gz
Merge from coreutils CVS.
-rw-r--r--ChangeLog4
-rw-r--r--lib/.cppi-disable10
-rw-r--r--lib/.cvsignore5
-rw-r--r--lib/ChangeLog28
-rw-r--r--lib/chown.c40
-rw-r--r--lib/file-type.c1
-rw-r--r--lib/file-type.h140
-rw-r--r--lib/lchown.c10
-rw-r--r--lib/stat-macros.h240
-rw-r--r--lib/xreadlink.c13
-rw-r--r--lib/xreadlink.h5
-rw-r--r--m4/ChangeLog19
-rw-r--r--m4/backupfile.m42
-rw-r--r--m4/chown.m470
-rw-r--r--m4/dirname.m42
-rw-r--r--m4/human.m42
-rw-r--r--m4/inttypes.m44
-rw-r--r--m4/longlong.m42
-rw-r--r--m4/makepath.m42
-rw-r--r--m4/memchr.m42
-rw-r--r--m4/memcmp.m42
-rw-r--r--m4/mountlist.m42
-rw-r--r--m4/path-concat.m42
-rw-r--r--m4/prereq.m46
-rw-r--r--m4/putenv.m42
-rw-r--r--m4/quotearg.m42
-rw-r--r--m4/readutmp.m42
-rw-r--r--m4/strtoimax.m42
-rw-r--r--m4/strtoll.m43
-rw-r--r--m4/strtoull.m43
-rw-r--r--m4/strtoumax.m42
-rw-r--r--m4/ulonglong.m42
-rw-r--r--m4/vasnprintf.m42
-rw-r--r--m4/xstrtol.m42
-rw-r--r--modules/file-type3
35 files changed, 453 insertions, 185 deletions
diff --git a/ChangeLog b/ChangeLog
index ed3b455f30..c6c4242323 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2004-06-01 Paul Eggert <eggert@cs.ucla.edu>
+
+ * modules/file-type: Add lib/stat-macros.h.
+
2004-05-30 Paul Eggert <eggert@cs.ucla.edu>
* modules/hash (Depends-on): Remove malloc, realloc.
diff --git a/lib/.cppi-disable b/lib/.cppi-disable
index fe9d5936a1..9824320cec 100644
--- a/lib/.cppi-disable
+++ b/lib/.cppi-disable
@@ -1,9 +1,15 @@
+alloca_.h
+allocsa.h
error.h
+exit.h
fnmatch.h
+getndelim2.h
getopt.c
getopt.h
getopt1.c
getpagesize.h
+gettext.h
+localcharset.h
md5.h
obstack.h
printf-args.h
@@ -11,5 +17,9 @@ printf-parse.h
regex.c
regex.h
stdbool_.h
+strdup.h
+strndup.h
+strtoul.c
+time_r.h
vasnprintf.h
vasprintf.h
diff --git a/lib/.cvsignore b/lib/.cvsignore
index 3d2ec05a7f..a76f99e8ad 100644
--- a/lib/.cvsignore
+++ b/lib/.cvsignore
@@ -1,9 +1,12 @@
.deps
Makefile
+alloca.h
charset.alias
getdate.c
getdate.tab.c
+fnmatch.h
lstat.c
+poll.h
ref-add.sed
ref-del.sed
safe-lstat.c
@@ -11,4 +14,6 @@ safe-lstat.h
safe-stat.c
safe-stat.h
stat.c
+stdbool.h
+sysexit.h
unlocked-io.h
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 9752f1e763..32b69d2243 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,31 @@
+2004-06-01 Paul Eggert <eggert@cs.ucla.edu>
+ and Jim Meyering <jim@meyering.net>
+
+ Merge from coreutils CVS.
+
+ * stat-macros.h: New file, with contents from file-type.h
+ and coreutils' system.h.
+ * file-type.c: Include "stat-macros.h".
+ * file-type.h (file_type): Move all macro definitions to new file,
+ stat-macros.h.
+
+ * chown.c (rpl_chown) [CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE]:
+ Wrap old code with this conditional.
+ [CHOWN_MODIFIES_SYMLINK]: Try to work around a chown
+ function that does not dereference symlinks.
+ * lchown.c (lchown) [CHOWN_MODIFIES_SYMLINK]: Just call chown.
+
+ * xreadlink.c: Include xreadlink.h first, to catch .h file
+ dependency problems.
+ (xreadlink): Accept new arg SIZE, for efficiency.
+ All decls and uses changed.
+ * xreadlink.h: Include <stddef.h>, for size_t.
+
+ * .cppi-disable: Add alloca_.h, allocsa.h, exit.h, getndelim2.h,
+ gettext.h, localcharset.h, strdup.h, strndup.h, strtoul.c, time_r.h.
+
+ * .cvsignore: Add alloca.h, fnmatch.h, poll.h, stdbool.h, sysexits.h.
+
2004-05-30 Paul Eggert <eggert@cs.ucla.edu>
* xmalloc.c (HAVE_MALLOC, HAVE_REALLOC): Do not require these
diff --git a/lib/chown.c b/lib/chown.c
index 452fdfcac6..460e4f623a 100644
--- a/lib/chown.c
+++ b/lib/chown.c
@@ -1,6 +1,6 @@
/* 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 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2004 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
@@ -30,12 +30,26 @@
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
+#if HAVE_FCNTL_H
+# include <fcntl.h>
+#else
+# include <sys/file.h>
+#endif
+#include <errno.h>
+#ifndef errno
+extern int errno;
+#endif
-/* FIXME: describe. */
+/* Provide a more-closely POSIX-conforming version of chown on
+ systems with one or both of the following problems:
+ - chown doesn't treat an ID of -1 as meaning
+ `don't change the corresponding ID'.
+ - chown doesn't dereference symlinks. */
int
rpl_chown (const char *file, uid_t uid, gid_t gid)
{
+#if CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE
if (gid == (gid_t) -1 || uid == (uid_t) -1)
{
struct stat file_stats;
@@ -50,6 +64,28 @@ rpl_chown (const char *file, uid_t uid, gid_t gid)
if (uid == (uid_t) -1)
uid = file_stats.st_uid;
}
+#endif
+#if CHOWN_MODIFIES_SYMLINK
+ {
+ /* Handle the case in which the system-supplied chown function
+ does *not* follow symlinks. Instead, it changes permissions
+ on the symlink itself. To work around that, we open the
+ file (but this can fail due to lack of read permission) and
+ use fchown on the resulting descriptor. */
+ int fd = open (file, O_RDONLY | O_NONBLOCK | O_NOCTTY);
+ if (fd == -1)
+ return -1;
+ if (fchown (fd, uid, gid))
+ {
+ int saved_errno = errno;
+ close (fd);
+ errno = saved_errno;
+ return -1;
+ }
+ return close (fd);
+ }
+#else
return chown (file, uid, gid);
+#endif
}
diff --git a/lib/file-type.c b/lib/file-type.c
index 3c58c7fb06..6c25e77ba3 100644
--- a/lib/file-type.c
+++ b/lib/file-type.c
@@ -25,6 +25,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "file-type.h"
+#include "stat-macros.h"
#include <gettext.h>
#define _(text) gettext (text)
diff --git a/lib/file-type.h b/lib/file-type.h
index 502f091635..afe2f9444f 100644
--- a/lib/file-type.h
+++ b/lib/file-type.h
@@ -21,146 +21,6 @@
#ifndef FILE_TYPE_H
# define FILE_TYPE_H 1
-# if ! defined S_ISREG && ! defined S_IFREG
-you must include <sys/stat.h> before including this file
-# endif
-
char const *file_type (struct stat const *);
-# ifndef S_IFMT
-# define S_IFMT 0170000
-# endif
-
-# if STAT_MACROS_BROKEN
-# undef S_ISBLK
-# undef S_ISCHR
-# undef S_ISDIR
-# undef S_ISDOOR
-# undef S_ISFIFO
-# undef S_ISLNK
-# undef S_ISNAM
-# undef S_ISMPB
-# undef S_ISMPC
-# undef S_ISNWK
-# undef S_ISREG
-# undef S_ISSOCK
-# endif
-
-
-# ifndef S_ISBLK
-# ifdef S_IFBLK
-# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
-# else
-# define S_ISBLK(m) 0
-# endif
-# endif
-
-# ifndef S_ISCHR
-# ifdef S_IFCHR
-# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
-# else
-# define S_ISCHR(m) 0
-# endif
-# endif
-
-# ifndef S_ISDIR
-# ifdef S_IFDIR
-# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-# else
-# define S_ISDIR(m) 0
-# endif
-# endif
-
-# ifndef S_ISDOOR /* Solaris 2.5 and up */
-# ifdef S_IFDOOR
-# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
-# else
-# define S_ISDOOR(m) 0
-# endif
-# endif
-
-# ifndef S_ISFIFO
-# ifdef S_IFIFO
-# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
-# else
-# define S_ISFIFO(m) 0
-# endif
-# endif
-
-# ifndef S_ISLNK
-# ifdef S_IFLNK
-# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
-# else
-# define S_ISLNK(m) 0
-# endif
-# endif
-
-# ifndef S_ISMPB /* V7 */
-# ifdef S_IFMPB
-# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
-# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
-# else
-# define S_ISMPB(m) 0
-# define S_ISMPC(m) 0
-# endif
-# endif
-
-# ifndef S_ISNAM /* Xenix */
-# ifdef S_IFNAM
-# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
-# else
-# define S_ISNAM(m) 0
-# endif
-# endif
-
-# ifndef S_ISNWK /* HP/UX */
-# ifdef S_IFNWK
-# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
-# else
-# define S_ISNWK(m) 0
-# endif
-# endif
-
-# ifndef S_ISREG
-# ifdef S_IFREG
-# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
-# else
-# define S_ISREG(m) 0
-# endif
-# endif
-
-# ifndef S_ISSOCK
-# ifdef S_IFSOCK
-# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
-# else
-# define S_ISSOCK(m) 0
-# endif
-# endif
-
-
-# ifndef S_TYPEISMQ
-# define S_TYPEISMQ(p) 0
-# endif
-
-# ifndef S_TYPEISTMO
-# define S_TYPEISTMO(p) 0
-# endif
-
-
-# ifndef S_TYPEISSEM
-# ifdef S_INSEM
-# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
-# else
-# define S_TYPEISSEM(p) 0
-# endif
-# endif
-
-# ifndef S_TYPEISSHM
-# ifdef S_INSHD
-# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
-# else
-# define S_TYPEISSHM(p) 0
-# endif
-# endif
-
#endif /* FILE_TYPE_H */
diff --git a/lib/lchown.c b/lib/lchown.c
index 073e00419a..37320fb84b 100644
--- a/lib/lchown.c
+++ b/lib/lchown.c
@@ -1,5 +1,5 @@
/* Provide a stub lchown function for systems that lack it.
- Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2002, 2004 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
@@ -44,11 +44,16 @@ extern int errno;
int chown ();
/* Work just like chown, except when FILE is a symbolic link.
- In that case, set errno to ENOSYS and return -1. */
+ In that case, set errno to ENOSYS and return -1.
+ But if autoconf tests determined that chown modifies
+ symlinks, then just call chown. */
int
lchown (const char *file, uid_t uid, gid_t gid)
{
+#if CHOWN_MODIFIES_SYMLINK
+ return chown (file, uid, gid);
+#else
struct stat stats;
if (lstat (file, &stats) == 0 && S_ISLNK (stats.st_mode))
@@ -58,4 +63,5 @@ lchown (const char *file, uid_t uid, gid_t gid)
}
return chown (file, uid, gid);
+#endif
}
diff --git a/lib/stat-macros.h b/lib/stat-macros.h
new file mode 100644
index 0000000000..69218f43aa
--- /dev/null
+++ b/lib/stat-macros.h
@@ -0,0 +1,240 @@
+/* stat-related macros
+
+ Copyright (C) 1993, 1994, 2001, 2002, 2004 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 2, 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, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Written by Paul Eggert and Jim Meyering. */
+
+#ifndef STAT_MACROS_H
+# define STAT_MACROS_H 1
+
+# if ! defined S_ISREG && ! defined S_IFREG
+# error "you must include <sys/stat.h> before including this file"
+# endif
+
+# ifndef S_IFMT
+# define S_IFMT 0170000
+# endif
+
+# if STAT_MACROS_BROKEN
+# undef S_ISBLK
+# undef S_ISCHR
+# undef S_ISDIR
+# undef S_ISDOOR
+# undef S_ISFIFO
+# undef S_ISLNK
+# undef S_ISNAM
+# undef S_ISMPB
+# undef S_ISMPC
+# undef S_ISNWK
+# undef S_ISREG
+# undef S_ISSOCK
+# endif
+
+
+# ifndef S_ISBLK
+# ifdef S_IFBLK
+# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
+# else
+# define S_ISBLK(m) 0
+# endif
+# endif
+
+# ifndef S_ISCHR
+# ifdef S_IFCHR
+# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
+# else
+# define S_ISCHR(m) 0
+# endif
+# endif
+
+# ifndef S_ISDIR
+# ifdef S_IFDIR
+# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+# else
+# define S_ISDIR(m) 0
+# endif
+# endif
+
+# ifndef S_ISDOOR /* Solaris 2.5 and up */
+# ifdef S_IFDOOR
+# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
+# else
+# define S_ISDOOR(m) 0
+# endif
+# endif
+
+# ifndef S_ISFIFO
+# ifdef S_IFIFO
+# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+# else
+# define S_ISFIFO(m) 0
+# endif
+# endif
+
+# ifndef S_ISLNK
+# ifdef S_IFLNK
+# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+# else
+# define S_ISLNK(m) 0
+# endif
+# endif
+
+# ifndef S_ISMPB /* V7 */
+# ifdef S_IFMPB
+# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
+# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
+# else
+# define S_ISMPB(m) 0
+# define S_ISMPC(m) 0
+# endif
+# endif
+
+# ifndef S_ISNAM /* Xenix */
+# ifdef S_IFNAM
+# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
+# else
+# define S_ISNAM(m) 0
+# endif
+# endif
+
+# ifndef S_ISNWK /* HP/UX */
+# ifdef S_IFNWK
+# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
+# else
+# define S_ISNWK(m) 0
+# endif
+# endif
+
+# ifndef S_ISREG
+# ifdef S_IFREG
+# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+# else
+# define S_ISREG(m) 0
+# endif
+# endif
+
+# ifndef S_ISSOCK
+# ifdef S_IFSOCK
+# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
+# else
+# define S_ISSOCK(m) 0
+# endif
+# endif
+
+
+# ifndef S_TYPEISMQ
+# define S_TYPEISMQ(p) 0
+# endif
+
+# ifndef S_TYPEISTMO
+# define S_TYPEISTMO(p) 0
+# endif
+
+
+# ifndef S_TYPEISSEM
+# ifdef S_INSEM
+# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
+# else
+# define S_TYPEISSEM(p) 0
+# endif
+# endif
+
+# ifndef S_TYPEISSHM
+# ifdef S_INSHD
+# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
+# else
+# define S_TYPEISSHM(p) 0
+# endif
+# endif
+
+/* If any of the following are undefined,
+ define them to their de facto standard values. */
+# if !S_ISUID
+# define S_ISUID 04000
+# endif
+# if !S_ISGID
+# define S_ISGID 02000
+# endif
+
+/* S_ISVTX is a common extension to POSIX. */
+# ifndef S_ISVTX
+# define S_ISVTX 01000
+# endif
+
+# if !S_IRUSR && S_IREAD
+# define S_IRUSR S_IREAD
+# endif
+# if !S_IRUSR
+# define S_IRUSR 00400
+# endif
+# if !S_IRGRP
+# define S_IRGRP (S_IRUSR >> 3)
+# endif
+# if !S_IROTH
+# define S_IROTH (S_IRUSR >> 6)
+# endif
+
+# if !S_IWUSR && S_IWRITE
+# define S_IWUSR S_IWRITE
+# endif
+# if !S_IWUSR
+# define S_IWUSR 00200
+# endif
+# if !S_IWGRP
+# define S_IWGRP (S_IWUSR >> 3)
+# endif
+# if !S_IWOTH
+# define S_IWOTH (S_IWUSR >> 6)
+# endif
+
+# if !S_IXUSR && S_IEXEC
+# define S_IXUSR S_IEXEC
+# endif
+# if !S_IXUSR
+# define S_IXUSR 00100
+# endif
+# if !S_IXGRP
+# define S_IXGRP (S_IXUSR >> 3)
+# endif
+# if !S_IXOTH
+# define S_IXOTH (S_IXUSR >> 6)
+# endif
+
+# if !S_IRWXU
+# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
+# endif
+# if !S_IRWXG
+# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
+# endif
+# if !S_IRWXO
+# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
+# endif
+
+/* S_IXUGO is a common extension to POSIX. */
+# if !S_IXUGO
+# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
+# endif
+
+# ifndef S_IRWXUGO
+# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
+# endif
+
+/* All the mode bits that can be affected by chmod. */
+# define CHMOD_MODE_BITS \
+ (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
+
+#endif /* STAT_MACROS_H */
diff --git a/lib/xreadlink.c b/lib/xreadlink.c
index 3473578976..41f5242ea4 100644
--- a/lib/xreadlink.c
+++ b/lib/xreadlink.c
@@ -1,6 +1,6 @@
/* xreadlink.c -- readlink wrapper to return the link name in malloc'd storage
- Copyright (C) 2001, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2004 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
@@ -23,6 +23,8 @@
# include <config.h>
#endif
+#include "xreadlink.h"
+
#include <stdio.h>
#include <errno.h>
#ifndef errno
@@ -44,20 +46,21 @@ extern int errno;
#endif
#include "xalloc.h"
-#include "xreadlink.h"
/* Call readlink to get the symbolic link value of FILENAME.
+ SIZE is a hint as to how long the link is expected to be;
+ typically it is taken from st_size. It need not be correct.
Return a pointer to that NUL-terminated string in malloc'd storage.
If readlink fails, return NULL (caller may use errno to diagnose).
If malloc fails, or if the link value is longer than SSIZE_MAX :-),
give a diagnostic and exit. */
char *
-xreadlink (char const *filename)
+xreadlink (char const *filename, size_t size)
{
/* The initial buffer size for the link value. A power of 2
detects arithmetic overflow earlier, but is not required. */
- size_t buf_size = 128;
+ size_t buf_size = size + 1;
while (1)
{
@@ -80,7 +83,7 @@ xreadlink (char const *filename)
free (buffer);
buf_size *= 2;
- if (SSIZE_MAX < buf_size || (SIZE_MAX / 2 < SSIZE_MAX && buf_size == 0))
+ if (! (0 < buf_size && buf_size <= SSIZE_MAX))
xalloc_die ();
}
}
diff --git a/lib/xreadlink.h b/lib/xreadlink.h
index d9441215f3..5b2604bfea 100644
--- a/lib/xreadlink.h
+++ b/lib/xreadlink.h
@@ -1,6 +1,6 @@
/* readlink wrapper to return the link name in malloc'd storage
- Copyright (C) 2001, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2004 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
@@ -19,4 +19,5 @@
/* Written by Jim Meyering <jim@meyering.net> */
-char *xreadlink (char const *);
+#include <stddef.h>
+char *xreadlink (char const *, size_t);
diff --git a/m4/ChangeLog b/m4/ChangeLog
index 0a3af01bd0..e310404895 100644
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -1,3 +1,22 @@
+2004-06-01 Paul Eggert <eggert@cs.ucla.edu>
+
+ Merge from coreutils CVS.
+
+ * backupfile.m4, dirname.m4, human.m4, inttypes.m4, longlong.m4,
+ makepath.m4, memchr.m4, memcmp.m4, mountlist.m4, path-concat.m4,
+ putenv.m4, quotearg.m4, readutmp.m4, strtoimax.m4, strtoll.m4,
+ strtoull.m4, strtoumax.m4, ulonglong.m4, vasnprintf.m4,
+ xstrtol.m4: Fix copyright date and/or serial number.
+
+ * chown.m4 (gl_PREREQ_CHOWN): Check for fcntl.h.
+ See if we need an fchown replacement.
+ (gl_FUNC_CHOWN_FOLLOWS_SYMLINK): New macro.
+ (gl_FUNC_CHOWN): Require gl_FUNC_CHOWN_FOLLOWS_SYMLINK,
+ and use the replacement function if we detect either defect.
+
+ * prereq.m4 (gl_PREREQ): Add gl_ALLOCSA, gl_CLOEXEC, gl_INTTOSTR,
+ gl_UTIMECMP.
+
2004-05-31 Paul Eggert <eggert@cs.ucla.edu>
* stdbool.m4 (AC_HEADER_STDBOOL): Detect _Bool bug in HP aC++/ANSI
diff --git a/m4/backupfile.m4 b/m4/backupfile.m4
index 4f7e43f28e..1d9cbe1418 100644
--- a/m4/backupfile.m4
+++ b/m4/backupfile.m4
@@ -1,5 +1,5 @@
# backupfile.m4 serial 4
-dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/chown.m4 b/m4/chown.m4
index f723cb5765..430bc8073a 100644
--- a/m4/chown.m4
+++ b/m4/chown.m4
@@ -1,15 +1,24 @@
-#serial 9
-
-dnl From Jim Meyering.
-dnl Determine whether chown accepts arguments of -1 for uid and gid.
-dnl If it doesn't, arrange to use the replacement function.
-dnl
+#serial 10
+# Determine whether we need the chown wrapper. chown should accept
+# arguments of -1 for uid and gid, and it should dereference symlinks.
+# If it doesn't, arrange to use the replacement function.
+# From Jim Meyering.
AC_DEFUN([gl_FUNC_CHOWN],
[
- AC_REQUIRE([AC_TYPE_UID_T])dnl
+ AC_REQUIRE([AC_TYPE_UID_T])
AC_REQUIRE([AC_FUNC_CHOWN])
- if test $ac_cv_func_chown_works = no; then
+ AC_REQUIRE([gl_FUNC_CHOWN_FOLLOWS_SYMLINK])
+
+ if test $ac_cv_func_chown_works = yes; then
+ AC_DEFINE(CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE, 1,
+ [Define if chown is not POSIX compliant regarding IDs of -1.])
+ fi
+
+ # If chown has either of the above problems, then we need the wrapper.
+ if test $ac_cv_func_chown_works$gl_cv_func_chown_follows_symlink = yesyes; then
+ : # no wrapper needed
+ else
AC_LIBOBJ(chown)
AC_DEFINE(chown, rpl_chown,
[Define to rpl_chown if the replacement function should be used.])
@@ -17,8 +26,51 @@ AC_DEFUN([gl_FUNC_CHOWN],
fi
])
+# Determine whether chown follows symlinks (it should).
+AC_DEFUN([gl_FUNC_CHOWN_FOLLOWS_SYMLINK],
+[
+ AC_CACHE_CHECK(
+ [whether chown(2) dereferences symlinks],
+ gl_cv_func_chown_follows_symlink,
+ [
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <stdlib.h>
+#include <errno.h>
+
+ int
+ main ()
+ {
+ char const *dangling_symlink = "conftest.dangle";
+
+ unlink (dangling_symlink);
+ if (symlink ("conftest.no-such", dangling_symlink))
+ abort ();
+
+ /* Exit successfully on a conforming system,
+ i.e., where chown must fail with ENOENT. */
+ exit ( ! (chown (dangling_symlink, getuid (), getgid ()) != 0
+ && errno == ENOENT));
+ }
+ ]])],
+ [gl_cv_func_chown_follows_symlink=yes],
+ [gl_cv_func_chown_follows_symlink=no],
+ [gl_cv_func_chown_follows_symlink=no]
+ )
+ ]
+ )
+
+ if test $gl_cv_func_chown_follows_symlink = no; then
+ AC_DEFINE(CHOWN_MODIFIES_SYMLINK, 1,
+ [Define if chown modifies symlinks.])
+ fi
+])
+
# Prerequisites of lib/chown.c.
AC_DEFUN([gl_PREREQ_CHOWN],
[
- AC_CHECK_HEADERS_ONCE(unistd.h)
+ AC_CHECK_HEADERS_ONCE(unistd.h fcntl.h)
+ AC_CHECK_FUNC([fchown], , [AC_LIBOBJ(fchown-stub)])
])
diff --git a/m4/dirname.m4 b/m4/dirname.m4
index d0dacf1e06..b93ff608c4 100644
--- a/m4/dirname.m4
+++ b/m4/dirname.m4
@@ -1,5 +1,5 @@
# dirname.m4 serial 3
-dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/human.m4 b/m4/human.m4
index 3dbc16db5f..d70b219a55 100644
--- a/m4/human.m4
+++ b/m4/human.m4
@@ -1,5 +1,5 @@
# human.m4 serial 5
-dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/inttypes.m4 b/m4/inttypes.m4
index e19dd36fec..ab370ffe00 100644
--- a/m4/inttypes.m4
+++ b/m4/inttypes.m4
@@ -1,5 +1,5 @@
-# inttypes.m4 serial 2
-dnl Copyright (C) 1997-2002, 2004 Free Software Foundation, Inc.
+# inttypes.m4 serial 1 (gettext-0.11.4)
+dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/longlong.m4 b/m4/longlong.m4
index 698d2ae7ba..028422b612 100644
--- a/m4/longlong.m4
+++ b/m4/longlong.m4
@@ -1,5 +1,5 @@
# longlong.m4 serial 5
-dnl Copyright (C) 1999-2003 Free Software Foundation, Inc.
+dnl Copyright (C) 1999-2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/makepath.m4 b/m4/makepath.m4
index a50512578b..af8350a577 100644
--- a/m4/makepath.m4
+++ b/m4/makepath.m4
@@ -1,5 +1,5 @@
# makepath.m4 serial 3
-dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/memchr.m4 b/m4/memchr.m4
index 549dd86c8a..0ae7ff11b5 100644
--- a/m4/memchr.m4
+++ b/m4/memchr.m4
@@ -1,5 +1,5 @@
# memchr.m4 serial 3
-dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/memcmp.m4 b/m4/memcmp.m4
index 708fde5121..3e85fb8f6c 100644
--- a/m4/memcmp.m4
+++ b/m4/memcmp.m4
@@ -1,5 +1,5 @@
# memcmp.m4 serial 10
-dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/mountlist.m4 b/m4/mountlist.m4
index 14df556772..6eb11077b4 100644
--- a/m4/mountlist.m4
+++ b/m4/mountlist.m4
@@ -1,5 +1,5 @@
# mountlist.m4 serial 3
-dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/path-concat.m4 b/m4/path-concat.m4
index 615d61571e..12db2389ea 100644
--- a/m4/path-concat.m4
+++ b/m4/path-concat.m4
@@ -1,5 +1,5 @@
# path-concat.m4 serial 3
-dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/prereq.m4 b/m4/prereq.m4
index 18fc16acc6..e2588a29ed 100644
--- a/m4/prereq.m4
+++ b/m4/prereq.m4
@@ -1,4 +1,4 @@
-#serial 39
+#serial 40
dnl We use gl_ for non Autoconf macros.
m4_pattern_forbid([^gl_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
@@ -15,8 +15,10 @@ AC_DEFUN([gl_PREREQ],
AC_REQUIRE([AM_STDBOOL_H])
AC_REQUIRE([gl_FUNC_MKDIR_TRAILING_SLASH])
AC_REQUIRE([gl_FUNC_MKSTEMP])
+ AC_REQUIRE([gl_ALLOCSA])
AC_REQUIRE([gl_BACKUPFILE])
AC_REQUIRE([gl_CANON_HOST])
+ AC_REQUIRE([gl_CLOEXEC])
AC_REQUIRE([gl_CLOSEOUT])
AC_REQUIRE([gl_DIRNAME])
AC_REQUIRE([gl_ERROR])
@@ -71,6 +73,7 @@ AC_DEFUN([gl_PREREQ],
AC_REQUIRE([gl_HASH])
AC_REQUIRE([gl_HUMAN])
AC_REQUIRE([gl_IDCACHE])
+ AC_REQUIRE([gl_INTTOSTR])
AC_REQUIRE([gl_LONG_OPTIONS])
AC_REQUIRE([gl_MAKEPATH])
AC_REQUIRE([gl_MBSWIDTH])
@@ -102,6 +105,7 @@ AC_DEFUN([gl_PREREQ],
AC_REQUIRE([gl_UNICODEIO])
AC_REQUIRE([gl_UNISTD_SAFER])
AC_REQUIRE([gl_USERSPEC])
+ AC_REQUIRE([gl_UTIMECMP])
AC_REQUIRE([gl_UTIMENS])
AC_REQUIRE([gl_XALLOC])
AC_REQUIRE([gl_XGETCWD])
diff --git a/m4/putenv.m4 b/m4/putenv.m4
index 80abf84f72..0bb17f415a 100644
--- a/m4/putenv.m4
+++ b/m4/putenv.m4
@@ -1,5 +1,5 @@
# putenv.m4 serial 8
-dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/quotearg.m4 b/m4/quotearg.m4
index aa4a3d1473..877fcd9af1 100644
--- a/m4/quotearg.m4
+++ b/m4/quotearg.m4
@@ -1,5 +1,5 @@
# quotearg.m4 serial 2
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/readutmp.m4 b/m4/readutmp.m4
index c7dfb42278..5968465cfc 100644
--- a/m4/readutmp.m4
+++ b/m4/readutmp.m4
@@ -1,4 +1,4 @@
-# readutmp.m4 serial 3
+# readutmp.m4 serial 4
dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
diff --git a/m4/strtoimax.m4 b/m4/strtoimax.m4
index 17eaed1101..84e57a8761 100644
--- a/m4/strtoimax.m4
+++ b/m4/strtoimax.m4
@@ -1,5 +1,5 @@
# strtoimax.m4 serial 4
-dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/strtoll.m4 b/m4/strtoll.m4
index 6d570cc3e3..ce2d87cfdc 100644
--- a/m4/strtoll.m4
+++ b/m4/strtoll.m4
@@ -1,5 +1,5 @@
# strtoll.m4 serial 2
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
@@ -23,4 +23,3 @@ AC_DEFUN([gl_FUNC_STRTOLL],
AC_DEFUN([gl_PREREQ_STRTOLL], [
:
])
-
diff --git a/m4/strtoull.m4 b/m4/strtoull.m4
index 49c9bbe7d3..fd0a636151 100644
--- a/m4/strtoull.m4
+++ b/m4/strtoull.m4
@@ -1,5 +1,5 @@
# strtoull.m4 serial 2
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
@@ -23,4 +23,3 @@ AC_DEFUN([gl_FUNC_STRTOULL],
AC_DEFUN([gl_PREREQ_STRTOULL], [
:
])
-
diff --git a/m4/strtoumax.m4 b/m4/strtoumax.m4
index 1d5484454f..84d42ff16f 100644
--- a/m4/strtoumax.m4
+++ b/m4/strtoumax.m4
@@ -1,5 +1,5 @@
# strtoumax.m4 serial 4
-dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/ulonglong.m4 b/m4/ulonglong.m4
index 3c7c5f03d7..1123ccb837 100644
--- a/m4/ulonglong.m4
+++ b/m4/ulonglong.m4
@@ -1,5 +1,5 @@
# ulonglong.m4 serial 4
-dnl Copyright (C) 1999-2003 Free Software Foundation, Inc.
+dnl Copyright (C) 1999-2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/vasnprintf.m4 b/m4/vasnprintf.m4
index 172c320e7b..cba4428bf2 100644
--- a/m4/vasnprintf.m4
+++ b/m4/vasnprintf.m4
@@ -1,5 +1,5 @@
# vasnprintf.m4 serial 4
-dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/m4/xstrtol.m4 b/m4/xstrtol.m4
index a18b51ff7d..bed760c823 100644
--- a/m4/xstrtol.m4
+++ b/m4/xstrtol.m4
@@ -1,5 +1,5 @@
# xstrtol.m4 serial 4
-dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
diff --git a/modules/file-type b/modules/file-type
index dff2503de1..8f14c2e433 100644
--- a/modules/file-type
+++ b/modules/file-type
@@ -4,6 +4,7 @@ Return a string describing the type of a file.
Files:
lib/file-type.h
lib/file-type.c
+lib/stat-macros.h
m4/file-type.m4
Depends-on:
@@ -13,7 +14,7 @@ configure.ac:
gl_FILE_TYPE
Makefile.am:
-lib_SOURCES += file-type.h file-type.c
+lib_SOURCES += file-type.h file-type.c stat-macros.h
Include:
"file-type.h"