bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sync from coreutils to gnulib


From: Paul Eggert
Subject: sync from coreutils to gnulib
Date: Sun, 02 Oct 2005 15:39:52 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

I installed the following to sync gnulib from coreutils:

2005-10-02  Paul Eggert  <address@hidden>

        * .cppi-disable: Add getaddrinfo.h, getdelim.h, getline.h, getpass.c
        mbchar.h, mbuiter.h, strcase.h, strnlen.h, strnlen1.h.
        * .cvsignore: Add fts.h, search.h, t-fpending.
        * settime.c (settime): Fix { typo in previous patch.  Also, don't
        bother returning ENOSYS if settimeofday or stime fails; just let
        them return whatever errno they want to return.
        * utimens.c: Include unistd.h, for dup2.
        (futimens): Fix typo: HAVE_FUTIMESAT was misspelled in an #if.
        (futimens) [! HAVE_FUTIMESAT]: If !file, set errno before returning -1.

2005-10-02  Jim Meyering  <address@hidden>

        * fts-cycle.c [HAVE_CONFIG_H]: Include <config.h>.
        * openat-die.c: Use `#ifdef HAVE_CONFIG_H', not `#if HAVE_CONFIG_H'.
        * openat.c (fdopendir): Do not define if HAVE_FDOPENDIR.
        Remove AT_FDCWD test.
        Do not consume the fd unless successful.
        * openat.h (fdopendir): Do not define if HAVE_FDOPENDIR.
        * settime.c (settime): Move the HAVE_STIME block `up' into an #elif
        block, so that we don't even try to compile it if settimeofday is
        available.  This works around a compilation failure on OSF1 V5.1,
        due to stime requiring a `long int*' while tv_sec is `int'.

2005-10-02  Paul Eggert  <address@hidden>

        * openat.m4 (gl_FUNC_OPENAT): Check for fdopendir.
        * ullong_max.m4 (gl_ULLONG_MAX): Simplify so that it merely
        defines ULONG_MAX_LT_ULLONG_MAX.  Thomas M.Ott reports that
        ULLONG_MAX doesn't work with 2.7.2.1.

2005-10-02  Jim Meyering  <address@hidden>

        * utimes.m4 (gl_FUNC_UTIMES): Detect the version of utimes
        from glibc-2.2.5 that fails for read-only files.

2005-10-02  Alfred M. Szmidt  <address@hidden>

        * chdir-long.m4 (gl_FUNC_CHDIR_LONG): Compare $gl_have_path...
        against `yes', rather than just testing for nonempty.

Index: lib/.cppi-disable
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/.cppi-disable,v
retrieving revision 1.21
diff -p -u -r1.21 .cppi-disable
--- lib/.cppi-disable   23 Sep 2005 04:15:13 -0000      1.21
+++ lib/.cppi-disable   2 Oct 2005 22:30:35 -0000
@@ -5,6 +5,9 @@ exit.h
 fnmatch_.h
 fts.c
 fts_.h
+getaddrinfo.h
+getdelim.h
+getline.h
 getndelim2.h
 getopt.c
 getopt.h
@@ -12,8 +15,11 @@ getopt1.c
 getopt_.h
 getopt_int.h
 getpagesize.h
+getpass.c
 gettext.h
 localcharset.h
+mbchar.h
+mbuiter.h
 md5.h
 obstack.h
 printf-args.h
@@ -25,8 +31,11 @@ regex_internal.c
 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
Index: lib/.cvsignore
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/.cvsignore,v
retrieving revision 1.17
diff -p -u -r1.17 .cvsignore
--- lib/.cvsignore      4 Oct 2004 04:37:31 -0000       1.17
+++ lib/.cvsignore      2 Oct 2005 22:30:35 -0000
@@ -2,15 +2,18 @@
 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
Index: lib/fts-cycle.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/fts-cycle.c,v
retrieving revision 1.3
diff -p -u -r1.3 fts-cycle.c
--- lib/fts-cycle.c     14 Aug 2005 14:45:49 -0000      1.3
+++ lib/fts-cycle.c     2 Oct 2005 22:30:35 -0000
@@ -18,6 +18,10 @@
    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"
 
Index: lib/openat-die.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/openat-die.c,v
retrieving revision 1.1
diff -p -u -r1.1 openat-die.c
--- lib/openat-die.c    22 Sep 2005 23:30:37 -0000      1.1
+++ lib/openat-die.c    2 Oct 2005 22:30:35 -0000
@@ -16,7 +16,7 @@
    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
 
Index: lib/openat.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/openat.c,v
retrieving revision 1.6
diff -p -u -r1.6 openat.c
--- lib/openat.c        22 Sep 2005 23:30:37 -0000      1.6
+++ lib/openat.c        2 Oct 2005 22:30:35 -0000
@@ -89,6 +89,8 @@ rpl_openat (int fd, char const *file, in
   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.
@@ -100,7 +102,7 @@ rpl_openat (int fd, char const *file, in
    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)
 {
@@ -108,9 +110,6 @@ fdopendir (int fd)
   int saved_errno;
   DIR *dir;
 
-  if (fd == AT_FDCWD)
-    return opendir (".");
-
   if (save_cwd (&saved_cwd) != 0)
     openat_save_fail (errno);
 
@@ -118,7 +117,6 @@ fdopendir (int fd)
     {
       saved_errno = errno;
       free_cwd (&saved_cwd);
-      close (fd);
       errno = saved_errno;
       return NULL;
     }
@@ -130,11 +128,14 @@ fdopendir (int fd)
     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>
Index: lib/openat.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/openat.h,v
retrieving revision 1.6
diff -p -u -r1.6 openat.h
--- lib/openat.h        22 Sep 2005 23:30:37 -0000      1.6
+++ lib/openat.h        2 Oct 2005 22:30:35 -0000
@@ -46,7 +46,9 @@
 #  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);
Index: lib/settime.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/settime.c,v
retrieving revision 1.5
diff -p -u -r1.5 settime.c
--- lib/settime.c       23 Sep 2005 04:15:13 -0000      1.5
+++ lib/settime.c       2 Oct 2005 22:30:35 -0000
@@ -53,17 +53,15 @@ settime (struct timespec const *ts)
 #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;
Index: lib/utimens.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/utimens.c,v
retrieving revision 1.6
diff -p -u -r1.6 utimens.c
--- lib/utimens.c       25 Sep 2005 06:22:35 -0000      1.6
+++ lib/utimens.c       2 Oct 2005 22:30:35 -0000
@@ -26,6 +26,7 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <unistd.h>
 
 #if HAVE_UTIME_H
 # include <utime.h>
@@ -113,11 +114,24 @@ futimens (int fd ATTRIBUTE_UNUSED,
 # 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;
     }
 
Index: m4/chdir-long.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/chdir-long.m4,v
retrieving revision 1.2
diff -p -u -r1.2 chdir-long.m4
--- m4/chdir-long.m4    21 Mar 2005 20:49:26 -0000      1.2
+++ m4/chdir-long.m4    2 Oct 2005 22:30:35 -0000
@@ -1,4 +1,4 @@
-#serial 5
+#serial 6
 
 # Use Gnulib's robust chdir function.
 # It can handle arbitrarily long directory names, which means
@@ -27,7 +27,7 @@ have_path_max_definition
     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
Index: m4/openat.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/openat.m4,v
retrieving revision 1.2
diff -p -u -r1.2 openat.m4
--- m4/openat.m4        22 Sep 2005 23:30:37 -0000      1.2
+++ m4/openat.m4        2 Oct 2005 22:30:35 -0000
@@ -1,4 +1,4 @@
-#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.
@@ -13,6 +13,7 @@ AC_DEFUN([gl_FUNC_OPENAT],
   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) ;;
Index: m4/ullong_max.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/ullong_max.m4,v
retrieving revision 1.1
diff -p -u -r1.1 ullong_max.m4
--- m4/ullong_max.m4    18 Jan 2005 23:30:19 -0000      1.1
+++ m4/ullong_max.m4    2 Oct 2005 22:30:35 -0000
@@ -11,36 +11,17 @@ AC_DEFUN([gl_ULLONG_MAX],
 [
   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
 ])
Index: m4/utimes.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/utimes.m4,v
retrieving revision 1.11
diff -p -u -r1.11 utimes.m4
--- m4/utimes.m4        18 Jan 2005 23:52:18 -0000      1.11
+++ m4/utimes.m4        2 Oct 2005 22:30:35 -0000
@@ -12,6 +12,8 @@ dnl with or without modifications, as lo
 # 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.
 
@@ -23,6 +25,7 @@ AC_DEFUN([gl_FUNC_UTIMES],
   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>
@@ -38,6 +41,7 @@ main ()
   char const *file = "conftest.utimes";
   FILE *f;
   time_t now;
+  int fd;
 
   int ok = ((f = fopen (file, "w"))
            && fclose (f) == 0
@@ -57,6 +61,13 @@ main ()
      && lstat (file, &sbuf) == 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);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]