* bootstrap.conf: use intprops module.
* src/common.h: Define LINENUM_MIN and LINENUM_MAX macros.
* src/pch.c (another_hunk): Add line number overflow checking. Based on Robert
C. Seacord's INT32-C document for integer overflow checking and Tobias
Stoeckmann's "integer overflows and oob memory access" patch for FreeBSD.
* bootstrap.conf: use xmemdup0 module.
* src/pch.c (there_is_another_patch): Use xmemdup0 instead of savebuf when we
cannot recover from out-of-memory situations.
(intuit_diff_type): Likewise, use xstrdup instead of savestr.
(another_hunk): Handle the case when savestr returns NULL.
* src/util.c (fetchname, parse_name): Use xmemdup0 instead of savebuf when we
cannot recover from out-of-memory situations.
Bugs pointed out by Tobias Stoeckmann <tobias@stoeckmann.org>.
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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.