27 Commits

Author SHA1 Message Date
Andreas Gruenbacher
ac59899327 Use gnulib errno module instead of our own default ENOTSUP fallback
* bootstrap.conf (gnulib_modules): Add errno module.
* src/common.h: Remove ENOTSUP fallback.
2012-09-28 16:00:04 +02:00
Andreas Gruenbacher
3b4824fb33 Do not delete files immediately
Fixes the bug that more than one numbered backup would be created when a patch
file deletes and recreates a file.
* bootstrap.conf (gnulib_modules): Add linked-list and xlist modules.
* src/util.h (file_id_type): Add DELETE_LATER and OVERWRITTEN types.
(create_backup, set_file_attributes): Update prototype.
(insert_file_id): Add prototype.
* src/util.c (insert_file_id): Export.
(set_file_attributes, create_backup_copy): Make the st argument const.
(create_backup): Pass in to_st instead of returning it from create_backup().
This obsoletes the to_errno argument.
(move_file): Determine to_st here and pass it to create_backup().  Remember
when a file is overwritten.
* src/patch.c (output_file): Add to_st parameter.  Remember files to delete
instead of deleting them immediately.  Pass from-st to create_backup().
(file_to_delete): New struct.
(init_files_to_delete, delete_file_later, delete_files): New functions.
(main): Use init_files_to_delete() and delete_files().  Pass to_st to
output_file() where we already have it.
* src/pch.c (intuit_diff_type): Assume that files which are marked for deletion
don't exist.
2012-04-17 16:48:19 +02:00
Jim Meyering
297f9e7dd6 build: update bootstrap from gnulib and adapt
* bootstrap: Update from gnulib.
* bootstrap.conf (gnulib_tool_option_extras): Define.
* lib/Makefile.am: Initialize numerous automake variables so that
generated code in gnulib.mk may use += to append to them.
* configure.ac: Add AM_PROG_AR, to placate newer automake.
2012-02-16 14:36:11 +01:00
Jim Meyering
2d38b11799 maint: update all copyright year number ranges
Run "make update-copyright".
2012-01-01 10:26:02 +01:00
Jim Meyering
46ad06707c build: use largefile module and update to latest gnulib
* configure.ac: Remove AC_SYS_LARGEFILE, subsumed by ...
* bootstrap.conf (gnulib_modules): ...this.  Use largefile module.
* gnulib: Update to latest.
This is useful to Mac OS X 10.5 users if/when configure
is generated using autoconf prior to v2.68-80-gdb2f2e0.
2011-08-11 14:18:57 +02:00
Jim Meyering
bb2fef06eb explicitly ignore close return value to placate static analyzers
* src/util.c: Include "ignore-value.h".
(ask): Use ignore_value to tell tools that yes, we really do
mean to ignore any close failure on this error path.
* bootstrap.conf (gnulib_modules): Add ignore-value.
2011-05-25 16:47:33 +02:00
Jim Meyering
df2831fbdf maint: remove now-unneeded macro definitions
* bootstrap.conf (gnulib_modules): Include gnulib's signal module,
so that signal.h guarantees definition of certain macros.
* src/util.c (SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK): Remove definition.
Now, gnulib guarantees that these are defined.
* src/common.h (SIZE_MAX): Likewise.
* cfg.mk (local-checks-to-skip): Enable the
sc_prohibit_always-defined_macros check, now that it passes.
2011-03-27 09:19:46 +02:00
Jim Meyering
8b78759a8b maint: use gnulib's progname module
* src/patch.c (main): Call set_program_name rather than
initializing program_name explicitly.
* src/common.h: Include progname.h rather than declaring the extern,
program_name.
* bootstrap.conf (gnulib_modules): Add progname.
* cfg.mk (local-checks-to-skip): Remove sc_program_name,
thus enabling this test.
2011-03-27 09:16:46 +02:00
Jim Meyering
db2fb7cdba maint: update copyright date year ranges to include 2011
* bootstrap.conf (gnulib_modules): Add update-copyright.
Run "make update-copyright".
2011-03-27 09:16:46 +02:00
Jim Meyering
7db2653124 build: accept new configure-time option --enable-gcc-warnings
* configure.ac: Enable many options.
* bootstrap.conf (gnulib_modules): Add manywarnings.
* src/Makefile.am (AM_CFLAGS): Use $(WARN_CFLAGS) and $(WERROR_CFLAGS).
2011-03-26 14:20:28 +01:00
Jim Meyering
07d4792620 maint: remove trailing blanks
* bootstrap.conf: Remove trailing blanks.
* tests/reject-format: Define a dummy, empty variable, and use it in
here-doc to protect required trailing blanks from accidental removal.
* tests/no-newline-triggers-assert: Likewise.
* tests/preserve-c-function-names: Likewise.
* tests/create-delete: Likewise.
* tests/global-reject-files: Complete a sentence that ended in a space.
2011-03-26 14:20:28 +01:00
Jim Meyering
94e032f941 maint: use gnulib's maintainer-makefile module
* bootstrap.conf (gnulib_modules): Add maintainer-makefile.
2011-03-26 14:17:36 +01:00
Jim Meyering
764d0ea12e do not version-control ChangeLog; instead, generate it from git log
With this change, all ChangeLog entries going forward are generated
into a file named ChangeLog in each distribution tarball.
ChangeLog entries prior to today's date are in ChangeLog-2011.
* Makefile.am (gen-ChangeLog): New rule.
(dist-hook): Depend on it.
(EXTRA_DIST): Add ChangeLog-2011.
* ChangeLog-2011: Renamed from ChangeLog
* ChangeLog: Remove file.
* .gitignore: Ignore ChangeLog.
* bootstrap.conf: Ensure that ChangeLog exists.
(gnulib_modules): Add gitlog-to-changelog.
2011-03-17 11:12:37 +01:00
Andreas Gruenbacher
76d0e43140 Preserve extended attributes of patched files when possible
* src/patch.c (main): Set all file attributes of the temporary output
file before renaming it over the final output file (possibly replacing
the input file).  Pass the input file name to set_file_attributes().
* src/util.c (set_file_attributes): When enabled (USE_XATTR), also
copy extended attributes including attributes which define
permissions.
(copy_attr_error, copy_attr_quote, copy_attr_free, copy_attr_check,
copy_attr): Helper functions for copying extended attributes.
* m4/xattr.m4 (gl_FUNC_XATTR): Import from coreutils.
* src/Makefile.am (patch_LDADD): Add $(LIB_XATTR) here.
* bootstrap.conf: Use the gnulib verror module.
2010-10-27 02:53:42 +02:00
Andreas Gruenbacher
4b6267d62f Add function make_tempfile()
* bootstrap.conf: Use the gnulib tempname module.
* src/util.c (make_tempfile): New function.
2010-09-17 01:36:53 +02:00
Andreas Gruenbacher
5b68db86ce Use the gnulib unistd module
* bootstrap.conf: Use the gnulib unistd module.
2010-05-05 01:03:57 +02:00
Andreas Gruenbacher
a78d3c405b Use the gnulib mkdir module
* bootstrap.conf: Use the gnulib mkdir module.
* m4/mkdir.m4: Delete.
2010-05-05 01:00:39 +02:00
Andreas Gruenbacher
dc0a3e09a8 Add support for writing symlinks
* src/util.c (copy_file): Require the mode parameter to include the
file type.  Use that to decide whether to copy a regular file or a
symlink.
(create_backup): Refuse to back up files which are neither a regular
file nor a symlink.
(move_file): Add support for turning a temporary output file into a
symlink.
* src/patch.c (move_file, copy_file): Pass down the file type.
* src/pch.h (prefix_components): Do not follow symlinks.
2010-05-02 11:42:24 +02:00
Andreas Gruenbacher
7f35c90cf7 Add support for reading symlinks
* src/inp.c (get_input_file): Add a mode parameter specifying the
input file type (which can be either S_IFREG or S_IFLNK).  The file
type must match this mode parameter; for symbolic links, the --get
option is not supported.
(scan_input): Abort when plan_a() cannot handle a symbolic link.
Say when patching a symbolic link instead of a regular file.
(plan_a): Add support for reading symbolic links.
* src/patch.c: For now, always tell get_input_file() to read regular
files.
* bootstrap.conf: Use the gnulib readlink module.
2010-05-02 11:38:31 +02:00
Andreas Gruenbacher
ba67864c2a Set file attributes only in a single place
* src/util.h (enum file_attributes): New type.
(set_file_attributes): New function.
* src/util.c (set_file_attributes): Move the code for setting file
attributes here from create_backup_copy() and make it usable from
patch.c as well.  Make it symlink safe.  In addition, also preserve
the file owner when permitted.
(create_backup_copy): Use set_file_attributes().
* src/patch.c (main): Use set_file_attributes().
* bootstrap.conf: Use the gnulib lchmod module.
2010-04-29 02:20:43 +02:00
Andreas Gruenbacher
e3cfef7f99 Refuse to patch symlinks
* src/inp.c (get_input_file), src/pch.c (there_is_another_patch,
intuit_diff_type): Use lstat instead of stat.  This causes patch to
refuse patching symlinks (get_input_file() will refuse to read them).
* src/util.c (create_backup): Refuse to create backups of symlinks.
* tests/symlinks: New test case.
* tests/Makefile.am (TESTS): Add test case.
* bootstrap.conf: Use the gnulib lstat module.
2010-04-27 12:38:15 +02:00
Andreas Gruenbacher
a11bfc85e5 Use the gnulib fcntl-h and sys_stat modules
* bootstrap.conf: Use the gnulib fcntl-h and sys_stat modules.
* src/common.h: Remove the declarations provided by gnulib sys_stat.
Always include fcntl.h (and depend on gnulib fcntl-h).
* src/util.h: Remove duplicate include of <timespec.h>.
* configure.ac: Remove obsolete checks for fcntl.h and utime.h.
2010-04-27 12:38:15 +02:00
Andreas Gruenbacher
d909eee7c9 Support for nanosecond timestamps
* src/patch.c (main): Support nanosecond timestamps.  Replaqce utime()
with utimens().
* src/util.c (create_backup_copy): Preserve nanosecond timestamps.
Replace utime() with utimens().
* src/util.h: Remove the utime() related declarations, and include
the utimens() and nanosecond related headers instead.
* bootstrap.conf: Add the stat-time and utimens modules.
2010-04-22 01:41:51 +02:00
Andreas Gruenbacher
f81fe080e5 Replace timestamp parsing code with gnulib getdate
* src/Makefile.am (patch_SOURCES): Remove maketime.c, maketime.h,
partime.c, and partime.h.
(patch_LDFLAGS): Add LIB_CLOCK_GETTIME for clock_gettime().
* src/util.c: Replace maketime.h and partime.h with getdate.h.
(fetchname): Replace str2time() with get_date().  Sanitize the test
for epoch timestamps.
* src/patch.c (main): When --set-utc is given, set the TZ environment
variable to UTC so that get_date() will default to UTC timestamps.
* tests/preserve-mode-and-timestamp: Switching to get_date() revealed
that str2time() was ignoring timezones.  In order to test --set-utc
now that get_date() fixes this, we must use timestamps that do not
include timestamps here.
* bootstrap.conf: Add the clock-time, getdate, gettime, and setenv
modules.
2010-04-22 01:32:55 +02:00
Andreas Gruenbacher
3693996297 Use struct timespec instead of time_t internally
* src/pch.h (pch_timestamp): Return timestamp as struct timespec
instead of time_t.
* src/pch.c: Use struct timespec instead of time_t.  A tv_sec value
of -1 indicates "no timestamp".
* src/util.h (fetchname): Return timestamp as struct timespec
instead of time_t.
* src/util.c (fetchname): str2time() does not give us nanoseconds; set
them to zero for now.
* src/patch.c (main): Only use the seconds in timestamps for now.
* bootstrap.conf: Add the time module for getting struct timespec
declared on old hosts.
2010-04-22 00:43:29 +02:00
Andreas Gruenbacher
f97abc39d2 diffseq: Use the gnulib version instead of a private copy
* diffseq: Use the gnulib version instead of a private copy.
2010-04-19 01:35:28 +02:00
Andreas Gruenbacher
7fa8417c05 Convert to automake and use a git submodule for gnulib
* configure.ac: Add automake and gnulib macros, replace several
obsolete macros.
* Makefile.am, lib/Makefile.am, src/Makefile.am, tests/Makefile.am:
Add for automake.
* autogen.sh, INSTALL, Makefile.in, mkinstalldirs, update-version.sh:
Obsolete; remove.
* README-hacking: Import from diffutils, replace cvs with git.
* build-aux: Move gnulib auxiliary files here from the top-level
directory.
* gnulib: Add gnulib git submodule.
* bootstrap, bootstrap.conf: Import from gnulib and adjust.
* gl/lib: Remove gnulib files from the repository; they are now
imported into lib/ from gnulib as needed.
* tests/test-lib.sh: Use $abs_top_builddir exported from
tests/Makefile.am here instead of $PWD.
* m4/utimbuf.m4: This macro has been removed from gnulib. Add it here
for now; this will be replaced by gnulib's utimens module soon.
2010-04-12 16:27:55 +02:00