[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-tar] paxutils improvements for wide time stamps etc.
From: |
Paul Eggert |
Subject: |
[Bug-tar] paxutils improvements for wide time stamps etc. |
Date: |
Tue, 21 Jun 2005 23:17:26 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) |
I installed this into paxutils. Mostly, it is prelude for a larger
patch to GNU tar, which is in response to Jim Meyering's recent bug
report.
2005-06-21 Paul Eggert <address@hidden>
Improve support for wide time stamps and other wide integers.
* gnulib.modules: Add inttostr, quote, quotearg.
* lib/system.h (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove.
(INT_STRLEN_BOUND): Remove.
Include "intprops.h" instead.
(UINTMAX_STRSIZE_BOUND): Define in terms of INT_BUFSIZE_BOUND,
not INT_STRLEN_BOUND.
[HAVE_UTIME_H]: Don't include utime.h.
* paxlib/DISTFILES: Remove convert.c.
* paxlib/convert.c: Remove.
* paxlib/error.c: Include quote.h, quotearg.h.
* paxlib/paxlib.h: Include inttostr.h.
(STRINGIFY_BIGINT): Define in terms of umaxtostr.
(stringify_uintmax_t_backwards): Remove decl.
* tests/genfile.c: Include <utimens.h> instead of rolling our own.
(exec_checkpoint): Use utimens instead of rolling our own.
Don't pass extra args to error.
(main): Wrap message inside _().
Index: gnulib.modules
===================================================================
RCS file: /cvsroot/paxutils/paxutils/gnulib.modules,v
retrieving revision 1.2
diff -p -u -r1.2 gnulib.modules
--- gnulib.modules 19 May 2005 08:33:11 -0000 1.2
+++ gnulib.modules 22 Jun 2005 06:13:05 -0000
@@ -5,6 +5,9 @@ dirname
full-write
getdate
getopt
+inttostr
+quote
+quotearg
safe-read
stdbool
strtol
Index: lib/system.h
===================================================================
RCS file: /cvsroot/paxutils/paxutils/lib/system.h,v
retrieving revision 1.3
diff -p -u -r1.3 system.h
--- lib/system.h 15 May 2005 06:34:49 -0000 1.3
+++ lib/system.h 22 Jun 2005 06:13:05 -0000
@@ -1,7 +1,7 @@
/* System dependent definitions for GNU tar.
Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003,
- 2004 Free Software Foundation, Inc.
+ 2004, 2005 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
@@ -453,24 +453,9 @@ char *getenv ();
# include <inttypes.h>
#endif
-/* These macros work even on ones'-complement hosts (!).
- The extra casts work around common compiler bugs. */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-#define TYPE_MINIMUM(t) (TYPE_SIGNED (t) \
- ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
- : (t) 0)
-#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
-
-/* Bound on length of the string representing an integer value of type t.
- Subtract one for the sign bit if t is signed;
- 302 / 1000 is log10 (2) rounded up;
- add one for integer division truncation;
- add one more for a minus sign if t is signed. */
-#define INT_STRLEN_BOUND(t) \
- ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 \
- + 1 + TYPE_SIGNED (t))
+#include <intprops.h>
-#define UINTMAX_STRSIZE_BOUND (INT_STRLEN_BOUND (uintmax_t) + 1)
+#define UINTMAX_STRSIZE_BOUND INT_BUFSIZE_BOUND (uintmax_t)
/* Prototypes for external functions. */
@@ -489,10 +474,6 @@ char *getenv ();
time_t time ();
#endif
-#ifdef HAVE_UTIME_H
-# include <utime.h>
-#endif
-
/* Library modules. */
#include <dirname.h>
Index: m4/system.m4
===================================================================
RCS file: /cvsroot/paxutils/paxutils/m4/system.m4,v
retrieving revision 1.2
diff -p -u -r1.2 system.m4
--- m4/system.m4 13 Jun 2005 12:51:06 -0000 1.2
+++ m4/system.m4 22 Jun 2005 06:13:05 -0000
@@ -1,9 +1,16 @@
+# Configuration for paxutils/lib/system.h.
+
+# Copyright (C) 2005 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
AC_DEFUN([PU_SYSTEM],[
AC_HEADER_STDC
AC_CHECK_HEADERS_ONCE([string.h memory.h fcntl.h unistd.h sys/wait.h
sys/gentape.h \
sys/tape.h sys/device.h sys/param.h sys/buf.h sys/tprintf.h sys/mtio.h \
- sgtty.h sys/io/trioctl.h inttypes.h locale.h utime.h])
+ sgtty.h sys/io/trioctl.h inttypes.h locale.h])
AC_CHECK_HEADERS_ONCE([sys/time.h])
AC_HEADER_TIME
@@ -17,4 +24,3 @@ AC_DEFUN([PU_SYSTEM],[
AC_CHECK_FUNCS_ONCE(lstat mkfifo setlocale)
AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])
])
-
Index: paxlib/DISTFILES
===================================================================
RCS file: /cvsroot/paxutils/paxutils/paxlib/DISTFILES,v
retrieving revision 1.2
diff -p -u -r1.2 DISTFILES
--- paxlib/DISTFILES 21 May 2005 22:56:26 -0000 1.2
+++ paxlib/DISTFILES 22 Jun 2005 06:13:05 -0000
@@ -1,4 +1,3 @@
-convert.c
error.c
exit.c
names.c
Index: paxlib/error.c
===================================================================
RCS file: /cvsroot/paxutils/paxutils/paxlib/error.c,v
retrieving revision 1.2
diff -p -u -r1.2 error.c
--- paxlib/error.c 21 May 2005 22:56:54 -0000 1.2
+++ paxlib/error.c 22 Jun 2005 06:13:05 -0000
@@ -18,6 +18,8 @@
#include <system.h>
#include <paxlib.h>
+#include <quote.h>
+#include <quotearg.h>
/* Decode MODE from its binary form in a stat structure, and encode it
into a 9-byte string STRING, terminated with a NUL. */
@@ -355,5 +357,3 @@ chdir_fatal (char const *name)
{
call_arg_fatal ("chdir", name);
}
-
-
Index: paxlib/paxlib.h
===================================================================
RCS file: /cvsroot/paxutils/paxutils/paxlib/paxlib.h,v
retrieving revision 1.1
diff -p -u -r1.1 paxlib.h
--- paxlib/paxlib.h 21 May 2005 22:55:55 -0000 1.1
+++ paxlib/paxlib.h 22 Jun 2005 06:13:05 -0000
@@ -22,6 +22,7 @@
#define _paxlib_h_
#include <hash.h>
+#include <inttostr.h>
/* Error reporting functions and definitions */
@@ -100,9 +101,7 @@ void write_error (char const *);
void pax_exit (void);
void fatal_exit (void) __attribute__ ((noreturn));
-#define STRINGIFY_BIGINT(i, b) \
- stringify_uintmax_t_backwards ((uintmax_t) (i), (b) + UINTMAX_STRSIZE_BOUND)
-char *stringify_uintmax_t_backwards (uintmax_t, char *);
+#define STRINGIFY_BIGINT(i, b) umaxtostr (i, b)
/* Name-related functions */
Index: tests/genfile.c
===================================================================
RCS file: /cvsroot/paxutils/paxutils/tests/genfile.c,v
retrieving revision 1.8
diff -p -u -r1.8 genfile.c
--- tests/genfile.c 21 Jun 2005 17:37:57 -0000 1.8
+++ tests/genfile.c 22 Jun 2005 06:13:05 -0000
@@ -28,6 +28,7 @@
#include <argmatch.h>
#include <argp.h>
#include <argcv.h>
+#include <utimens.h>
#ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
@@ -40,16 +41,6 @@
# define SIGCHLD SIGCLD
#endif
-#if HAVE_UTIME_H
-# include <utime.h>
-#else
-struct utimbuf
- {
- long actime;
- long modtime;
- };
-#endif
-
enum pattern
{
DEFAULT_PATTERN,
@@ -509,10 +500,14 @@ exec_checkpoint (struct action *p)
{
case OPT_TOUCH:
{
- struct utimbuf u;
+ struct timespec ts[2];
- u.actime = u.modtime = p->ts.tv_sec;
- utime (p->name, &u);
+ ts[0] = ts[1] = p->ts;
+ if (utimens (p->name, ts) != 0)
+ {
+ error (0, errno, _("cannot set time on `%s'"), p->name);
+ break;
+ }
}
break;
@@ -521,8 +516,7 @@ exec_checkpoint (struct action *p)
FILE *fp = fopen (p->name, "a");
if (!fp)
{
- error (0, errno, _("cannot open `%s'"),
- p->name, strerror (errno));
+ error (0, errno, _("cannot open `%s'"), p->name);
break;
}
@@ -536,8 +530,7 @@ exec_checkpoint (struct action *p)
int fd = open (p->name, O_RDWR);
if (fd == -1)
{
- error (0, errno, _("cannot open `%s'"),
- p->name, strerror (errno));
+ error (0, errno, _("cannot open `%s'"), p->name);
break;
}
ftruncate (fd, p->size);
@@ -709,7 +702,7 @@ main (int argc, char **argv)
{
case mode_stat:
if (argc == 0)
- error (EXIT_FAILURE, 0, "--stat requires file names");
+ error (EXIT_FAILURE, 0, _("--stat requires file names"));
while (argc--)
print_stat (*argv++);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-tar] paxutils improvements for wide time stamps etc.,
Paul Eggert <=