fnmatch_.h
fts.c
fts_.h
+getaddrinfo.h
+getdelim.h
+getline.h
getndelim2.h
getopt.c
getopt.h
getopt_.h
getopt_int.h
getpagesize.h
+getpass.c
gettext.h
localcharset.h
+mbchar.h
+mbuiter.h
md5.h
obstack.h
printf-args.h
regex_internal.h
stat-time.h
stdbool_.h
+strcase.h
strdup.h
strndup.h
+strnlen.h
+strnlen1.h
strtoul.c
time_r.h
utimecmp.h
Makefile
alloca.h
charset.alias
+fnmatch.h
+fts.h
getdate.c
getdate.tab.c
getopt.h
-fnmatch.h
lstat.c
poll.h
ref-add.sed
ref-del.sed
+search.h
stat.c
stdbool.h
sysexit.h
+t-fpending
unlocked-io.h
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "cycle-check.h"
#include "hash.h"
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
return new_fd;
}
+#if !HAVE_FDOPENDIR
+
/* Replacement for Solaris' function by the same name.
<http://www.google.com/search?q=fdopendir+site:docs.sun.com>
Simulate it by doing save_cwd/fchdir/opendir(".")/restore_cwd.
W A R N I N G:
Unlike the other fd-related functions here, this one
effectively consumes its FD parameter. The caller should not
- close or otherwise manipulate FD after calling this function. */
+ close or otherwise manipulate FD if this function returns successfully. */
DIR *
fdopendir (int fd)
{
int saved_errno;
DIR *dir;
- if (fd == AT_FDCWD)
- return opendir (".");
-
if (save_cwd (&saved_cwd) != 0)
openat_save_fail (errno);
{
saved_errno = errno;
free_cwd (&saved_cwd);
- close (fd);
errno = saved_errno;
return NULL;
}
openat_restore_fail (errno);
free_cwd (&saved_cwd);
- close (fd);
+ if (dir)
+ close (fd);
errno = saved_errno;
return dir;
}
+#endif
+
/* Replacement for Solaris' function by the same name.
<http://www.google.com/search?q=fstatat+site:docs.sun.com>
Simulate it by doing save_cwd/fchdir/(stat|lstat)/restore_cwd.
# define __OPENAT_ID(y) __OPENAT_XCONCAT (__OPENAT_PREFIX, y)
# define openat __OPENAT_ID (openat)
int openat (int fd, char const *file, int flags, /* mode_t mode */ ...);
-# define fdopendir __OPENAT_ID (fdopendir)
+# if ! HAVE_FDOPENDIR
+# define fdopendir __OPENAT_ID (fdopendir)
+# endif
DIR *fdopendir (int fd);
# define fstatat __OPENAT_ID (fstatat)
int fstatat (int fd, char const *file, struct stat *st, int flag);
#if HAVE_SETTIMEOFDAY
{
struct timeval tv;
- int r;
tv.tv_sec = ts->tv_sec;
tv.tv_usec = ts->tv_nsec / 1000;
- r = settimeofday (&tv, 0);
- if (r == 0 || errno == EPERM)
- return r;
+ return settimeofday (&tv, 0);
}
-#endif
-
-#if HAVE_STIME
+#elif HAVE_STIME
+ /* This fails to compile on OSF1 V5.1, due to stime requiring
+ a `long int*' and tv_sec is `int'. But that system does provide
+ settimeofday. */
return stime (&ts->tv_sec);
#else
errno = ENOSYS;
#include <errno.h>
#include <fcntl.h>
+#include <unistd.h>
#if HAVE_UTIME_H
# include <utime.h>
# endif
#endif
-#if ! HAVE_FUTIMES_AT
+#if ! HAVE_FUTIMESAT
if (!file)
{
+# if ! (HAVE_WORKING_UTIMES && HAVE_FUTIMES)
errno = ENOSYS;
+# endif
+
+ /* Prefer EBADF to ENOSYS if both error numbers apply. */
+ if (errno == ENOSYS)
+ {
+ int fd2 = dup (fd);
+ int dup_errno = errno;
+ if (0 <= fd2)
+ close (fd2);
+ errno = (fd2 < 0 && dup_errno == EBADF ? EBADF : ENOSYS);
+ }
+
return -1;
}
-#serial 5
+#serial 6
# Use Gnulib's robust chdir function.
# It can handle arbitrarily long directory names, which means
gl_have_path_max_definition=yes,
gl_have_path_max_definition=no)])
- if test $gl_have_path_max_definition; then
+ if test $gl_have_path_max_definition = yes; then
AC_LIBOBJ([chdir-long])
gl_PREREQ_CHDIR_LONG
fi
-#serial 4
+#serial 6
# See if we need to use our replacement for Solaris' openat function.
dnl Copyright (C) 2004, 2005 Free Software Foundation, Inc.
AC_LIBSOURCES([openat.c, openat.h, openat-die.c])
AC_LIBOBJ([openat-die])
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+ AC_CHECK_FUNCS_ONCE([fdopendir])
AC_REPLACE_FUNCS(openat)
case $ac_cv_func_openat in
yes) ;;
[
dnl Avoid _AC_COMPUTE_INT-related macros, as they may not work with
dnl types wider than long int, due to problems with expr.
- AC_CACHE_CHECK([for ULLONG_MAX], gl_cv_ullong_max,
- [gl_cv_ullong_max=no
- AC_EGREP_CPP([ULLONG_MAX is defined],
- [
- #include <limits.h>
- #ifdef ULLONG_MAX
- "ULLONG_MAX is defined"
- #endif
- ],
- [gl_cv_ullong_max=yes])
- case $gl_cv_ullong_max in
- no)
- for gl_expr in \
- 18446744073709551615ULL \
- 4722366482869645213695ULL \
- 340282366920938463463374607431768211455ULL
- do
- AC_TRY_COMPILE([],
- [char test[$gl_expr == (unsigned long long int) -1 ? 1 : -1];
- static unsigned long long int i = $gl_expr;
- return i && test;],
- [gl_cv_ullong_max=$gl_expr])
- test $gl_cv_ullong_max != no && break
- done
- esac])
- case $gl_cv_ullong_max in
- yes | no) ;;
- *)
- AC_DEFINE_UNQUOTED([ULLONG_MAX], [$gl_cv_ullong_max],
- [Define as the maximum value of the type 'unsigned long long int',
- if the system doesn't define it, and if the system has that type.]);;
- esac
+ AC_CACHE_CHECK([whether ULONG_MAX < ULLONG_MAX],
+ [gl_cv_ulong_max_lt_ullong_max],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_BOOL_COMPILE_TRY(
+ [AC_INCLUDES_DEFAULT],
+ [[(unsigned long int) -1 < (unsigned long long int) -1]])],
+ [gl_cv_ulong_max_lt_ullong_max=yes],
+ [gl_cv_ulong_max_lt_ullong_max=no])])
+ if test $gl_cv_ulong_max_lt_ullong_max = yes; then
+ AC_DEFINE([ULONG_MAX_LT_ULLONG_MAX], 1,
+ [Define if ULONG_MAX < ULLONG_MAX, even if your compiler does not
+ support ULLONG_MAX.])
+ fi
])
# Then, there was code to round rather than truncate.
# Then, there was an implementation (sparc64, Linux-2.4.28, glibc-2.3.3)
# that didn't honor the NULL-means-set-to-current-time semantics.
+# Finally, there was also a version of utimes that failed on read-only
+# files, while utime worked fine (linux-2.2.20, glibc-2.2.5).
#
# From Jim Meyering, with suggestions from Paul Eggert.
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <sys/types.h>
#include <sys/stat.h>
+#include <fcntl.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
char const *file = "conftest.utimes";
FILE *f;
time_t now;
+ int fd;
int ok = ((f = fopen (file, "w"))
&& fclose (f) == 0
&& now - sbuf.st_atime <= 2
&& now - sbuf.st_mtime <= 2);
unlink (file);
+ if (!ok)
+ exit (1);
+
+ ok = (0 <= (fd = open (file, O_WRONLY|O_CREAT, 0444))
+ && close (fd) == 0
+ && utimes (file, NULL) == 0);
+ unlink (file);
exit (!ok);
}