diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | Makefile.in | 5 | ||||
-rw-r--r-- | m4/timespec.m4 | 52 | ||||
-rw-r--r-- | patch.c | 4 | ||||
-rw-r--r-- | timespec.h | 60 | ||||
-rw-r--r-- | util.c | 22 | ||||
-rw-r--r-- | util.h | 2 |
7 files changed, 21 insertions, 137 deletions
@@ -3,6 +3,19 @@ * pch.c (intuit_diff_type): Rename need_filename argument to need_header. Omit superfluous "missing header" warnings. + When remembering files including timestamps, we need to update the + timestamps after appending to a file. This causes problems on some + systems where the timestamps returned by fstat() after appending are + not up to date, yes. We only remember timestamps as a compatibility + hack with non-POSIX systems that do not have unique inode numbers; + drop this hack instead. + * timespec.h, m4/timespec.m4: Remove. + * util.c: Remove timespec.h and all uses of struct timespec. + (append_to_file): Remove REMEMBER argument; no need to update known + files anymore. + * util.h (append_to_file): Update definition. + * Makefile.in: Remove timespec.h and m4/timespec.m4. + 2009-03-24 Andreas Gruenbacher <agruen@suse.de> * patch.c (abort_hunk_unified, abort_hunk_context): Preserve diff --git a/Makefile.in b/Makefile.in index ac6c243..931d61b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -88,7 +88,7 @@ HDRS = argmatch.h backupfile.h common.h dirname.h \ unlocked-io.h util.h version.h xalloc.h MISC = AUTHORS COPYING ChangeLog INSTALL Makefile.in NEWS README VERSION \ aclocal.m4 config.hin configure configure.ac install-sh \ - mkinstalldirs patch.man stdbool_.h tests/test-lib.sh timespec.h \ + mkinstalldirs patch.man stdbool_.h tests/test-lib.sh \ update-version.sh TESTS = tests/corrupt-reject-files tests/crlf-handling \ tests/global-reject-files tests/need-filename \ @@ -177,7 +177,6 @@ M4FILES = \ $(M4DIR)/st_mtim.m4 \ $(M4DIR)/stdbool.m4 \ $(M4DIR)/strcase.m4 \ - $(M4DIR)/timespec.m4 \ $(M4DIR)/unlocked-io.m4 \ $(M4DIR)/utimbuf.m4 \ $(M4DIR)/xalloc.m4 @@ -245,7 +244,7 @@ quotearg.$(OBJEXT): gettext.h quotearg.h xalloc.h quotesys.$(OBJEXT): quotesys.h strncasecmp.$(OBJEXT): strcasecmp.c util.$(OBJEXT): backupfile.h $(COMMON) dirname.h hash.h maketime.h \ - partime.h quotearg.h quotesys.h timespec.h util.h version.h xalloc.h + partime.h quotearg.h quotesys.h util.h version.h xalloc.h version.$(OBJEXT): $(COMMON) version.h xmalloc.$(OBJEXT): error.h exitfail.h gettext.h xalloc.h diff --git a/m4/timespec.m4 b/m4/timespec.m4 deleted file mode 100644 index 5ca16d4..0000000 --- a/m4/timespec.m4 +++ /dev/null @@ -1,52 +0,0 @@ -#serial 7 - -dnl From Jim Meyering - -AC_DEFUN([gl_TIMESPEC], -[ - dnl Prerequisites of lib/timespec.h. - AC_REQUIRE([AC_HEADER_TIME]) - AC_CHECK_HEADERS_ONCE(sys/time.h) - jm_CHECK_TYPE_STRUCT_TIMESPEC - AC_STRUCT_ST_MTIM_NSEC - - dnl Persuade glibc <time.h> to declare nanosleep(). - AC_REQUIRE([AC_GNU_SOURCE]) - - AC_CHECK_DECLS(nanosleep, , , [#include <time.h>]) -]) - -dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared -dnl in time.h or sys/time.h. - -AC_DEFUN([jm_CHECK_TYPE_STRUCT_TIMESPEC], -[ - dnl Persuade pedantic Solaris to declare struct timespec. - AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - - AC_REQUIRE([AC_HEADER_TIME]) - AC_CHECK_HEADERS_ONCE(sys/time.h) - AC_CACHE_CHECK([for struct timespec], fu_cv_sys_struct_timespec, - [AC_TRY_COMPILE( - [ -# if TIME_WITH_SYS_TIME -# include <sys/time.h> -# include <time.h> -# else -# if HAVE_SYS_TIME_H -# include <sys/time.h> -# else -# include <time.h> -# endif -# endif - ], - [static struct timespec x; x.tv_sec = x.tv_nsec;], - fu_cv_sys_struct_timespec=yes, - fu_cv_sys_struct_timespec=no) - ]) - - if test $fu_cv_sys_struct_timespec = yes; then - AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1, - [Define if struct timespec is declared in <time.h>. ]) - fi -]) @@ -445,7 +445,7 @@ main (int argc, char **argv) written_to_rejname = true; } else - append_to_file (TMPREJNAME, rejname, false); + append_to_file (TMPREJNAME, rejname); } else { @@ -456,7 +456,7 @@ main (int argc, char **argv) if (rej_errno && rej_errno != ENOENT) write_fatal (); if (! rej_errno && file_already_seen (&tost)) - append_to_file (TMPREJNAME, rej, true); + append_to_file (TMPREJNAME, rej); else move_file (TMPREJNAME, &TMPREJNAME_needs_removal, &rejst, rej, 0666, false); diff --git a/timespec.h b/timespec.h deleted file mode 100644 index 8633461..0000000 --- a/timespec.h +++ /dev/null @@ -1,60 +0,0 @@ -/* timespec -- System time interface - - Copyright (C) 2000, 2002 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. */ - -#if ! defined TIMESPEC_H -# define TIMESPEC_H - -/* You must include config.h before including this file. */ - -# include <sys/types.h> -# if TIME_WITH_SYS_TIME -# include <sys/time.h> -# include <time.h> -# else -# if HAVE_SYS_TIME_H -# include <sys/time.h> -# else -# include <time.h> -# endif -# endif - -# if ! HAVE_STRUCT_TIMESPEC -/* Some systems don't define this struct, e.g., AIX 4.1, Ultrix 4.3. */ -struct timespec -{ - time_t tv_sec; - long tv_nsec; -}; -# endif - -# ifdef ST_MTIM_NSEC -# define TIMESPEC_NS(timespec) ((timespec).ST_MTIM_NSEC) -# else -# define TIMESPEC_NS(timespec) 0 -# endif - -# if ! HAVE_DECL_NANOSLEEP -/* Don't specify a prototype here. Some systems (e.g., OSF) declare - nanosleep with a conflicting one (const-less first parameter). */ -int nanosleep (); -# endif - -int gettime (struct timespec *); -int settime (struct timespec const *); - -#endif @@ -27,7 +27,6 @@ #include <hash.h> #include <quotearg.h> #include <quotesys.h> -#include <timespec.h> #undef XTERN #define XTERN #include <util.h> @@ -52,7 +51,6 @@ typedef struct { dev_t dev; ino_t ino; - struct timespec mtime; } file_id; /* Return an index for ENTRY into a hash table of size TABLE_SIZE. */ @@ -61,7 +59,7 @@ static unsigned int file_id_hasher (void const *entry, unsigned int table_size) { file_id const *e = entry; - unsigned int i = e->ino + e->dev + e->mtime.tv_sec + e->mtime.tv_nsec; + unsigned int i = e->ino + e->dev; return i % table_size; } @@ -72,10 +70,7 @@ file_id_comparator (void const *entry1, void const *entry2) { file_id const *e1 = entry1; file_id const *e2 = entry2; - return (e1->mtime.tv_nsec == e2->mtime.tv_nsec - && e1->mtime.tv_sec == e2->mtime.tv_sec - && e1->ino == e2->ino - && e1->dev == e2->dev); + return (e1->ino == e2->ino && e1->dev == e2->dev); } static Hash_table *file_id_table; @@ -103,8 +98,6 @@ insert_file (struct stat const *st) next_slot = xmalloc (sizeof *next_slot); next_slot->dev = st->st_dev; next_slot->ino = st->st_ino; - next_slot->mtime.tv_sec = st->st_mtime; - next_slot->mtime.tv_nsec = TIMESPEC_NS (st->st_mtim); p = hash_insert (file_id_table, next_slot); if (!p) xalloc_die (); @@ -121,8 +114,6 @@ file_already_seen (struct stat const *st) file_id f; f.dev = st->st_dev; f.ino = st->st_ino; - f.mtime.tv_sec = st->st_mtime; - f.mtime.tv_nsec = TIMESPEC_NS (st->st_mtim); return hash_lookup (file_id_table, &f) != 0; } @@ -327,20 +318,13 @@ copy_file (char const *from, char const *to, struct stat *tost, /* Append to file. */ void -append_to_file (char const *from, char const *to, bool remember) +append_to_file (char const *from, char const *to) { int tofd; if ((tofd = open (to, O_WRONLY | O_BINARY | O_APPEND)) < 0) pfatal ("Can't reopen file %s", quotearg (to)); copy_to_fd (from, tofd); - if (remember) - { - struct stat newst; - if (fstat (tofd, &newst) != 0) - write_fatal (); - insert_file (&newst); - } if (close (tofd) != 0) write_fatal (); } @@ -45,7 +45,7 @@ int systemic (char const *); char *format_linenum (char[LINENUM_LENGTH_BOUND + 1], LINENUM); void Fseek (FILE *, file_offset, int); void copy_file (char const *, char const *, struct stat *, int, mode_t); -void append_to_file (char const *, char const *, bool); +void append_to_file (char const *, char const *); void exit_with_signal (int) __attribute__ ((noreturn)); void ignore_signals (void); void init_backup_hash_table (void); |