Index: ChangeLog =================================================================== RCS file: /fetish/cu/ChangeLog,v retrieving revision 1.1702 diff -p -u -r1.1702 ChangeLog --- ChangeLog 12 Apr 2006 07:49:34 -0000 1.1702 +++ ChangeLog 12 Apr 2006 20:12:11 -0000 @@ -1,7 +1,18 @@ -2006-04-11 Paul Eggert +2006-04-12 Paul Eggert * Version 6.0-cvs. + * src/ln.c (linkfunc): Remove. This method ran into a compiler/linker + bug in Interix. Just call symlink or link directly. All uses changed. + * src/setuidgid.c (main) [! HAVE_SETGROUPS]: Don't call setgroups. + * stat.c (USE_STATVFS): New macro. + Include and use statvfs only if USE_STATVFS. + (NAMEMAX_FORMAT): define a bit more clearly, now that the + statvfs-using code is a bit more regular. + * system.h (sync) [!HAVE_SYNC]: New macro. + +2006-04-11 Paul Eggert + * NEWS: csplit, nl, expr now conform to POSIX better, and are more-compatible with traditional Unix, with respect to regular expressions. Index: lib/ChangeLog =================================================================== RCS file: /fetish/cu/lib/ChangeLog,v retrieving revision 1.1166 diff -p -u -r1.1166 ChangeLog --- lib/ChangeLog 10 Apr 2006 06:46:07 -0000 1.1166 +++ lib/ChangeLog 12 Apr 2006 20:12:12 -0000 @@ -1,3 +1,12 @@ +2006-04-12 Paul Eggert + + * fsusage.c: Don't include or , since + fsusage.h now does that. Include fsusage.h first, to test interface. + Prefer statvfs if it works, since it's blessed by POSIX. Attempt + at most one method (the old code could have generated decls that + didn't conform to C89, not that this was ever exercised). + * fsusage.h: Include and if they exist. + 2006-04-09 Paul Eggert Merge regex changes from libc, removing some of our Index: lib/fsusage.c =================================================================== RCS file: /fetish/cu/lib/fsusage.c,v retrieving revision 1.54 diff -p -u -r1.54 fsusage.c --- lib/fsusage.c 22 Sep 2005 06:05:39 -0000 1.54 +++ lib/fsusage.c 12 Apr 2006 20:12:12 -0000 @@ -1,6 +1,6 @@ /* fsusage.c -- return space usage of mounted file systems - Copyright (C) 1991, 1992, 1996, 1998, 1999, 2002, 2003, 2004, 2005 + Copyright (C) 1991, 1992, 1996, 1998, 1999, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -21,58 +21,46 @@ # include #endif -#if HAVE_INTTYPES_H -# include -#endif -#if HAVE_STDINT_H -# include -#endif -#include -#ifndef UINTMAX_MAX -# define UINTMAX_MAX ((uintmax_t) -1) -#endif - -#include -#include #include "fsusage.h" #include +#include -#if HAVE_SYS_PARAM_H -# include -#endif - -#if HAVE_SYS_MOUNT_H -# include -#endif - -#if HAVE_SYS_VFS_H -# include -#endif - -#if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */ -# include -#endif - -#if defined HAVE_SYS_FILSYS_H && !defined _CRAY -# include /* SVR2 */ -#endif - -#include - -#if HAVE_SYS_STATFS_H -# include -#endif - -#if HAVE_DUSTAT_H /* AIX PS/2 */ -# include -#endif - -#if HAVE_SYS_STATVFS_H /* SVR4 */ +#if STAT_STATVFS /* POSIX 1003.1-2001 (and later) with XSI */ # include +#else +/* Don't include backward-compatibility files unless they're needed. + Eventually we'd like to remove all this cruft. */ +# include +# include +# include +# if HAVE_SYS_PARAM_H +# include +# endif +# if HAVE_SYS_MOUNT_H +# include +# endif +# if HAVE_SYS_VFS_H +# include +# endif +# if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */ +# include +# endif +# if defined HAVE_SYS_FILSYS_H && !defined _CRAY +# include /* SVR2 */ +# endif +# if HAVE_SYS_STATFS_H +# include +# endif +# if HAVE_DUSTAT_H /* AIX PS/2 */ +# include +# endif +# include "full-read.h" #endif -#include "full-read.h" +#ifndef UINTMAX_MAX +# define UINTMAX_MAX ((uintmax_t) -1) +#endif /* Many space usage primitives use all 1 bits to denote a value that is not applicable or unknown. Propagate this information by returning @@ -108,18 +96,19 @@ int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) { -#ifdef STAT_STATFS3_OSF1 +#if defined STAT_STATVFS /* POSIX */ - struct statfs fsd; + struct statvfs fsd; - if (statfs (file, &fsd, sizeof (struct statfs)) != 0) + if (statvfs (file, &fsd) < 0) return -1; - fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); - -#endif /* STAT_STATFS3_OSF1 */ + /* f_frsize isn't guaranteed to be supported. */ + fsp->fsu_blocksize = (fsd.f_frsize + ? PROPAGATE_ALL_ONES (fsd.f_frsize) + : PROPAGATE_ALL_ONES (fsd.f_bsize)); -#ifdef STAT_STATFS2_FS_DATA /* Ultrix */ +#elif defined STAT_STATFS2_FS_DATA /* Ultrix */ struct fs_data fsd; @@ -134,9 +123,7 @@ get_fs_usage (char const *file, char con fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.fd_req.gtot); fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.fd_req.gfree); -#endif /* STAT_STATFS2_FS_DATA */ - -#ifdef STAT_READ_FILSYS /* SVR2 */ +#elif defined STAT_READ_FILSYS /* SVR2 */ # ifndef SUPERBOFF # define SUPERBOFF (SUPERB * 512) # endif @@ -171,9 +158,16 @@ get_fs_usage (char const *file, char con : (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1)); fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode); -#endif /* STAT_READ_FILSYS */ +#elif defined STAT_STATFS3_OSF1 + + struct statfs fsd; + + if (statfs (file, &fsd, sizeof (struct statfs)) != 0) + return -1; + + fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); -#ifdef STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */ +#elif defined STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */ struct statfs fsd; @@ -197,9 +191,7 @@ get_fs_usage (char const *file, char con } # endif /* STATFS_TRUNCATES_BLOCK_COUNTS */ -#endif /* STAT_STATFS2_BSIZE */ - -#ifdef STAT_STATFS2_FSIZE /* 4.4BSD */ +#elif defined STAT_STATFS2_FSIZE /* 4.4BSD */ struct statfs fsd; @@ -208,9 +200,7 @@ get_fs_usage (char const *file, char con fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); -#endif /* STAT_STATFS2_FSIZE */ - -#ifdef STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */ +#elif defined STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */ # if !_AIX && !defined _SEQUENT_ && !defined DOLPHIN # define f_bavail f_bfree @@ -230,24 +220,10 @@ get_fs_usage (char const *file, char con fsp->fsu_blocksize = 512; # endif -#endif /* STAT_STATFS4 */ - -#ifdef STAT_STATVFS /* SVR4 */ - - struct statvfs fsd; - - if (statvfs (file, &fsd) < 0) - return -1; - - /* f_frsize isn't guaranteed to be supported. */ - fsp->fsu_blocksize = (fsd.f_frsize - ? PROPAGATE_ALL_ONES (fsd.f_frsize) - : PROPAGATE_ALL_ONES (fsd.f_bsize)); - -#endif /* STAT_STATVFS */ +#endif -#if !defined STAT_STATFS2_FS_DATA && !defined STAT_READ_FILSYS - /* !Ultrix && !SVR2 */ +#if (defined STAT_STATVFS \ + || (!defined STAT_STATFS2_FS_DATA && !defined STAT_READ_FILSYS)) fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.f_blocks); fsp->fsu_bfree = PROPAGATE_ALL_ONES (fsd.f_bfree); @@ -256,7 +232,7 @@ get_fs_usage (char const *file, char con fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.f_files); fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.f_ffree); -#endif /* not STAT_STATFS2_FS_DATA && not STAT_READ_FILSYS */ +#endif return 0; } Index: lib/fsusage.h =================================================================== RCS file: /fetish/cu/lib/fsusage.h,v retrieving revision 1.14 diff -p -u -r1.14 fsusage.h --- lib/fsusage.h 2 Jun 2005 05:05:29 -0000 1.14 +++ lib/fsusage.h 12 Apr 2006 20:12:12 -0000 @@ -1,6 +1,6 @@ /* fsusage.h -- declarations for file system space usage info - Copyright (C) 1991, 1992, 1997, 2003, 2004, 2005 Free Software + Copyright (C) 1991, 1992, 1997, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -22,6 +22,12 @@ #if !defined FSUSAGE_H_ # define FSUSAGE_H_ +# if HAVE_INTTYPES_H +# include +# endif +# if HAVE_STDINT_H +# include +# endif # include struct fs_usage Index: m4/ChangeLog =================================================================== RCS file: /fetish/cu/m4/ChangeLog,v retrieving revision 1.812 diff -p -u -r1.812 ChangeLog --- m4/ChangeLog 12 Apr 2006 07:11:52 -0000 1.812 +++ m4/ChangeLog 12 Apr 2006 20:12:13 -0000 @@ -1,3 +1,8 @@ +2006-04-12 Paul Eggert + + * jm-macros.m4 (gl_MACROS): Check for setgroups and sync, since they + are not in Interix. + 2006-04-11 Paul Eggert * time_r.m4 (gl_TIME_R): Add AC_LIBSOURCES for time_r.c and time_r.h. Index: m4/jm-macros.m4 =================================================================== RCS file: /fetish/cu/m4/jm-macros.m4,v retrieving revision 1.237 diff -p -u -r1.237 jm-macros.m4 --- m4/jm-macros.m4 2 Jan 2006 06:34:13 -0000 1.237 +++ m4/jm-macros.m4 12 Apr 2006 20:12:13 -0000 @@ -1,4 +1,4 @@ -#serial 96 -*- autoconf -*- +#serial 97 -*- autoconf -*- dnl Misc type-related macros for coreutils. @@ -115,8 +115,10 @@ AC_DEFUN([gl_MACROS], mkfifo \ mbrlen \ realpath \ + setgroups \ sethostname \ siginterrupt \ + sync \ sysctl \ sysinfo \ tcgetpgrp \ Index: src/ln.c =================================================================== RCS file: /fetish/cu/src/ln.c,v retrieving revision 1.156 diff -p -u -r1.156 ln.c --- src/ln.c 26 Mar 2006 12:07:04 -0000 1.156 +++ src/ln.c 12 Apr 2006 20:12:13 -0000 @@ -60,10 +60,6 @@ char *program_name; /* FIXME: document */ static enum backup_type backup_type; -/* A pointer to the function used to make links. This will point to either - `link' or `symlink'. */ -static int (*linkfunc) (); - /* If true, make symbolic links; otherwise, make hard links. */ static bool symbolic_link; @@ -241,7 +237,8 @@ do_link (const char *source, const char } } - ok = (linkfunc (source, dest) == 0); + ok = ((symbolic_link ? symlink (source, dest) : link (source, dest)) + == 0); /* If the attempt to create a link failed and we are removing or backing up destinations, unlink the destination and try again. @@ -270,7 +267,8 @@ do_link (const char *source, const char return false; } - ok = (linkfunc (source, dest) == 0); + ok = ((symbolic_link ? symlink (source, dest) : link (source, dest)) + == 0); } if (ok) @@ -506,11 +504,6 @@ main (int argc, char **argv) quote (file[n_files - 1])); } - if (symbolic_link) - linkfunc = symlink; - else - linkfunc = link; - if (backup_suffix_string) simple_backup_suffix = xstrdup (backup_suffix_string); Index: src/setuidgid.c =================================================================== RCS file: /fetish/cu/src/setuidgid.c,v retrieving revision 1.16 diff -p -u -r1.16 setuidgid.c --- src/setuidgid.c 14 May 2005 07:58:37 -0000 1.16 +++ src/setuidgid.c 12 Apr 2006 20:12:13 -0000 @@ -1,5 +1,5 @@ /* setuidgid - run a command with the UID and GID of a specified user - Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2006 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 @@ -104,8 +104,10 @@ main (int argc, char **argv) error (SETUIDGID_FAILURE, errno, _("unknown user-ID: %s"), quote (user_id)); +#if HAVE_SETGROUPS if (setgroups (1, &pwd->pw_gid)) error (SETUIDGID_FAILURE, errno, _("cannot set supplemental group")); +#endif if (setgid (pwd->pw_gid)) error (SETUIDGID_FAILURE, errno, Index: src/stat.c =================================================================== RCS file: /fetish/cu/src/stat.c,v retrieving revision 1.91 diff -p -u -r1.91 stat.c --- src/stat.c 15 Dec 2005 20:15:20 -0000 1.91 +++ src/stat.c 12 Apr 2006 20:12:13 -0000 @@ -1,5 +1,5 @@ /* stat.c -- display file or file system status - Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation. 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,11 +19,18 @@ #include +#if (STAT_STATVFS \ + && (HAVE_STRUCT_STATVFS_F_BASETYPE || ! HAVE_STRUCT_STATFS_F_FSTYPENAME)) +# define USE_STATVFS 1 +#else +# define USE_STATVFS 0 +#endif + #include #include #include #include -#if HAVE_SYS_STATVFS_H && HAVE_STRUCT_STATVFS_F_BASETYPE +#if USE_STATVFS # include #elif HAVE_SYS_VFS_H # include @@ -56,35 +63,29 @@ #include "strftime.h" #include "xreadlink.h" -#define NAMEMAX_FORMAT PRIuMAX - -#if HAVE_STRUCT_STATVFS_F_BASETYPE +#if USE_STATVFS # define STRUCT_STATVFS struct statvfs # define HAVE_STRUCT_STATXFS_F_TYPE HAVE_STRUCT_STATVFS_F_TYPE # if HAVE_STRUCT_STATVFS_F_NAMEMAX # define SB_F_NAMEMAX(S) ((uintmax_t) ((S)->f_namemax)) # endif -# if STAT_STATVFS -# define STATFS statvfs -# define STATFS_FRSIZE(S) ((S)->f_frsize) -# endif +# define STATFS statvfs +# define STATFS_FRSIZE(S) ((S)->f_frsize) #else # define STRUCT_STATVFS struct statfs # define HAVE_STRUCT_STATXFS_F_TYPE HAVE_STRUCT_STATFS_F_TYPE # if HAVE_STRUCT_STATFS_F_NAMELEN # define SB_F_NAMEMAX(S) ((uintmax_t) ((S)->f_namelen)) # endif -#endif - -#ifndef STATFS # define STATFS statfs # define STATFS_FRSIZE(S) 0 #endif -#ifndef SB_F_NAMEMAX +#ifdef SB_F_NAMEMAX +# define NAMEMAX_FORMAT PRIuMAX +#else /* NetBSD 1.5.2 has neither f_namemax nor f_namelen. */ # define SB_F_NAMEMAX(S) "*" -# undef NAMEMAX_FORMAT # define NAMEMAX_FORMAT "s" #endif Index: src/system.h =================================================================== RCS file: /fetish/cu/src/system.h,v retrieving revision 1.145 diff -p -u -r1.145 system.h --- src/system.h 12 Mar 2006 20:45:04 -0000 1.145 +++ src/system.h 12 Apr 2006 20:12:13 -0000 @@ -765,6 +765,10 @@ enum : (errno = EOVERFLOW, -1)) #endif +#if ! HAVE_SYNC +# define sync() /* empty */ +#endif + /* Compute the greatest common divisor of U and V using Euclid's algorithm. U and V must be nonzero. */