1 2009-11-12 Andreas Gruenbacher <agruen@suse.de>
3 * NEWS: Version 2.6 released.
5 2009-10-27 Andreas Gruenbacher <agruen@suse.de>
7 * patch.man: Fix typo (reported by Vytautas Ĺ altenis).
9 * src/merge.c: Clarify the message when (part of) a hunk cannot be
11 * tests/merge: Adapt the test case.
13 2009-09-04 Andreas Gruenbacher <agruen@suse.de>
15 * Makefile.in (LIBSRCS, LIBHDRS, LIBM4FILES): Add the gnulib which
16 were imported on 2009-06-05 here as well.
18 * src/partime.c (main): Try to preserve the owning group of patched
21 2009-07-19 Andreas Gruenbacher <agruen@suse.de>
23 * gl/lib/full-write.c, gl/lib/safe-write.c, gl/lib/full-write.h,
24 gl/lib/safe-write.h, gl/m4/safe-write.m4, gl/m4/ssize_t.m4:
25 Import full_write() and its prerequesites from gnulib.
26 * Makefile.in (LIBSRCS, LIBHDRS, LIBM4FILES): Add new files.
28 * configure.ac (gl_SAFE_WRITE): Needef for full_write().
29 * src/util.c: Include full-write.h.
30 (copy_to_fd): use full_write() instead of write().
32 * src/partime.c: The -m option hasn't been officially allocated yet.
33 Use only the long form for now (--merge).
35 2009-06-15 Andreas Gruenbacher <agruen@suse.de>
37 * src/util.c (move_file): Don't fail when removing nonexistent
38 files: this condition is already checked in maybe_reverse().
40 2009-06-05 Andreas Gruenbacher <agruen@suse.de>
42 * gl/lib/getopt_int.h, gl/lib/strndup.c, gl/m4/strndup.m4: Add
43 some missing gnulib files.
44 * Makefile.in (GETOPT_H): Include subdirectory (gl/lib/) when
45 using the gnulib version.
47 * src/patch.c: When sending output to stdout, use dup2 to redirect
48 messages to stderr; simply assigning stderr to stdout doesn't work on
50 * gl/lib/dup2.c, gl/m4/dup2.m4: Import from gnulib.
52 * gl/lib/rename.c, gl/m4/rename.m4: Import from gnulib for platforms
55 2009-05-12 Andreas Gruenbacher <agruen@suse.de>
57 * src/merge.c (locate_merge): Make sure to return a line number
58 bigger than last_frozen_line.
60 * src/patch.c (explicit_inname): New variable.
61 (get_some_switches): Set to true when the filename to patch has been
62 specified on the command line.
63 (reinitialize_almost_everything): Do not reset the input filename
64 between patches when it has been specified on the command line.
65 * tests/inname: New test case.
66 * Makefile.in: Add test case.
68 2009-04-11 Vincent Legoll <vincent.legoll@gmail.com>
70 * src/patch.c (main): Always set patch_get to 0 unless PATCH_GET is
72 * patch.man: Update accordingly.
74 2009-04-11 Andreas Gruenbacher <agruen@suse.de>
76 * update-version.sh, configure.ac, Makefile.in: Portability
79 2009-04-08 Andreas Gruenbacher <agruen@suse.de>
81 * src/patch.c (create_output_file): Add support for sending output
83 (main): Allow -o -. Remove redundant check.
84 * patch.man: Document the new use of -o.
86 * src/pch.c (there_is_another_patch): Allow special characters in
87 filenames read interactively.
89 * src/util.c (fetchname): Don't forget to NUL terminate ptimestr.
91 2009-04-07 Andreas Gruenbacher <agruen@suse.de>
93 * src/util.c (file_id_hasher): Adapt to Gnulib type change.
94 * Makefile.in: Fix out-of-tree builds.
95 (dist): Optionally also create bzip2 and xz tarballs.
98 * patch.man: Replace "systems like DOS" with "Windows". Spelling.
100 Preserve timestamps in reject files.
101 * src/pch.c (p_timestr): New variable.
102 (intuit_diff_type): Set p_timestr here through fetchname().
103 (pch_timestr): New function.
104 * src/pch.h (pch_timestr): Declare.
105 * src/util.c (fetchname): Return the timestamp as string when asked to.
106 * src/util.h (fetchname): Update declaration.
107 * tests/preserve-c-function-names, tests/reject-format: Update.
109 2009-04-06 Andreas Gruenbacher <agruen@suse.de>
111 Fix the "patch would create" fix from 2009-03-28.
112 * src/pch.c (maybe_reverse): New function.
113 (intuit_diff_type): Move the check back here from
114 there_is_another_patch(), but compute it using maybe_reverse(). If
115 an input file name has been specified, do this check here as well.
116 * src/patch.c (main): Only set outname if we are not skipping the
118 * src/inp.c (get_input_file): We may get here without a file to read
119 as well now; don't abort in this case.
120 * tests/create-delete: Add test cases covering the previously-broken
123 * Makefile.in (MISC): Add config.guess and config.sub.
125 * src/partime.c (parse_pattern_letter): Fix for timestamps with
126 seconds > 59.5 from Christian Franke.
128 2009-04-05 Andreas Gruenbacher <agruen@suse.de>
130 * util.c (create_backup): We also need to create base directories
131 with a --prefix without slashes and a filename with slashes. A
132 --suffix cannot contain slashes, though.
133 * merge.c (merge_hunk): Add missing outstate->zero_output = false.
135 Move all source and header files into src/.
136 * Makefile.in, tests/test-lib.sh, configure.ac: Update accordingly.
137 Move all Gnulib files below gl/, and all other source and header
139 * Makefile.in, tests/test-lib.sh, configure.ac, autogen.sh: Update
141 * m4/st_mtim.m4: Remove (obsolete since 2009-03-28).
143 Update to the latest version of Gnulib.
144 * config.guess, config.sub, gl/lib/getopt.hin, gl/lib/mbrtowc.c,
145 gl/lib/stripslash.c, gl/lib/verify.h, gl/lib/xstrndup.c,
146 gl/lib/xstrndup.h, gl/m4/argmatch.m4, gl/m4/double-slash-root.m4,
147 gl/m4/gettext.m4, gl/m4/inline.m4, gl/m4/minmax.m4,
148 gl/m4/xstrndup.m4: New files.
149 * gl/lib/argmatch.c, gl/lib/argmatch.h, gl/lib/backupfile.c,
150 gl/lib/backupfile.h, gl/lib/basename.c, gl/lib/dirname.c,
151 gl/lib/dirname.h, gl/lib/error.c, gl/lib/error.h, gl/lib/exitfail.c,
152 gl/lib/exitfail.h, gl/lib/getopt.c, gl/lib/getopt1.c, gl/lib/gettext.h,
153 gl/lib/hash.c, gl/lib/hash.h, gl/lib/malloc.c, gl/lib/memchr.c,
154 gl/lib/quote.c, gl/lib/quote.h, gl/lib/quotearg.c, gl/lib/quotearg.h,
155 gl/lib/realloc.c, gl/lib/strcasecmp.c, gl/lib/strncasecmp.c,
156 gl/lib/unlocked-io.h, gl/lib/xalloc.h, gl/lib/xmalloc.c: Modified.
157 * gl/m4/backupfile.m4, gl/m4/d-ino.m4, gl/m4/dirname.m4, gl/m4/dos.m4,
158 gl/m4/error.m4, gl/m4/exitfail.m4, gl/m4/extensions.m4,
159 gl/m4/getopt.m4, gl/m4/hash.m4, gl/m4/malloc.m4, gl/m4/mbrtowc.m4,
160 gl/m4/mbstate_t.m4, gl/m4/memchr.m4, gl/m4/onceonly.m4, gl/m4/quote.m4,
161 gl/m4/quotearg.m4, gl/m4/realloc.m4, gl/m4/stdbool.m4,
162 gl/m4/unlocked-io.m4, gl/m4/utimbuf.m4, gl/m4/xalloc.m4: Likewise.
163 * install-sh, mkinstalldirs: Likewise.
164 * gl/lib/stdbool.hin: Renamed from gl/lib/stdbool_.h.
165 * gl/lib/getopt.h: Removed (should be generated).
166 * gl/lib/addext.c: Removed from Gnulib.
168 Replace memory_fatal() with xalloc_die(). The FILESYSTEM_PREFIX_LEN()
169 macro has been renamed to FILE_SYSTEM_PREFIX_LEN().
170 * src/patch.c (main): Remove xalloc_fail_func (replaced by
171 xalloc_die()). Work around the missing addext() with
172 find_backup_file_name() plus hacks.
173 * src/util.c (create_backup, version_controller): The new versions of
174 base_name() and dir_name() return malloc'ed buffers. Adapt.
175 * src/util.h: Replace memory_fatal() with xalloc_die().
176 * src/pch.c: Don't leak memory with strlen (base_name (...)).
178 * src/util.c (create_file): Add to_dir_known_to_exist argument and
179 try to create parent directories when set and the create failed with
181 (copy_file, create_backup_copy): Pass the new to_dir_known_to_exist
183 (create_backup): Don't assume the target directory exists when making
185 * src/util.h (create_file, copy_file): Change the declarations.
186 * src/patch.c, src/pch.c, src/inp.c: In the calls to create_file() and
187 copy_file(), assume the parent directory exists.
188 * tests/unmodified-files: Test the create_backup() fix.
190 * src/util.c (create_backup): The new dir_name() and base_name()
191 functions are really counter productive. Remove them and the bugs
192 that keepeing them here as introduced.
193 * tests/backup-prefix-suffix: Add more regression tests.
195 * src/patch.c (locate_hunk): Revert to the original asymmetric hunk
196 behavior (but only anchor hunks starting at line 0 to the start of the
197 file): there is not enough reason to change the historic behavior.
198 * src/merge.c (locate_merge): Add similar asymmetric hunk check here.
199 * tests/asymmetric-hunks: Update accordingly.
200 * patch.man: Document the asymmetric hunk behavior.
203 Copyright notice updates.
204 * README, AUTHORS: Updates.
206 * patch.man: Document that merging can be slow.
207 * tests/test-lib.sh: Also unset QUOTING_STYLE.
209 2009-04-04 Andreas Gruenbacher <agruen@suse.de>
211 * pch.c (another_hunk): Add (back) the line number ranges to the
213 * merge.c (merge_hunk): Likewise.
214 (locate_merge): Add a note about the algorithm's requirements.
215 * util.c (create_backup): Split from move_file. New LEAVE_ORIGINAL
216 argument for copying instead of renaming. Don't fail when rename
217 fails with errno == EXDEV; copy and unlink in that case instead.
218 (copy_file): Add debug message.
219 * util.h: Move including <utime.h> etc. here from patch.c.
220 (create_backup): Declare.
221 * patch.c (main): Create backup files even for files which did not
222 actually change; some users of patch rely on the presence of backup
223 files when patch says "patching file".
224 * tests/unmodified-files: Test the patch.c change. (The EXDEV fix in
225 create_mackup() was tested manually.)
226 * util.c (copy_to_fd, ask): The read() return type is ssize_t.
228 2009-04-03 Andreas Gruenbacher <agruen@suse.de>
230 * patch.man: Document the -m or --merge option. Some minor other
232 * NEWS: Document the asymmetric hunk behavior and the -m or --merge
234 * merge.c (locate_merge): Include the number of changes in the debug
236 (print_linerange): New function.
237 (merge_result): No longer print line offsets: without exact matches,
238 line numbers are less meaningful. Output the entire messages here.
239 (merge_hunk): Be silent when merging exact matches unless in
241 * tests/merge: Add another interesting test case.
243 * tests/test-lib.sh: Add have_ed function for checking if ed is
245 * tests/crlf-handling, tests/need-filename: Check for ed and skip the
246 ed related tests if we don't have it.
247 * tests/merge: Use sed instead of ed: sed is more readily available.
249 * patch.c (locate_hunk): If a hunk starts at a line > 1, it obviously
250 is not from the start of the file.
251 * tests/asymmetric-hunks: Add tests for all possible cases.
253 2009-04-02 Andreas Gruenbacher <agruen@suse.de>
255 * patch.c (locate_hunk): Revert the assymmetric hunk fix from
256 2009-03-29. Instead, allow such hunks to apply only when no
257 more context remains.
259 * patch.c (main): Restructure to get rid of some code duplication.
260 (copy_till, similar): Export these functions.
261 * common.h (struct outstate, in_offset, out_offset,
262 last_frozen_line): Move here from patch.c.
263 (apply_hunk, copy_till, similar): Declare here.
265 Simple merge support:
266 * configure.ac (ENABLE_MERGE): New --disable-merge option.
267 * patch.c (merge): New variable.
268 (main): New -m and --merge options. When in merge mode, don't try
269 to reverse patches, and don't try to apply with fuzz.
270 * common.h (merge_hunk): Declare function.
271 * merge.c: New file containing all the merge code.
272 * tests/merge: New test case.
273 * Makefile.in (SRCS): Add merge.c.
274 (OBJS): Add merge.$(OBJEXT) when merge support is enabled.
275 (TESTS): Add test case.
276 (COMPILE): Define ENABLE_MERGE when merge support is enabled.
278 Locate hunks to merge more intelligently:
279 * bestmatch.h: Shortest Edit Sequence algorithm.
280 * merge.c (locate_merge, count_fuzz_lines): New functions.
281 (merge_hunk): Replace simple guessing with locate_merge().
282 * Makefile.in (HDRS): Add bestmatch.h.
283 * tests/merge: Only minor improvements up to now.
285 * diffseq.h: New file (Gnulib compareseq algorithm).
286 * minmax.h: New file (Gnulib MIN and MAX macros).
287 * Makefile.in (HDRS): Add diffseq.h and minmax.h.
289 * COPYING: Update to GPL version 3 because of diffseq.h.
291 * diffseq.h: When an EQUAL_IDX macro is defined, use that instead
292 of EQUAL. This macro takes vector indexes instead of elements as
295 Better merge support:
296 * patch.c, common.h (apply_hunk): Make static again.
297 * merge.c (compute_changes): New function for computing the
298 difference between lines in a hunk and lines in the input file.
299 (merge_result): We may have more than one result per hunk now.
300 (merge_hunk): Merge the hunk with the compute_changes() result.
301 * tests/merge: Better results now.
303 * merge.c: Add license header.
305 * merge.c (locate_merge): The number of changes allowed permits a
306 higher maximum merge position (max_where).
307 * tests/merge: Add a test for this case.
309 * merge.c (merge_hunk): Add two missing checks that were leading into
311 * tests/merge: Add test cases for each of these checks.
313 * Makefile.in (install, uninstall): DESTDIR specifies a prefix to
314 the root directory to install into.
315 (installdirs): Merge with install.
317 2009-04-01 Andreas Gruenbacher <agruen@suse.de>
319 * tests/test-lib.sh: When $GDB is set, run patch in gdbserver
321 * pch.c (another_hunk): Make the debug output easier to read.
323 2009-03-31 Andreas Gruenbacher <agruen@suse.de>
325 * patch.c: Split last_offset into in_offset and out_offset and
326 count line numbers properly.
327 * tests/line-numbers: Without the fixes, this test case goes
329 * Makefile.in (TESTS): Add test case.
331 2009-03-30 Jim Meyering <meyering@redhat.com>
333 tests: accommodate ls' "alternate access control method" indicator
334 ls can output an additional byte after a file's permissions string,
335 e.g., rather than "rwxr--r-- ..." it can output "rwxr--r--+ ..."
336 or "rwxr--r--. ..." to indicate the presence of an ACL.
337 * tests/create-delete: Adjust sed filter to accommodate that.
338 * tests/preserve-mode-and-timestamp: Likewise.
340 2009-03-30 Andreas Gruenbacher <agruen@suse.de>
342 * tests/test-lib.sh: Unset environment variables that influence
343 the behavior of patch.
344 * util.c (move_file): Add debug message when files have been seen
345 already. Fix leftover "empty uneadable" debug message.
347 * patch.c (main): Print newline earlier.
348 * util.c (copy_file): Add debug message.
350 2009-03-29 Andreas Gruenbacher <agruen@suse.de>
352 * patch.c (locate_hunk): Hunks that have fewer or more lines of
353 context at the beginning than at the end can match anywhere; the
354 assumption that this can only occur at the beginning or end of the
355 file is wrong. Remove those checks.
356 * tests/asymmetric-hunks: New test case.
357 * Makefile.in (TESTS): Add test case.
359 * util.c (move_file): Create backup files of nonexisting files with
360 the default mode instead of mode 0: files with mode 0 cause too many
361 problems with applications which do not expect unreadable files.
362 * tests/create-delete: Test for this.
364 * Makefile.in (BROKEN_TESTS): Test cases which fail.
366 2009-03-28 Andreas Gruenbacher <agruen@suse.de>
368 * pch.c (intuit_diff_type): Rename need_filename argument to
369 need_header. Omit superfluous "missing header" warnings.
371 When remembering files including timestamps, we need to update the
372 timestamps after appending to a file. This causes problems on some
373 systems where the timestamps returned by fstat() after appending are
374 not up to date, yes. We only remember timestamps as a compatibility
375 hack with non-POSIX systems that do not have unique inode numbers;
376 drop this hack instead.
377 * timespec.h, m4/timespec.m4: Remove.
378 * util.c: Remove timespec.h and all uses of struct timespec.
379 (append_to_file): Remove REMEMBER argument; no need to update known
381 * util.h (append_to_file): Update definition.
382 * Makefile.in: Remove timespec.h and m4/timespec.m4.
384 * common.h (origsuff): New variable.
385 * patch.c (main): Remember when -z was used.
386 * util.c (contains_slash): New function.
387 (move_file): Enforce simple backup mode and compute the backup file
388 name here if -B, -Y, or -z is used. Fix the case where -B or -Y is
390 * patch.man: Document this change.
391 * tests/backup-prefix-suffix: New test case.
392 * Makefile.in (TESTS): Add test case.
394 * tests/munged-context-format: New test case.
395 * Makefile.in (TESTS): Add test case.
397 * util.c (vsay): New function for use in say(), etc.
398 (ok_to_reverse): Use vsay() here instead of fprintf() to ensure
401 * pch.c (there_is_another_patch): Move the "patch would create" test
402 here from intuit_diff_type() after asking for the filename to patch.
403 * inp.c (get_input_file): No need to report when the file is missing;
404 this is done in there_is_another_patch() already.
405 * patch.c (main): No need to report when a patch attempts to create
406 an exiting file, either.
408 2009-03-25 Andreas Gruenbacher <agruen@suse.de>
410 * patch.c (main): Avoid replacing files when nothing has changed.
411 * tests/unmodified-files: New test case.
412 * Makefile.in (TESTS): Add test case.
414 * patch.c (main): New apply_empty_patch variable. When applying an
415 empty patch to a file and -o is given, copy the input file to the
418 2009-03-24 Andreas Gruenbacher <agruen@suse.de>
420 * patch.c (abort_hunk_unified, abort_hunk_context): Preserve
421 Index lines in reject files as well.
422 * tests/reject-format: Test this change.
424 * configure.ac (TEST_SHELL): New substitution.
425 * Makefile.in (TEST_SHELL): New variable.
426 (HAVE__BOOL): New variable.
427 (hash.$(OBJEXT)): Add $(STDBOOL_H) dependency.
428 * tests/test-lib.sh: Use expr for arithmetic operations. Check for
429 working "echo -n" and BASH_LINENO. Replace printf with echo.
430 * tests/preserve-mode-and-timestamp: Ignore leading "+" in ls output.
431 * tests: Remove !shebang line from tests and make them non-executable.
432 Replace printf with echo.
434 2009-03-23 Andreas Gruenbacher <agruen@suse.de>
436 * patch.c (intuit_diff_type): When looking for an ed or normal
437 patch, don't look for filename headers. (Those formats don't
439 * pch.c (there_is_another_patch): Don't suggest to use -p with
440 normal format diffs for the same reason.
442 2009-03-22 Andreas Gruenbacher <agruen@suse.de>
444 * NEWS: Update for alpha release.
446 * patch.c (main): Always initialize the known files table.
447 Move new reject files into place; append to known ones.
448 * util.c (file_already_seen): Export.
449 (move_file): Remember all files, not only backup files.
450 (append_to_file): When asked to remember a file, remember
451 the state *after* appending. (The timestamps will change!)
452 * tests/remember-reject-files: New test case.
453 * Makefile.in (TESTS): Add test case.
455 * common.h (no_strip_trailing_cr): New variable.
456 * patch.c: Use no_strip_trailing_cr. Option --binary no longer
457 a no-op on POSIX systems.
458 * patch.man: Document change of --binary.
459 * pch.c (there_is_another_patch): Check no_strip_trailing_cr.
460 * tests/crlf-handling: Add --binary tests here.
462 * patch.c (apply_hunk): Use fputs() in simple fprintf()
465 * patch.c (main): Require filename in patch if none specified on
466 the command line and posixly_correct is false.
467 * pch.c (intuit_diff_type): While we still don't have a filename,
468 don't look for hunks.
469 (there_is_another_patch): Pass need_filename through.
470 * tests/need-filename: New test case.
471 * Makefile.in (TESTS): Add test case.
473 * pch.c (intuit_diff_type): Check for garbage after what looks
474 like a normal format command.
475 * tests/normal-garbage: New test case.
476 * Makefile.in (TESTS): Add test case.
478 * Makefile.in (bindir): Define as @bindir@.
479 (DISTFILES_CLEAN): Move DISTFILES here which must not be remade by
481 (MISC): Add missing tests/test-lib.sh and update-version.sh.
482 (check, $(TESTS)): Make each test depend on all so that they can be
484 (maintainer-clean): Also remove patch-*.tar.gz and patch-*.tar.gz.sig.
485 (dist): Add PV directory level. Add reminder to self how to upload.
486 * configure.ac: Silence "missing datarootdir" warning.
488 * tests/crlf-handling: Add test for "diff -p" context with a CRLF
491 2009-03-21 Andreas Gruenbacher <agruen@suse.de>
493 * patch.c (main): With -r, instead of moving the global reject
494 file into place, copy the first reject into the file, and
495 append all the rest. Discard rejects with -r -.
496 * patch.man: Document the latter.
497 * util.c (copy_to_fd): New function.
498 (copy_file): Use that.
499 (append_to_file): New function.
500 * util.h (append_to_file): Add function declaration.
501 * tests/global-reject-files: New test case.
502 * Makefile.in (TESTS): Add test case.
504 * patch.man: Minor fix.
506 * pch.c (another_hunk, pch_swap): Always add the '^' hunk end
507 marker: apply_hunk() and abort_hunk_unified() rely on it.
508 (pch_char): Explain when this returns '\n'.
509 * util.c: Remove unused include <version.h>.
511 2009-03-20 Andreas Gruenbacher <agruen@suse.de>
513 * patch.c: New option --reject-format=FORMAT.
514 (abort_hunk_context): Rename from abort_hunk().
515 (abort_hunk_unified, abort_hunk, mangled_patch,
516 print_unidiff_range): New functions.
517 * patch.man: Document this.
518 * pch.c, pch.h (pch_normalize): New function.
519 * tests/reject-format: New test case.
520 * Makefile.in (TESTS): Add test case.
521 * tests/preserve-c-function-names: Update.
523 * pch.c (p_name): New variable.
524 (intuit_diff_type): Save the old, new, and index filenames.
525 (pch_char): Return either of the saved filenames.
526 * pch.h: Move enum nametype here from pch.c. Declare pch_name().
527 * patch.c (abort_hunk, abort_hunk_unified, abort_hunk_context):
528 New HEADER and REVERSE arguments.
529 (print_header_line): New function.
530 (abort_hunk_unified, abort_hunk_context): Use it.
531 * tests/corrupt-reject-files, tests/preserve-c-function-names,
532 tests/reject-format: Update.
534 * patch.c (main): No longer set reject file modes to the modes of the
535 files they are assiciated with: the previous behavior is inconsistent
536 with global reject files (-r), which are not associated with any
538 * tests/preserve-mode-and-timestamp: New test case.
539 * Makefile.in (TESTS): Add test case.
541 * Makefile.in (DISTFILES): Add the files from DISTFILES_M4,
542 DISTFILES_PC, DISTFILES_PC_DJGPP.
543 (DISTFILES_M4, DISTFILES_PC, DISTFILES_PC_DJGPP): Remove.
544 (distclean): Also remove config.hin~ and autom4te.cache/.
545 (maintainer-clean): Also remove aclocal.m4, config.hin, configure.
546 (dist): Make work for DISTFILES in subdirectories. Normalize and
549 * Makefile.in (MISC): Add VERSION.
551 (VERSION): Recompute automatically from repository.
552 (configure): Depend on VERSION. Regenerate with --force: autoconf
553 does not recognize the dependency between VERSION and ocnfigure.
554 (config.hin): Regenerate with --force.
555 (maintainer-clean): Also remove VERSION.
556 * configure.ac: Compute PACKAGE_VERSION from repository.
557 * update-version.sh: New file.
559 * README-alpha: New file.
560 * Makefile.in (dist): Add README-alpha when appropriate.
562 * Makefile.in (M4FILES): Rename from ACINCLUDE_INPUTS.
563 (aclocal.m4): Recompute with aclocal.
565 * tests/test-lib.sh: Add library for simple test scripts.
566 * tests/crlf-handling, tests/remember-backup-files: New test cases.
567 * Makefile.in (TESTS): New variable. Add test cases.
568 (check): Replace the dummy test target with running all TESTS.
570 * pch.c, pch.h (pch_c_function): New function.
571 * pch.c (p_c_function): New variable.
572 (another_hunk): Preserve the "diff -p" output.
573 * patch.c (abort_hunk): Use pch_c_function().
574 * tests/preserve-c-function-names: New test case.
575 * Makefile.in (TESTS): Add test case.
577 * util.c (savebuf): Return NULL if size == 0.
578 * pch.c (another_hunk): Check size for size != 0 before checking
579 savebuf()'s return value.
580 * tests/no-newline-triggers-assert: New test case.
581 * Makefile.in (TESTS): Add test case.
583 * tests/corrupt-reject-files: new test case for Jim Meyering's
585 * Makefile.in (TESTS): Add test case.
587 2009-03-19 Andreas Gruenbacher <agruen@suse.de>
589 Imported from Paul Eggert's working directory:
590 * exitfail.c, exitfail, m4/exitfail.m4: Import from gnulib.
591 * hash.c, hash.h, m4/hash.m4: Likewise.
592 * m4/extensions.m4: Likewise.
593 * timespec.h, m4/timespec.m4: Likewise.
594 * m4/st_mtim.m4: New file.
595 * configure.ac: Update.
596 * common.h: Include <limits.h> unconditionally. Include <stdint.h>
598 * inp.c (plan_b, ifetch): Remove unnecessary casts.
599 * maketime.c, partime.c: Include <limits.h>, <stdlib.h>, <time.h>
600 unconditionally. Convert from K&R to ANSI C.
601 * maketime.h, partime.h: Convert from K&R to ANSI C.
602 * pch.c (p_indent, pget_line, intuit_diff_type): Use size_t for
604 * util.c: Assume we have vfprintf().
605 (NUM_SIGS): Cast to int in.
606 (fatal_exit_handler): Replace obsolescent AC_RETSIGTYPE.
607 * Various files: Update copyright notices.
609 2007-08-26 Jim Meyering <jim@meyering.net>
611 * pch.c (another_hunk): Avoid an off-by-one error that would
612 result in NUL bytes in .rej files.
614 2004-07-21 Paul Eggert <eggert@twinsun.com>
616 * Makefile.in (SRCS): Move hash.c here from LIBSRCS.
617 (exitfail.$(OBJEXT), patch.$(OBJEXT), xmalloc.$(OBJEXT)):
618 Depend on exitfail.h.
619 (hash.$(OBJEXT), util.$(OBJEXT)): Depend on hash.h.
620 * util.c: Whitespace cleanup in file_id.
622 2004-07-19 Stepan Kasal <kasal@ucw.cz>
624 * pch.c (get_ed_command_letter): Allow commands without address.
626 2003-11-10 Manu B <manubee@users.sourceforge.net>
628 Trivial change to port to mingw, which declares mkdir in unistd.h.
629 * m4/mkdir.m4 (PATCH_FUNC_MKDIR_TAKES_ONE_ARG): Include unistd.h.
630 * common.h (mkdir): Define after including unistd.h.
632 2003-09-11 Paul Eggert <eggert@twinsun.com>
634 * pch.c (do_ed_script): Adjust to copy_file signature change.
636 * Makefile.in (STDBOOL_H): New macro. All uses of @STDBOOL_H@ changed.
637 (SRCS): Add exitfail.c.
638 (OBJS): Add exitfail.$(OBJEXT).
639 (HDRS): Add exitfail.h.
640 (stdbool.h): Use $@, as gnulib now suggests.
641 (ACINCLUDE_INPUTS): Add exitfail.m4, extensions.m4.
642 * common.h: Include <string.h>, <stdlib.h> unconditionally.
643 * configure.ac (gl_USE_SYSTEM_EXTENSIONS): Use this instead
646 * patch.c: Include exitfail.h.
647 (main): Set exit_failure, not xalloc_exit_failure.
649 * inp.c (get_input_file): Clear cs if dry run.
651 * util.c (fetchname): Handle missing timestamps better.
653 * Makefile.in (LIBSRCS): Add hash.c.
654 (OBJS): Add hash.$(OBJEXT).
656 (MISC): Add timespec.h.
657 (ACINCLUDE_INPUTS): Add hash.m4, st_mtim.m4, timespec.m4
658 (util.$(OBJEXT): Depend on timespec.h.
659 * configure.ac (gl_HASH, gl_TIMESPEC): Add.
660 * patch.c (spew_output): New output arg, to contain status of output
662 (main): Use it to get status of output file, and pass this to
663 move_file as needed. Initialize hash table.
664 * util.c (file_id): New type.
665 (file_id_hasher, file_id_comparator, init_backup_hash_table,
666 insert_file, file_already_seen): New functions.
667 (file_id_table): New var.
668 (move_file): New arg FROMST; all uses changed.
669 Do not backup a file that's already been patched.
670 Keep track of files that have been patched.
671 (copy_file): New arg TOST; all uses changed.
672 * util.h (copy_file, move_file): Adjust decls as per above.
673 (init_backup_hash_table): New decl.
676 2003-07-05 Paul Eggert <eggert@twinsun.com>
678 * Makefile.in (check): Add a trivial check that "patch --help" works.
679 From a suggestion by Ed Avis.
681 2003-07-02 Paul Eggert <eggert@twinsun.com>
683 * pch.c (intuit_diff_type): If a unified-diff header line contains
684 trailing CR, strip CR from each body line. This corrects a bug
685 introduced in the 2003-05-18 patch. Bug reported by Andreas
688 * mkdir.c, rmdir.c, m4/rmdir.m4: Remove; we no longer
689 need to worry about ancient hosts that lack these functions.
691 * addext.c, backupfile.c, backupfile.h, dirname.h, m4/backupfile.m4,
692 m4/onceonly.m4, m4/quote.m4, malloc.c, quote,c, quote.h, realloc.c,
693 strcasecmp.c, xalloc.h, xmalloc.c: Sync with gnulib.
694 * stdbool_.h: Renamed from stdbool.h.in; all uses changed.
695 This renaming is imported from gnulib.
696 * m4/strcase.m4: New file, imported from gnulib.
698 * Makefile.in (LIBSRCS): Remove mkdir.c and rmdir.c.
699 (stdbool.h): Put output into temporary file and then rename it;
700 this change is imported from gnulib.
701 (mostlyclean): Clean stdbool.h-t too.
702 (ACINCLUDE_INPUTS): Remove rmdir.m4. Add strcase.m4.
703 * configure.ac (gl_FUNC_RMDIR): Remove.
704 (jm_PREREQ_ADDEXT): Remove; now down by gl_BACKUPFILE.
705 (gl_STRCASE, gl_XALLOC): Add.
706 (AC_REPLACE_FUNCS): Remove mkdir, strcasecmp.
708 2003-05-20 Paul Eggert <eggert@twinsun.com>
710 * NEWS, configure.ac (AC_INIT): Version 2.5.9 released.
712 * Makefile.in (HDRS): Add gettext.h.
714 Use bool, not int, for booleans.
716 * pch.c (pch_says_nonexistent): Returns int, not bool.
718 * configure.ac: Add AM_STDBOOL_H.
720 * Makefile.in (MISC): Add stdbool.h.in.
721 (stdbool.h): New rule.
722 (ACINCLUDE_INPUTS): Add stdbool.m4.
723 (mostlyclean): Remove stdbool.h.
724 (COMMON): New macro; use it instead of common.h for dependencies.
726 * common.h: Include <stdbool.h>.
727 Remove TRUE, FALSE, bool. All uses changed to standard names.
729 * common.h (reverse, set_time, set_utc):
730 Use bool, not int, for booleans.
731 * pch.c (p_strip_trailing_cr, p_pass_comments_through,
732 prefix_components, pget_line, re_patch,
733 there_is_another_patch, intuit_diff_type, scan_linenum,
734 another_hunk, pget_line, pch_timestamp): Likewise.
735 * inp.h (ifetch): Likewise.
736 * util.c (move_file, version_controller, version_get, ok_to_reverse,
737 set_signals): Likewise.
738 * inp.c (report_revision, get_input_file, plan_a, plan_b, ifetch):
740 * util.h (ok_to_reverse, version_controller, version_get,
741 move_file, set_signals): Likewise.
742 * pch.h (another_hunk, pch_says_nonexistent, pch_timestamp):
744 * patch.c (struct outstate, numeric_string, make_backups,
745 backup_if_mismatch, remove_empty_files,
746 reverse_flag_specified, main, reinitialize_almost_everything,
747 get_some_switches, apply_hunk, init_output, copy_till):
750 2003-05-18 Paul Eggert <eggert@twinsun.com>
752 * pch.c (p_pass_comments_through): New var.
753 (pget_line): Accept new arg for pass_comments_through.
755 (there_is_another_patch): Do not suggest -p for ed diffs.
756 (intuit_diff_type): Check ed command for correct syntax.
757 Do not set p_strip_trailing_cr merely because a -p line contains a CR.
758 (get_ed_command_letter): New function.
759 (do_ed_script): Use it. Do not treat '#' data lines as comments in ed
762 * util.c (move_file):
763 Don't assume that when 'rename(A,B)' succeeds then A no
764 longer exists. This is not true of POSIX 1003.1-2001 rename when A
765 and B are links to the same file.
766 (fetchname): Fix test for file names with internal spaces.
768 * version.c: Don't include patchlevel.h.
769 (version): Use PACKAGE_NAME and PACKAGE_VERSION instead of obsolete
770 PROGRAM_NAME and PATCH_VERSION.
771 (copyright_string): Bump to 2003.
773 * common.h (FILESYSTEM_PREFIX_LEN, ISSLASH):
774 Remove; now done by 'configure'.
775 (PROGRAM_NAME): Remove; now done by 'configure' as PACKAGE_NAME.
777 * patch.c: Do not include <exitfail.h>.
778 (main): Set xalloc_exit_failure, not exit_failure.
779 Add "&& !skip_rest_of_patch" when deciding to continue ed scripts.
780 (option_help): Use PACKAGE_BUGREPORT rather than hardcoding.
782 * configure.ac (AC_PREREQ): Bump to 2.57.
783 (AC_GNU_SOURCE): Add, early on.
784 (gl_BACKUPFILE, gl_DIRNAME, gl_ERROR, gl_FUNC_MEMCHR, gl_FUNC_RMDIR,
785 gl_GETOPT, gl_PREREQ_XMALLOC, gl_QUOTE, gl_QUOTEARG): Add.
786 (jm_PREREQ_ADDEXT): Add, with definition.
787 (jm_PREREQ_DIRNAME, jm_PREREQ_ERROR, jm_PREREQ_MEMCHR,
788 jm_PREREQ_QUOTEARG): Remove.
789 (AC_REPLACE_FUNCS): Remove memchr, rename, rmdir).
790 (jm_FUNC_GLIBC_UNLOCKED_IO, jm_AC_DOS): Add.
791 (jm_CHECK_TYPE_STRUCT_DIRENT_D_INO): Do not call directly.
792 (AC_OUTPUT): Use new style, with AC_CONFIG_FILES.
794 Update to current CVS gnulib.
796 * exitfail.c, exitfail.h, patchlevel.h, rename.c, m4/c-bs-a.m4,
797 m4/jm-glibc-io.m4, m4/prereq.m4: Remove.
798 * m4/backupfile.m4, m4/dirname.m4, m4/dos.m4, m4/getopt.m4,
799 m4/memchr.m4, m4/onceonly.m4, m4/quote.m4, m4/quotearg.m4,
800 m4/rmdir.m4, m4/unlocked-io.m4, m4/xalloc.m4: New files.
801 * Makefile.in (LIBSRCS): Move error.c here from SRCS.
803 (OBJS): Remove error.$(OBJEXT).
804 (HDRS): Remove exitfail.h, patchlevel.h.
805 (ACINCLUDE_INPUTS): Remove c-bs-a.m4, jm-glibc-io.m4, prereq.m4.
806 Add backupfile.m4, dirname.m4, dos.m4, getopt.m4, memchr.m4,
807 onceonly.m4, quote.m4, quotearg.m4, rmdir.m4, unlocked-io.m4,
809 (patchlevel.h): Remove. All uses removed.
810 (argmatch.$(OBJEXT), error.$(OBJEXT), quotesys.$(OBJEXT)),
811 xmalloc.$(OBJEXT)): Depend on gettext.h.
812 (dirname.$(OBJEXT), quote.$(OBJEXT), strncasecmp.$(OBJEXT)): New rules.
813 (patch.$(OBJEXT), xmalloc.$(OBJEXT)): Remove exitfail.h.
814 (rename.$(OBJEXT)): Remove.
815 (version.$(OBJEXT)): Remove util.h.
816 (xmalloc.$(OBJEXT)): Add error.h.
818 2002-11-23 Paul Eggert <eggert@twinsun.com>
820 * patch.c (main): Don't check for zero-sized file after 'ed'
821 when skipping patch. From Michael Fedrowitz.
823 2002-06-03 Paul Eggert <eggert@twinsun.com>
825 * configure.ac (AC_OUTPUT): Use new form, with AC_CONFIG_FILES,
826 instead of obsolescent form. Patch from Art Haas.
828 * pch.c (intuit_diff_type): Do not warn about trailing white space
829 after Prereq: word. Bug reported by Mike Castle.
831 2002-06-02 Paul Eggert <eggert@twinsun.com>
833 * NEWS, configure.ac (AC_INIT): Version 2.5.8 released.
835 * README: POSIX.2 -> POSIX.
836 * inp.c (report_revision): Don't modify 'revision', since
837 it gets freed later. Bug reported by Mike Castle.
839 2002-05-30 Paul Eggert <eggert@twinsun.com>
841 * NEWS, configure.ac (AC_INIT): Version 2.5.7 released.
843 * Makefile.in (MISC): Remove README-alpha.
844 (patchlevel.h): Depend on configure, not configure.ac.
846 * INSTALL: Upgrade to Autoconf 2.53 version.
848 2002-05-28 Paul Eggert <eggert@twinsun.com>
850 * patch.c (end_defined, apply_hunk): Output #endif without
851 the comment, as POSIX 1003.1-2001 requires.
853 * pch.c (there_is_another_patch): Flush stderr after perror.
855 * NEWS, configure.ac (AC_INIT): Version 2.5.6 released.
857 * strcasecmp.c, strncasecmp.c: New files, taken from fileutils.
858 * config.guess, config.sub: Remove.
859 * Makefile.in (LIBSRCS): Add strcasecmp.c, strncasecmp.c.
860 (MISC): Remove config.guess, config.sub.
862 The code already assumes C89 or better, so remove K&R stuff.
863 * common.h (volatile): Remove.
864 (GENERIC_OBJECT): Remove; all uses changed to 'void'.
865 (PARAMS): Remove; all uses changed to prototypes.
866 * configure.ac (AC_PROG_CC_STDC): Add.
867 * util.c (vararg_start): Remove. All uses changed to va_start.
868 Always include <stdarg.h>.
870 * configure.ac (AC_CANONICAL_HOST): Remove.
871 (AC_REPLACE_FUNCS): Add strncasecmp.
872 (AC_CHECK_DECLS): Add mktemp.
874 * patch.c (main): Remove useless prototype decl.
875 (mktemp): Don't declare if HAVE_DECL_MKTEMP || defined mktemp.
876 (make_temp): Now accepts char, not int.
878 2002-05-26 Paul Eggert <eggert@twinsun.com>
880 * patch.c (not_defined): Prepend newline. All uses changed.
881 (apply_hunk): Fix bug: -D was outputting #ifdef when it should
882 have been outputting #ifndef. Bug report and partial fix by
885 * pch.c (intuit_diff_type): When reading an ed diff, don't use
886 indent and trailing-CR-ness of "." line; instead, use that of the
887 command. Bug reported by Anthony Towns; partial fix by Michael
889 (intuit_diff_type): If the index line exists, don't report a
890 missing header. Fix by Chip Salzenberg.
892 2002-05-26 Alessandro Rubini <rubini@gnu.org>
894 * patch.c (locate_hunk): Fixed updating of last_offset.
896 2002-05-25 Paul Eggert <eggert@twinsun.com>
898 * NEWS, README: Diffutils doc is up to date now.
899 Bug reporting address is now <bug-patch@gnu.org>.
900 * README: Describe '--disable-largefile'.
902 * NEWS-alpha, dirname.c, dirname.h, exitfail.c, exitfail.h,
903 quote.c, quote.h, unlocked-io.h: New files, taken from diffutils
906 * argmatch.c: [STDC_HEADERS]: Include stdlib.h, for 'exit'.
908 * addext.c, argmatch.c, argmatch.h, backupfile.c, basename.c:
909 Update from diffutils and fileutils.
911 * ansi2knr.1, ansi2knr.c: Remove.
913 * common.h: HAVE_SETMODE && O_BINARY -> HAVE_SETMODE_DOS.
914 * patch.c (usage): Likewise.
915 * pch.c (open_patch_file): Likewise.
917 * configure.ac: Renamed from configure.in. Add copyright notice.
918 (AC_PREREQ): Bump to 2.53.
919 (AC_INIT): Use 2.5x style.
920 (AC_CONFIG_SRCDIR): Add.
921 (PACKAGE, VERSION): Remove.
922 (AC_C_PROTOTYPES): Use this instead of AM_C_PROTOTYPES.
923 (jm_CHECK_TYPE_STRUCT_UTIMBUF): Use this instead of jm_STRUCT_UTIMBUF.
924 (jm_PREREQ_ADDEXT, jm_PREREQ_DIRNAME, jm_PREREQ_ERROR,
925 jm_PREREQ_MEMCHR, jm_PREREQ_QUOTEARG): Add.
926 (AC_CHECK_DECLS): Add free, getenv, malloc.
927 (AC_CHECK_FUNCS): Remove setmode.
928 (AC_FUNC_SETMODE_DOS): Add.
929 (jm_CHECK_TYPE_STRUCT_DIRENT_D_INO): Use this instead of
930 jm_STRUCT_DIRENT_D_INO.
932 * Makefile.in (OBJEXT): New var.
933 (PACKAGE_NAME): Renamed from PACKAGE. All uses changed.
934 (PACKAGE_VERSION): Renamed from VERSION. All uses changed.
935 (U): Remove. All uses of "$U.o" changed to ".$(OBJEXT)".
936 (LIBSRCS): REmove getopt.c getopt1.c. Add mkdir.c, rmdir.c.
937 (SRCS): Add dirname.c, exitfail.c, getopt.c, getopt1.c, quote.c.
939 (OBJS): Keep in sync with SRCS.
940 (HDRS): Remove basename.h.
941 Add dirname.h, exitfail.h, quote.h, unlocked-io.h.
942 (MISC, configure, config.hin, patchlevel.h):
943 configure.ac renamed from configure.in.
944 (MISC): Add README-alpha. Remove ansi2knr.1, ansi2knr.c.
945 (.c.$(OBJEXT)): Renamed from .c.o.
946 (ACINCLUDE_INPUTS): Add c-bs-a.m4, error.m4, jm-glibc-io.m4,
947 mbstate_t.m4, mkdir.m4, mbrtowc.m4, prereq.m4, setmode.m4.
948 Remove ccstdc.m4, inttypes_h.m4, largefile.m4, protos.m4.
949 (mostlyclean): Don't clean ansi2knr.
950 (ansi2knr.o, ansi2knr): Remove.
953 * patch.c: Include <exitfail.h>.
954 (main): Initialize exit_failure.
956 * patch.man: Update copyright notice.
958 * pch.c, util.c: Include <dirname.h>, not <basename.h>.
960 * version.c (copyright_string): Update copyright notice.
962 2002-02-17 Paul Eggert <eggert@twinsun.com>
964 * partime.c (parse_pattern_letter): Don't overrun buffer if it
965 contains only alphanumerics. Bug reported by Winni
968 2001-07-28 Paul Eggert <eggert@sic.twinsun.com>
970 * util.c (fetchname), NEWS:
971 Allow file names with internal spaces, so long as they
974 * pch.c (intuit_diff_type): Do not allow Prereq with multiple words.
976 * configure.in (AC_PREREQ): Bump to 2.50.
977 (AC_CHECK_FUNCS): Remove fseeko.
978 (AC_FUNC_FSEEKO): Add.
979 * Makefile.in (ACINCLUDE_INPUTS):
980 Remove largefile.m4; no longer needed with Autoconf 2.50.
982 2001-02-07 "Tony E. Bennett" <tbennett@nvidia.com>
984 * util.c (PERFORCE_CO): New var.
985 (version_controller): Support Perforce.
986 * patch.man: Document this.
988 2000-06-30 Paul Eggert <eggert@sic.twinsun.com>
990 * patch.man: Ignore comment lines.
992 * NEWS, pch.c: Ignore lines beginning with "#".
994 1999-10-24 Paul Eggert <eggert@twinsun.com>
996 * pch.c (another_hunk): Report a fatal error if a regular
997 context hunk's pattern has a different number of unchanged
998 lines than the replacement.
1000 1999-10-18 Paul Eggert <eggert@twinsun.com>
1002 * patch.c (main): If we skipped an ed patch, exit with nonzero status.
1004 1999-10-17 Paul Eggert <eggert@twinsun.com>
1006 * patch.c (main): Apply do_ed_script even if dry_run, because
1007 we need to make progress on the patch file.
1008 * pch.c (do_ed_script): If skip_rest_of_patch is nonzero,
1009 gobble up the patch without any other side effect.
1011 1999-10-12 Paul Eggert <eggert@twinsun.com>
1013 * NEWS, README: New bug reporting address.
1014 * NEWS: Report change in 2.5.4 that we forgot to document.
1015 * README: Document `configure --disable-largefile'.
1017 * basename.c, COPYING, getopt.c, getopt.h, getopt1.c, m4/largefile.m4:
1018 Update to latest version.
1019 * Makefile.in (basename$U.o): Depend on basename.h.
1020 (config.hin): Depend on $(srcdir)/aclocal.m4.
1022 * ansi2knr.c, maketime.c, mkinstalldirs, partime.c: Fix $Id.
1024 FreeBSD has an unrelated setmode function; work around this.
1025 * common.h (binary_transput): Don't declare unless O_BINARY.
1026 * patch.c (option_help, get_some_switches):
1027 Don't use setmode unless O_BINARY.
1028 * pch.c (open_patch_file): Don't invoke setmode unless O_BINARY.
1030 Fix incompatiblities with error.c.
1031 * common.h (program_name): Now XTERN char *, for compatibility
1032 with error.c. All uses changed.
1033 (PROGRAM_NAME): New macro.
1034 (PARAMS): Use ANSI C version only if defined PROTOTYPES
1035 || (defined __STDC__ && __STDC__), for compatibilty with error.c.
1036 * util.c (vararg_start): Likewise.
1037 * patch.c (program_name): Remove.
1038 (main): Initialize program_name.
1039 * version.c (version): Print PROGRAM_NAME, not program_name.
1041 Accommodate mingw32 port, which has one-argument mkdir (yuck!)
1043 * m4/mkdir.m4: New file.
1044 * Makefile.in (ACINCLUDE_INPUTS): Add $(M4DIR)/mkdir.m4.
1045 * configure.in (AC_CHECK_FUNCS): Add geteuid, getuid.
1046 (PATCH_FUNC_MKDIR_TAKES_ONE_ARG): Add.
1047 * common.h (mkdir): Define if mkdir takes one arg.
1048 (geteuid): New macro, if not already defined.
1050 1999-10-11 Christopher R. Gabriel <cgabriel@tin.it>
1052 * patch.c (option_help): Updated bug report address
1053 * configure.in (VERSION): Version 2.5.5 released.
1055 1999-09-01 Paul Eggert <eggert@twinsun.com>
1057 * patch.c (main): Default simple_backup_suffix to ".orig".
1059 1999-10-08 Paul Eggert <eggert@twinsun.com>
1061 * patch.man: Make it clear that `patch -o F' should not be
1062 used if F is one of the files to be patched.
1064 1999-08-30 Paul Eggert <eggert@twinsun.com>
1066 Version 2.5.4 fixes a few minor bugs, converts C sources to
1067 ANSI prototypes, and modernizes auxiliary sources and autoconf
1070 * configure.in (VERSION): Version 2.5.4 released.
1071 (AC_CANONICAL_HOST): Add.
1072 (AC_SYS_LARGEFILE): Add, replacing inline code.
1074 (jm_AC_HEADER_INTTYPES_H): Add, replacing inline code.
1075 (AC_TYPE_PID_T): Add.
1076 (jm_STRUCT_UTIMBUF): Add, replacing inline code.
1077 (HAVE_MEMCHR): Remove obsolescent test; nobody uses NetBSD 1.0 now.
1078 (getopt_long): Append $U to object file basenames.
1079 (AC_CHECK_FUNCS): Add fseeko, setmode. Remove mkdir.
1080 (AC_REPLACE_FUNCS): Add mkdir, rmdir.
1081 (jm_STRUCT_DIRENT_D_INO): Add, replacing inline code.
1083 * Makefile.in (EXEEXT): New macro.
1084 (mandir): New macro.
1085 (man1dir): Define in terms of mandir.
1086 (SRCS): Add mkdir.c, rmdir.c.
1087 (OBJS): Change .o to $U.o for addext, argmatch, backupfile, basename,
1088 error, inp, patch ,,pch, quotearg, util, version, xmalloc.
1089 (HDRS): Add basename.h, patchlevel.h.
1090 (MISC): Add ansi2knr.1, config.guess, config.sub.
1091 (MISC, config.hin): Remove acconfig.h; no longer needed.
1092 (DISTFILES_M4): New macro.
1093 (all): patch -> patch$(EXEEXT).
1094 (patch$(EXEEXT)): Renamed from patch. All uses changed.
1095 (uninstall): Remove manual page.
1096 (configure): Depend on aclocal.m4.
1097 (M4DIR, ACINCLUDE_INPUTS): New macros.
1098 ($(srcdir)/aclocal.m4): New rule.
1099 (patchlevel.h): Depend on configure.in, not Makefile,
1100 since we now distribute it.
1101 (distclean): Don't remove patchlevel.h.
1102 (dist): Distribute $(DISTFILES_M4).
1103 (addext_.c argmatch_.c backupfile_.c basename_.c error_.c
1104 getopt_.c getopt1_.c inp_.c malloc_.c mkdir_.c patch_.c pch_.c
1105 rename_.c util_.c version_.c xmalloc_.c): Depend on ansi2knr.
1106 Update dependencies to match sources.
1108 * common.h (_LARGEFILE_SOURCE): Remove; now autoconfigured.
1109 (file_offset): Depend on HAVE_FSEEKO, not _LFS_LARGEFILE.
1111 * patch.c (version_control_context): New variable.
1112 Convert to ANSI prototypes.
1113 Adjust to new argmatch calling convention.
1114 Similarly for get_version.
1115 Complain about creating an existing file only if
1116 pch_says_nonexistent returns 2 (not merely nonzero).
1117 Similarly for time mismatch check.
1118 (get_some_switches): Adjust to new get_version calling convention.
1119 Similarly for argmatch.
1121 * pch.c (<basename.h>): Include.
1122 (intuit_diff_type): Improve quality of test for empty file.
1123 (another_hunk): Don't assume off_t is no longer than long.
1125 * util.h (backup_type): New decl.
1126 * util.c (<basename.h>): Include.
1127 (move_file): Adjust to new find_backup_file_name convention.
1128 (doprogram, mkdir, rmdir): Remove; now in separate files.
1129 (fetchame): Match "/dev/null", not NULL_DEVICE.
1130 Ignore names that don't have enough slashes to strip off.
1132 * version.c: Update copyright notice.
1134 1998-03-20 Paul Eggert <eggert@twinsun.com>
1136 * configure.in (VERSION): Bump to 2.5.3.
1137 * quotearg.h (quotearg_quoting_options):
1138 Remove; it ran afoul of the Borland C compiler.
1139 Its address is now represented by the null pointer.
1140 * quotearg.c (default_quoting_options):
1141 Renamed from quotearg_quoting_options,
1142 and now static instead of extern.
1143 (clone_quoting_options, get_quoting_style, set_quoting_style,
1144 set_char_quoting, quotearg_buffer):
1145 Use default_quoting_options when passed a null pointer.
1146 * patch.c (main, get_some_switches):
1147 Pass a null pointer instead of address of quotearg_quoting_options.
1149 1998-03-17 Paul Eggert <eggert@twinsun.com>
1151 * patch.c (option_help): Update bug reporting address to gnu.org.
1152 * patch.man: Fix copyright and bug reporting address.
1154 1998-03-16 Paul Eggert <eggert@twinsun.com>
1156 * configure.in (VERSION): Bump to 2.5.2.
1157 (AC_CHECK_FUNCS): Add strerror.
1158 (jm_FUNC_MALLOC, jm_FUNC_REALLOC): Add.
1159 (AM_C_PROTOTYPES): Add.
1161 * NEWS, patch.c (longopts, get_some_switches), patch.man:
1162 Add --quoting-style, --posix options.
1164 * Makefile.in (LIBSRCS): Add malloc.c, realloc.c.
1165 (SRCS): Add error.c, quotesys.c, xmalloc.c.
1167 (HDRS): Add error.h, quotesys.h, xalloc.h.
1168 (MISC): Add AUTHORS, aclocal.m4, ansi2knr.c.
1169 (clean): Use mostlyclean rule.
1170 (argmatch.o, inp.o, patch.o, pch.o): Now also depends on quotearg.h.
1171 (inp.o, patch.o, util.o): Now also depends on xalloc.h.
1172 (error.o, quotearg.o, quotesys.o, xmalloc.o,
1173 ansi2knr.o, ansi2knr, quotearg_.c, .c_.c): New rules.
1175 (OBJS, quotearg$U.o): Rename quotearg.o to quotearg$U.o.
1176 (mostlyclean): Remove ansi2knr, *_.c.
1177 (.SUFFIXES): Add _.c.
1179 * acconfig.h (PROTOTYPES): New undef.
1181 * acconfig.h, configure.in (HAVE_INTTYPES_H, malloc, realloc):
1184 * aclocal.m4, error.c, error.h, malloc.c,
1185 quotearg.h, quotearg.c, realloc.c, xalloc.h, xmalloc.c: New files.
1187 * argmatch.c: Include <sys/types.h> before <argmatch.h>.
1188 Include <quotearg.h>.
1190 * argmatch.c (invalid_arg),
1191 inp.c (scan_input, report_revision, too_many_lines, get_input_file,
1193 patch.c (main, get_some_switches, numeric_string),
1194 pch.c (open_patch_file, intuit_diff_type, do_ed_script):
1195 util.c (move_file, create_file, copy_file, version_get, removedirs):
1196 Quote output operands properly.
1198 * common.h: Include <inttypes.h> if available.
1199 (CHAR_BIT, TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM,
1200 CHAR_MAX, INT_MAX, LONG_MIN, SIZE_MAX, O_EXCL): New macros.
1201 (TMPINNAME_needs_removal, TMPOUTNAME_needs_removal,
1202 TMPPATNAME_needs_removal): New variables.
1203 (xmalloc): Remove decl; now in xalloc.h.
1205 * inp.c: Include <quotearg.h>, <xalloc.h>.
1207 * inp.c (get_input_file),
1208 pch.c (intuit_diff_type),
1209 util.c (version_controller):
1210 Don't do diff operation if diffbuf is null; used by ClearCase support.
1213 patch.c (init_reject),
1214 pch.c (open_patch_file, do_ed_script):
1215 Create temporary file with O_EXCL to avoid races.
1217 * patch.c: Include <quotearg.h>, <xalloc.h>.
1218 (create_output_file, init_output): New open_flags arg.
1219 All callers changed.
1220 (init_reject): No longer takes filename arg. All callers changed.
1221 (remove_if_needed): New function.
1222 (cleanup): Use it to remove temporary files only if needed.
1223 (TMPREJNAME_needs_removal): New var.
1224 (main): Set xalloc_fail_func to memory_fatal; needed for xalloc.
1225 Initialize quoting style from QUOTING_STYLE.
1226 (longopts, get_some_switches): Offset longarg options by CHAR_MAX,
1227 not 128; this is needed for EBCDIC ports.
1229 * patch.c (main, locate_hunk, abort_hunk, spew_output),
1230 pch.c (there_is_another_patch, intuit_diff_type, malformed,
1232 The LINENUM type now might be longer than long,
1233 so print and read line numbers more carefully.
1236 pch.c (there_is_another_patch):
1238 strippath now defaults to -1, so that we can distinguish unset
1239 value from largest possible.
1241 * patch.man: Clarify how file name is chosen from candidates.
1243 * pch.c: Include <quotearg.h>.
1244 (p_strip_trailing_cr): New variable.
1245 (scan_linenum): New function.
1246 (pget_line, re_patch, there_is_another_patch, intuit_diff_type,
1247 get_line): Strip trailing CRs from context diffs that need this.
1248 (best_name): Use SIZE_MAX instead of (size_t) -1 for max size_t.
1250 * quotesys.c, quotearg.h: Renamed from quotearg.c and quotearg.h.
1252 * quotesys.h (__QUOTESYS_P): Renamed from __QUOTEARG_P.
1254 * util.c: Include <quotearg.h>, <xalloc.h>.
1255 (raise): Don't define if already defined.
1256 (move_file): New arg from_needs_removal. All callers changed.
1257 (copy_file): New arg to_flags. All callers changed.
1258 (CLEARTOOL_CO): New constant.
1259 (version_controller): Add ClearCase support.
1260 (format_linenum): New function.
1261 (fetchname): Allow any POSIX.1 time zone spec, which means
1262 any local time offset in the range -25:00 < offset < +26:00.
1263 Ignore the name if it doesn't have enough slashes to strip off.
1264 (xmalloc): Remove; now in xmalloc.c.
1266 * util.h (LINENUM_LENGTH_BOUND): New macro.
1267 (format_linenum): New decl.
1269 * version.c (copyright_string): Update years of copyrights.
1271 1997-09-03 Paul Eggert <eggert@twinsun.com>
1273 * configure.in (VERSION): Bump to 2.5.1.
1274 * inp.c (re_input): Don't free buffers twice when input is garbled.
1275 * patch.c (main): If skipping patch and Plan A fails, don't
1276 bother trying Plan B.
1278 1997-08-31 Paul Eggert <eggert@twinsun.com>
1280 * configure.in (VERSION): Version 2.5 released.
1282 1997-07-21 Paul Eggert <eggert@twinsun.com>
1284 * configure.in (VERSION): Bump to 2.4.4.
1285 * pch.c (there_is_another_patch), NEWS: Report an error if the patch
1286 input contains garbage but no patches.
1288 * pch.c (open_patch_file):
1289 Check for patch file too long (i.e., its size
1290 doesn't fit in a `long', and LFS isn't available).
1293 Cast malloc return value, in case malloc returns char *.
1295 1997-07-16 Paul Eggert <eggert@twinsun.com>
1297 * configure.in (VERSION): Bump to 2.4.3.
1299 * NEWS, patch.man, pch.c (intuit_diff_type, get_line, pget_line):
1300 Now demangles RFC 934 encapsulation.
1301 * pch.c (p_rfc934_nesting): New var.
1303 * pch.c (intuit_diff_type): Don't bother to check file names carefully
1304 if we're going to return NO_DIFF.
1306 * inp.c (plan_a): Count the number of lines before allocating
1307 pointer-to-line buffer; this reduces memory requirements
1308 considerably (roughly by a factor of 5 on 32-bit hosts).
1309 Decrease `size' only when read unexpectedly reports EOF.
1310 (i_buffer): New var.
1311 (too_many_lines): New fn.
1312 (re_input): Free i_buffer if using plan A.
1313 Free buffers unconditionally; they can't be zero.
1315 * inp.c (plan_a, plan_b): Check for overflow of line counter.
1317 * pch.c (malformed), util.h (memory_fatal, read_fatal, write_fatal):
1318 Declare as noreturn.
1320 1997-07-10 Paul Eggert <eggert@twinsun.com>
1322 * configure.in (VERSION): Bump to 2.4.2.
1324 * util.c (ok_to_reverse), NEWS: The default answer is now `n';
1325 this is better for Emacs.
1327 * Makefile.in (dist): Use cp -p, not ln;
1328 some hosts do the wrong thing with ln if the source is a symbolic link.
1330 * patch.man: Fix typo: -y -> -Y.
1332 1997-07-05 Paul Eggert <eggert@twinsun.com>
1334 * configure.in (VERSION): Bump to 2.4.1.
1336 * patch.c: (main, get_some_switches), NEWS, patch.man:
1337 Version control is now independent of whether backups are made.
1338 * patch.c (option_help): Put version control options together.
1339 (get_some_switches): With CVS 1.9 hack, treat -b foo like -b -z foo,
1340 not just -z foo. This change is needed due to recent change in -z.
1341 * backupfile.c (find_backup_file_name):
1342 backup_type == none causes undefined behavior;
1343 this undoes the previous change to this file.
1345 * patch.c (locate_hunk): Fix bug when locating context diff hunks
1346 near end of file with nonzero fuzz.
1348 * util.c (move_file): Don't assume that ENOENT is reported when both
1349 ENOENT and EXDEV apply; this isn't true with DJGPP, and
1350 Posix doesn't require it.
1352 * pch.c (there_is_another_patch):
1353 Suggest -p when we can't intuit a file.
1355 1997-06-19 Paul Eggert <eggert@twinsun.com>
1357 * configure.in (VERSION): Version 2.4 released.
1358 * NEWS: Patch is now verbose when patches do not match exactly.
1360 1997-06-17 Paul Eggert <eggert@twinsun.com>
1362 * pc/djgpp/configure.sed (config.h): Remove redundant $(srcdir).
1364 * configure.in (VERSION): Bump to 2.3.9.
1365 * patch.c (main): By default, warn about hunks that succeed
1366 with nonzero offset.
1367 * patch.man: Add LC_ALL=C advice for making patches.
1368 * pc/djgpp/configure.sed (config.h): Fix paths to dependent files.
1370 1997-06-17 Paul Eggert <eggert@twinsun.com>
1372 * configure.in (VERSION): Bump to 2.3.8.
1374 * pch.c (open_patch_file): Test stdin for fseekability.
1375 (intuit_diff_type): Missing context diff headers are now warnings,
1376 not errors; some people use patches with them (e.g. when retrying
1379 * patch.c (struct outstate):
1380 New type, collecting together some output state vars.
1381 (apply_hunk, copy_till, spew_output, init_output): Use it.
1382 Keep track of whether some output has been generated.
1383 (backup_if_mismatch): New var.
1384 (ofp): Remove, in favor of local struct outstate vars.
1385 (main): Use struct outstate. Initialize backup_if_mismatch to
1386 be the inverse of posixly_correct. Keep track of whether mismatches
1387 occur, and use this to implement backup_if_mismatch.
1388 Report files that are not empty after patching, but should be.
1389 (longopts, option_help, get_some_switches): New options
1390 --backup-if-mismatch, --no-backup-if-mismatch.
1391 (get_some_switches): -B, -Y, -z no longer set backup_type.
1392 * backupfile.c (find_backup_file_name):
1393 Treat backup_type == none like simple.
1395 * Makefile.in (CONFIG_HDRS):
1396 Remove var; no longer needed by djgpp port.
1397 (DISTFILES_PC_DJGPP): Rename pc/djgpp/config.sed to
1398 pc/djgpp/configure.sed; remove pc/djgpp/config.h in favor of
1399 new file that edits it, called pc/djgpp/config.sed.
1400 * pc/djgpp/configure.bat: Rename config.sed to configure.sed.
1401 * pc/djgpp/configure.sed (CONFIG_HDRS): Remove.
1402 (config.h): Add rule to build this from config.hin and
1403 pc/djgpp/config.sed.
1404 * pc/djgpp/config.sed:
1405 Convert from .h file to .sed script that generates .h file.
1407 * NEWS: Describe --backup-if-mismatch, --no-backup-if-mismatch.
1409 Describe new options --backup-if-mismatch, --no-backup-if-mismatch
1410 and their ramifications. Use unreadable backup to represent
1413 1997-06-12 Paul Eggert <eggert@twinsun.com>
1415 * configure.in (VERSION): Bump to 2.3.7.
1416 (AC_CHECK_FUNCS): Add `raise'.
1418 * Makefile.in (inp.o): No longer depends on quotearg.h.
1420 * common.h (outfile): New decl (was private var named `output').
1422 (GENERIC_OBJECT): Renamed from VOID.
1423 (NULL_DEVICE, TTY_DEVICE): New macros.
1425 * patch.c (output): Remove; renamed to `outfile' and moved to common.h.
1426 (main): `failed' is count, not boolean.
1427 Say "Skipping patch." when deciding to skip patch.
1428 (get_some_switches): Set invc when setting inname.
1430 * inp.c: Do not include <quotearg.h>.
1431 (SCCSPREFIX, GET, GET_LOCKED, SCCSDIFF1, SCCSDIFF2, SCCSDIFF3,
1432 RCSSUFFIX, CHECKOUT, CHECKOUT_LOCKED, RCSDIFF1, RCSDIFF2):
1434 (get_input_file): Invoke new functions version_controller and
1435 version_get to simplify this code.
1436 (plan_b): "/dev/tty" -> NULL_DEVICE
1438 * pch.h (pch_timestamp): New decl.
1439 * pch.c (p_timestamp): New var; takes over from global timestamp array.
1440 (pch_timestamp): New function to export p_timestamp.
1441 (there_is_another_patch): Use blander wording when you can't intuit
1443 Say "Skipping patch." when deciding to skip patch.
1444 (intuit_diff_type): Look for version-controlled but nonexistent files
1445 when intuiting file names; set invc accordingly.
1446 Ignore Index: line if either old or new line is present, and if
1447 POSIXLY_CORRECT is not set.
1448 (do_ed_script): Flush stdout before invoking popen, since it may
1449 send output to stdout.
1451 * util.h (version_controller, version_get): New decls.
1452 * util.c: Include <quotearg.h> earlier.
1453 (raise): New macro, if ! HAVE_RAISE.
1454 (move_file): Create empty unreadable file when backing up a nonexistent
1456 (DEV_NULL): New constant.
1457 (SCCSPREFIX, GET. GET_LOCKED, SCCSDIFF1, SCCSDIFF2,
1458 RCSSUFFIX, CHECKOUT, CHECKOUT_LOCKED, RCSDIFF1): Moved here from inp.c.
1459 (version_controller, version_get): New functions.
1460 (ask): Look only at /dev/tty for answers; and when standard output is
1461 not a terminal and ! posixly_correct, don't even look there.
1462 Remove unnecessary fflushes of stdout.
1463 (ok_to_reverse): Say "Skipping patch." when deciding to skip patch..
1464 (sigs): SIGPIPE might not be defined.
1465 (exit_with_signal): Use `raise' instead of `kill'.
1466 (systemic): fflush stdout before invoking subsidiary command.
1468 * patch.man: Document recent changes.
1469 Add "COMPATIBILITY ISSUES" section.
1471 * NEWS: New COMPATIBILITY ISSUES for man page.
1472 Changed verbosity when fuzz is found.
1473 File name intuition is changed, again.
1474 Backups are made unreadable when the file did not exist.
1476 * pc/djgpp/config.h (HAVE_STRUCT_UTIMBUF): Define.
1477 (HAVE_RAISE): New macro.
1478 (HAVE_UTIME_H): Define.
1479 (TZ_is_unset): Do not define; it's not a serious problem with `patch'
1480 to have TZ be unset in DOS.
1482 1997-06-08 Paul Eggert <eggert@twinsun.com>
1484 * configure.in (VERSION): Bump to 2.3.6.
1485 (AC_CHECK_HEADERS): Add utime.h.
1486 * acconfig.h, configure.in, pc/djgpp/config.h (HAVE_STRUCT_UTIMBUF):
1488 * pc/djgpp/config.h (HAVE_UTIME_H, TZ_is_unset): New macros.
1490 * NEWS, patch.man: Describe new -Z, -T options, new numeric
1491 option for -G, retired -G, and more verbose default behavior
1494 * pch.c (intuit_diff_type): Record times reported for files in headers.
1495 Remove head_says_nonexistent[x], since it's now equivalent to
1497 * util.h (fetchname): Change argument head_says_nonexistent to
1499 * util.c: #include <partime.h> for TM_LOCAL_ZONE.
1500 Don't include <time.h> since common.h now includes it.
1501 (ok_to_reverse): noreverse and batch cases now output regardless of
1503 (fetchname): Change argument head_says_nonexistent to pstamp, and
1504 store header timestamp into *pstamp.
1505 If -T or -Z option is given, match time stamps more precisely.
1506 (ask): Remove unnecessary close of ttyfd.
1507 When there is no terminal at all, output a newline to make the
1508 output look nicer. After reporting EOF, flush stdout;
1509 when an input error, report the error type.
1511 * inp.c (get_input_file):
1512 Ask user whether to get file if patch_get is negative.
1514 * Makefile.in (clean): Don't clean */*.o; clean core* and *core.
1516 1997-06-04 Paul Eggert <eggert@twinsun.com>
1518 * configure.in (VERSION): Bump to 2.3.5.
1520 * util.c (ok_to_reverse):
1521 Be less chatty if verbosity is SILENT and we don't
1522 have to ask the user. If force is nonzero, apply the patch anyway.
1524 * pch.c (there_is_another_patch):
1525 Before skipping rest of patch, skip to
1526 the patch start, so that another_hunk can skip it properly.
1527 (intuit_diff_type): Slight wording change for missing headers, to
1528 regularize with other diagnostics. Fix off-by-one error when setting
1529 p_input_line when scanning the first hunk to check for deleted files.
1531 1997-06-03 Paul Eggert <eggert@twinsun.com>
1533 * configure.in (VERSION): Bump to 2.3.4.
1535 * NEWS: Now matches more generously against nonexistent or empty files.
1537 * pch.c (there_is_another_patch): Move warning about not being
1538 able to intuit file names here from skip_to.
1539 (intuit_diff_type): Fatal error if we find a headless unified
1542 * util.c (ask): Null-terminate buffer properly even if it grew.
1543 (fetchname): No need to test for null first argument.
1545 1997-06-02 Paul Eggert <eggert@twinsun.com>
1547 * configure.in (VERSION): Bump to 2.3.3.
1548 * pch.c (p_says_nonexistent, pch_says_nonexistent): Is now 1 for empty,
1550 (intuit_diff_type): Set p_says_nonexistent according to new meaning.
1551 Treat empty files like nonexistent files when reversing.
1552 (skip_to): Output better diagnostic when we can't intuit a file name.
1554 Count bytes, not lines, when testing whether a file is empty,
1555 since it may contain only non-newline chars.
1556 pch_says_nonexistent now returns 2 for nonexistent files.
1558 1997-06-01 Paul Eggert <eggert@twinsun.com>
1560 * configure.in (VERSION): Bump to 2.3.2.
1561 * pch.c (open_patch_file):
1562 Fix bug when computing size of patch read from a pipe.
1564 1997-05-30 Paul Eggert <eggert@twinsun.com>
1566 * configure.in (VERSION): Bump to 2.3.1.
1568 * Makefile.in (transform, patch_name): New vars,
1569 for proper implementation of AC_ARG_PROGRAM.
1570 (install, uninstall): Use them.
1571 (install-strip): New rule.
1572 * pc/djgpp/config.sed (program_transform_name): Set to empty.
1574 1997-05-30 Paul Eggert <eggert@twinsun.com>
1576 * configure.in (VERSION), NEWS: Version 2.3 released.
1577 * patch.man: Fix two font typos.
1578 * util.c (doprogram): Fix misspelled decl.
1580 1997-05-26 Paul Eggert <eggert@twinsun.com>
1582 * configure.in (VERSION): Bump to 2.2.93.
1584 * pch.c (open_patch_file):
1585 Fatal error if binary_transput and stdin is a tty.
1587 * pc/djgpp/config.sed (chdirsaf.c):
1588 Use sed instead of cp, since cp might not be installed.
1589 * pc/djgpp/configure.bat:
1590 Prepend %srcdir% to pathname of config.sed, for crosscompiles.
1592 1997-05-25 Paul Eggert <eggert@twinsun.com>
1594 * configure.in (VERSION): Bump to 2.2.92.
1595 (D_INO_IN_DIRENT): New macro.
1596 * pc/djgpp/config.h, acconfig.h (D_INO_IN_DIRENT): New macro.
1597 * backupfile.c (REAL_DIR_ENTRY):
1598 Depend on D_INO_IN_DIRENT, not _POSIX_VERSION.
1600 * addext.c (addext): Adjust slen when adjusting s for DOS 8.3 limit.
1601 Do not use xxx.h -> xxxh~ hack.
1603 * util.c: (move_file): Avoid makedirs test when possible even
1604 if FILESYSTEM_PREFIX_LEN (p) is nonzero. Don't play
1605 case-changing tricks to come up with backup file name; it's
1606 not portable to case-insensitive file systems.
1607 * common.h (ISLOWER): Remove.
1609 * inp.c (scan_input): Don't use Plan A if (debug & 16).
1611 * patch.c (shortopts): Add -g, -G.
1612 (longopts): --help now maps to 132, not 'h', to avoid confusion.
1613 (get_some_switches): Likewise.
1614 Don't invoke setmode on input if --binary; wait until needed.
1615 Don't ever invoke setmode on stdout.
1616 * pch.c (open_patch_file): Setmode stdin to binary if binary_transput.
1618 * patch.man: Fix documentation of backup file name to match behavior.
1619 Add advice for ordering of patches of derived files.
1620 Add /dev/tty to list of files used.
1621 * README: Adjust instructions for building on DOS.
1622 * pc/djgpp/README: Remove tentative wording.
1623 * NEWS: The DOS port is now tested.
1624 Backup file names are no longer computed by switching case.
1626 * pc/chdirsaf.c (ERANGE): Include <errno.h> to define it.
1627 (restore_wd): chdir unconditionally.
1628 (chdir_safer): Invoke atexit successfully at most once.
1629 * pc/djgpp/config.sed: Use chdirsaf.o, not pc/chdirsaf.o.
1630 Replace CONFIG_HDRS, don't append.
1631 Use $(srcdir) in CONFIG_STATUS.
1632 Don't apply $(SHELL) to $(CONFIG_STATUS).
1633 Append rules for chdirsaf.o, chdirsaf.c; clean chdirsaf.c at the end.
1634 * pc/djgpp/configure.bat: Append CR to each line; DOS needs this.
1635 Don't use | as sed s delimiter; DOS can't handle it.
1637 1997-05-21 Paul Eggert <eggert@twinsun.com>
1639 * configure.in (VERSION): Bump to 2.2.91.
1641 * pch.c (another_hunk):
1642 Fix bug with computing size of prefix and suffix context
1643 with ordinary context diffs. Report malformed patch if a unified diff
1644 has nothing but context.
1646 * inp.c (get_input_file):
1647 Use patch_get, not backup_type, to decide whether to
1648 get from RCS or SCCS. Use the word `get' in diagnostics.
1649 * patch.c (main): Initialize patch_get from PATCH_GET.
1650 Omit DEFAULT_VERSION_CONTROL hook; it just leads to nonstandarization.
1651 (longopts, option_help, get_some_switches): Add support for -g, -G.
1652 (option_help): Add bug report address.
1653 * common.h (patch_get): New decl.
1654 * patch.man: Add -g and -G options; use `get' instead of `check out'.
1655 Add PATCH_GET. Recommend -Naur instead of -raNU2 for diff.
1656 * NEWS: Describe -g, -G, PATCH_GET.
1658 * version.c (copyright_string): Use only most recent copyright year,
1659 as per GNU standards.
1661 * Makefile.in (DISTFILES_PC): Remove pc/quotearg.c.
1662 * pc/djgpp/config.sed: Remove unnecessary hooks for quotearg and SHELL.
1664 1997-05-18 Paul Eggert <eggert@twinsun.com>
1666 * configure.in (VERSION): Increase to 2.2.9.
1667 (AC_TYPE_MODE_T): Add.
1669 * pch.h (another_hunk): New parameter REV.
1670 * pch.c (hunkmax): Now of type LINENUM.
1671 (malformed): Add decl.
1672 (there_is_another_patch): Skip inname-detection if skip_rest_of_patch.
1673 (intuit_diff_type): To determine whether file appears to have been
1674 deleted, look at replacement, not pattern.
1675 If there is a mismatch between existence of file and whether the
1676 patch claims to change whether the file exists, ask whether to
1678 (another_hunk): New parameter REV specifying whether to reverse the
1679 hunk. All callers changed.
1680 (do_ed_script): Add assertion to ensure input file exists.
1682 * util.h (create_file): New function.
1683 (copy_file): Now takes mode, not struct stat.
1684 (makedirs): No longer exported.
1685 (move_file): Now takes mode, not struct stat.
1686 * util.c (makedirs): No longer exported.
1687 (move_file): Accept mode of destination, not struct stat.
1688 All callers changed.
1689 Quote file names in diagnostics.
1690 Create parent dir of destination if necessary.
1692 Don't unlink source; it will be unlinked later.
1693 Unlink destination if FROM is zero.
1694 (create_file): New function.
1695 (copy_file): Accept mode of destination, not struct stat.
1696 All callers changed.
1697 Use create_file to create file.
1698 (ok_to_reverse): Moved here from patch.c. Now accepts format and args;
1699 all callers changed.
1700 (mkdir): 2nd arg is now mode_t, for better compatibility.
1701 (replace_slashes): Ignore slashes at the end of the filename.
1703 * common.h (noreverse): New decl.
1704 (ok_to_reverse): Remove decl.
1706 * patch.c (noreverse): Now extern.
1707 (main): New environment var PATCH_VERSION_CONTROL overrides VERSION_CONTROL.
1708 Don't assert(hunk) if we're skipping the patch; we may not have any hunks.
1709 When removing a file, back it up if backups are desired.
1710 Don't chmod output file if input file did not exist.
1711 chmod rej file to input file's mode minus executable bits.
1712 (locate_hunk): Go back to old way of a single fuzz parameter, but
1713 handle it more precisely: context diffs with partial contexts
1714 can only match file ends, since the partial context can occur
1715 only at the start or end of file.
1716 All callers changed.
1717 (create_output_file): Use create_file to create files.
1718 (ok_to_reverse): Move to util.c.
1720 * inp.c (scan_input, get_input_file): Quote file names in diagnostics.
1721 (get_input_file): Set inerrno if it's not already set.
1722 Don't create file; it's now the caller's responsibility.
1723 (plan_b): Use /dev/null if input size is zero, since it might not exist.
1724 Use create_file to create temporary file.
1726 * NEWS: Add PATCH_VERSION_CONTROL; DOS port is untested.
1728 * pc/djgpp/config.h: Add comment for mode_t.
1730 * pc/djgpp/README: Note that it's not tested.
1732 * patch.man: PATCH_VERSION_CONTROL overrides VERSION_CONTROL.
1734 1997-05-15 Paul Eggert <eggert@twinsun.com>
1736 * configure.in: Add AC_PREREQ(2.12).
1737 (VERSION): Bump to 2.2.8.
1738 (ed_PROGRAM): Rename from ED_PROGRAM.
1740 * pch.c (prefix_components): Support DOS file names better.
1741 Fix typo that caused fn to almost always yield 0.
1743 * util.c (<time.h>, <maketime.h>): Include.
1744 (move_file, copy_file): Add support for DOS filenames.
1745 Preserve mode of input files when creating temp files.
1746 Add binary file support.
1747 (doprogram, rmdir): New functions.
1748 (mkdir): Use doprogram.
1749 (replace_slashes): Add support for DOS filenames.
1750 (removedirs): New function.
1751 (init_time)): New function.
1752 (initial_time): New var.
1753 (fetchname): Add support for deleted files, DOS filenames.
1755 * basename.c (FILESYSTEM_PREFIX_LEN, ISSLASH):
1756 New macros, for DOS port.
1757 (base_name): Use them.
1759 * addext.c (HAVE_DOS_FILE_NAMES): New macro.
1760 <limits.h>: Include if HAVE_LIMITS_H.
1761 (addext): Handle hosts with DOS file name limits.
1763 * common.h (LONG_MIN): New macro.
1764 (FILESYSTEM_PREFIX_LEN, ISSLASH): New macros, for DOS port.
1765 (ok_to_create_file): Remove.
1767 (ok_to_reverse): New function decl.
1768 (O_WRONLY, _O_BINARY, O_BINARY, O_CREAT, O_TRUNC): New macros.
1769 (binary_transput): New var decl.
1771 * Makefile.in (ed_PROGRAM): Renamed from ED_PROGRAM.
1772 (CONFIG_HDRS, CONFIG_STATUS): New vars.
1773 (SRCS): Add maketime.c, partime.c.
1775 (HDRS): Add maketime.h, partime.h.
1776 (DISTFILES_PC, DISTFILES_PC_DJGPP): New vars.
1777 (Makefile, config.status): Use CONFIG_STATUS, not config.status.
1778 (clean): Remove */*.o.
1779 (dist): Add pc and pc/djgpp subdirectories.
1780 ($(OBJS)): Depend on $(CONFIG_HDRS) instead of config.h.
1781 (maketime.o, partime.o): New rules.
1782 (util.o): Depend on maketime.h.
1785 Call init_time. Add DEFAULT_VERSION_CONTROL hook for people who
1786 prefer the old ways. Build temp file names before we might invoke cleanup.
1787 Add support for deleted files and clean up the patch-swapping code a bit.
1788 Delete empty ancestors of deleted files.
1789 When creating temporaries, use file modes of original files.
1790 (longopts, get_some_switches): New option --binary.
1791 (get_some_switches): Report non-errno errors with `fatal', not `pfatal'.
1792 (create_output_file): New function, which preserves modes of original files
1793 and supports binary transput.
1794 (init_output, init_reject): Use it.
1795 (ok_to_reverse): New function.
1796 (TMPDIR): New macro.
1797 (make_temp): Use $TMPDIR, $TMP, $TEMP, or TMPDIR, whichever comes first.
1799 * pch.c (p_says_nonexistent): New var.
1800 (open_patch_file): Add binary transput support.
1801 Apply stat to file names retrieved from user.
1802 Reject them if they don't exist.
1803 (intuit_diff_type): Add support for deleting files.
1804 Don't treat trivial directories any differently.
1805 Avoid stating the same file twice in common case of context diffs.
1806 (prefix_components): Don't treat trivial directories any differently.
1807 Add support for DOS filenames.
1808 (pch_says_nonexistent): New function.
1809 (do_ed_script): Preserve mode of input files when creating temp files.
1810 Add support for binary transput.
1812 * pch.h (pch_says_nonexistent): New decl.
1814 * util.h (replace_slashes): No longer exported.
1815 (fetchname): Add support for deleted files.
1816 (copy_file, move_file): Add support for preserving file modes.
1817 (init_time, removedirs): New functions.
1819 * argmatch.c: Converge with fileutils.
1821 * backupfile.c: Converge with fileutils.
1822 (find_backup_file_name): Treat .~N~ suffix just like any other suffix
1823 when handling file names that are too long.
1826 In messages, put quotes around file names and spaces around "--".
1827 (get_input_file): Allow files to be deleted. Do the expense of
1828 makedirs only if we can't create the file.
1829 (plan_a, plan_b): Add support for binary transput.
1831 * pc/chdirsaf.c, pc/djgpp/README, pc/djgpp/config.h, pc/djgpp/config.sed, pc/djgpp/configure.bat, pc/quotearg.c:
1835 New methods for removing files; adjust file name intuition again.
1836 Add description of MS-DOS and MS-Windows ports.
1839 Simplify file name intuition slightly (no distinction for trivial dirs).
1840 Add --binary. Describe how files and directories are deleted.
1841 Suggest diff -a. Include caveats about what context diffs cannot represent.
1843 1997-05-06 Paul Eggert <eggert@twinsun.com>
1845 * configure.in (VERSION): Now 2.2.7.
1846 (CPPFLAGS, LDFLAGS, LIBS): If the user has not set any of these vars,
1847 prefer support for large files if available.
1849 * common.h (_LARGEFILE_SOURCE): Define.
1850 (file_offset): New typedef.
1851 (file_seek, file_tell): New macros.
1854 Remove empty files by default unless POSIXLY_CORRECT is set.
1856 * util.c, util.h (Fseek):
1857 Use file_offset instead of long, for portability to large-file hosts.
1859 * pch.c: (p_base, p_start, next_intuit_at, skip_to, open_patch_file,
1860 intuit_diff_type, another_hunk, incomplete_line, do_ed_script):
1861 Use file_offset instead of long, for portability to large-file hosts.
1862 (prefix_components): Renamed from path_name_components; count only
1863 nontrivial prefix components, and take a 2nd EXISTING arg.
1864 (existing_prefix_components): Remove; subsumed by prefix_components.
1865 (intuit_diff_type): When creating files, try for the creation of the
1868 * configure.in (VERSION): Now 2.2.6.
1870 * pch.c (existing_prefix_components): New function.
1871 (intuit_diff_type): When creating a file, use a name whose existing
1872 directory prefix contains the most nontrivial path name components.
1873 (best_name): Don't check for null 2nd arg.
1875 * util.h (replace_slashes): New decl.
1877 * util.c (replace_slashes): Now external.
1878 (fetchname): Don't assume chars are nonnegative.
1881 When creating a file, use a name whose existing directory prefix
1882 contains the most nontrivial path name components.
1883 Add advice for creating patches and applying them.
1885 1997-05-06 Paul Eggert <eggert@twinsun.com>
1887 * configure.in (VERSION): Now 2.2.6.
1889 * pch.c (existing_prefix_components): New function.
1890 (intuit_diff_type): When creating a file, use a name whose existing
1891 directory prefix contains the most nontrivial path name components.
1892 (best_name): Don't check for null 2nd arg.
1894 * util.h (replace_slashes): New decl.
1895 * util.c (replace_slashes): Now external.
1896 (fetchname): Don't assume chars are nonnegative.
1898 * patch.man: Describe above change to pch.c.
1899 Add advice for creating patches and applying them.
1901 1997-05-05 Paul Eggert <eggert@twinsun.com>
1903 * configure.in (VERSION): Update to 2.2.5.
1905 * quotearg.h, quotearg.c: New files.
1906 * Makefile.in (SRCS, OBJS, HDRS): Mention new files.
1907 (inp.o, util.o): Now depends on quotearg.h.
1908 (quotearg.o): New makefile rule.
1910 * common.h (posixly_correct): New var.
1911 * patch.c (main): Initialize it.
1912 If ! posixly_correct, default backup type is now `existing'.
1913 SIMPLE_BACKUP_SUFFIX no longer affects backup type.
1914 (backup): Remove var.
1916 * util.h: (countdirs): Remove.
1917 (systemic): New decl.
1918 * util.c (move_file): Try making the parent directory of TO
1919 if backup prefix or suffix contain a slash.
1920 (ask): Remove arbitrary limit on size of result.
1921 (systemic): New function.
1922 (mkdir): Work even if arg contains shell metacharacters.
1923 (replace_slashes): Return 0 if none were replaced.
1924 Don't replace slash after . or .. since it's redundant.
1925 (countdirs): Remove.
1926 (makedirs): Ignore mkdir failures.
1928 * NEWS, patch.man: More POSIXLY_CORRECT adjustments.
1929 Describe new rules for how file names are intuited.
1931 1997-04-17 Paul Eggert <eggert@twinsun.com>
1933 * configure.in (VERSION): Version 2.2 released.
1935 * Makefile.in (config.hin):
1936 Remove before building; we always want the timestamp updated.
1938 * inp.c (get_input_file):
1939 Look for RCS files only if backup_type == numbered_existing.
1942 Remove mention of never-implemented -V rcs and -V sccs options.
1943 * patch.man: `pathname' -> `file name'
1944 Correct the description of how file names are found in diff headers.
1945 Clarify the distinction between ordinary and unified context diffs.
1947 1997-04-13 Paul Eggert <eggert@twinsun.com>
1949 * configure.in (VERSION): Update to 2.1.7.
1951 * patch.c (numeric_optarg): New function.
1952 (get_some_switches): Use it.
1954 * pch.c (intuit_diff_type): When creating a file, prefer a name whose
1955 existing dir prefix is the longest.
1957 * util.h (countdirs): New function.
1958 * util.c (replace_slashes, countdirs): New functions.
1959 (makedirs): Use replace_slashes, to be more like countdirs.
1961 * patch.man: Explain -pN vs -p N. Recommend --new-file.
1962 Explain possible incompatibility with strip count.
1964 1997-04-10 Paul Eggert <eggert@twinsun.com>
1966 * configure.in (VERSION): Bump to 2.1.6.
1967 (AC_CHECK_HEADERS): Remove stdlib.h (i.e. remove HAVE_STDLIB_H).
1969 * Makefile.in: (HDRS, patchlevel.h, TAGS, distclean, maintainer-clean):
1970 Don't distribute patchlevel.h; let the user do it.
1971 This works around some obscure (possibly nonexistent?) `make' bugs.
1973 * common.h (program_name): extern, not XTERN.
1974 (<stdlib.h>): Include if STDC_HEADERS, not if HAVE_STDLIB_H.
1975 (atol, getenv, malloc, realloc): Don't worry whether they're #defined.
1977 * patch.c (get_some_switches):
1978 Add special hack for backwards compatibility with CVS 1.9.
1979 (-B, -Y, -z): Now set backup_type = simple.
1981 * NEWS: Fix misspellings; minor reformatting.
1982 * README: Report POSIX.2 compliance.
1984 1997-04-06 Paul Eggert <eggert@twinsun.com>
1986 Move all old RCS $Log entries into ChangeLog.
1987 #include all files with < >, not " ".
1989 * addext.c, argmatch.c, argmatch.h, memchr.c, install-sh:
1991 * EXTERN.h, INTERN.h: Removed.
1992 * config.hin: Renamed from config.h.in.
1994 * acconfig.h (NODIR): Remove.
1997 * configure.in (AC_ARG_PROGRAM, AC_PROG_MAKE_SET, HAVE_MEMCHR): Add.
1998 (AC_CHECK_HEADERS): Replaces obsolescent AC_HAVE_HEADERS.
1999 Add stdlib.h, string.h, unistd.h, varargs.h.
2000 Delete obsolete call to AC_UNISTD_H.
2001 (AC_CONFIG_HEADER): Rename config.h.in to config.hin.
2002 (AC_C_CONST): Replaces obsolescent AC_CONST.
2003 (AC_CHECK_FUNC): Check for getopt_long; define LIBOBJS and substitute
2005 (AC_CHECK_FUNCS): Replaces obsolescent AC_HAVE_FUNCS.
2006 Add _doprintf, isascii, mktemp, sigaction, sigprocmask, sigsetmask.
2008 (AC_FUNC_CLOSEDIR_VOID, AC_FUNC_VPRINTF): Add.
2009 (AC_HEADER_DIRENT): Replaces obsolescent AC_DIR_HEADER.
2010 (AC_HEADER_STDC): Replaces obsolescent AC_STDC_HEADERS.
2011 (AC_SYS_LONG_FILE_NAMES): Replaces obsolescent AC_LONG_FILE_NAMES.
2012 (AC_TYPE_OFF_T): Replaces obsolescent AC_OFF_T.
2013 (AC_TYPE_SIGNAL): Replaces obsolescent AC_RETSIGTYPE.
2014 (AC_TYPE_SIZE_T): Replaces obsolescent AC_SIZE_T.
2015 (AC_XENIX_DIR): Remove.
2016 (ED_PROGRAM): New var.
2018 (PACKAGE, VERSION): New vars; substitute them with AC_SUBST.
2020 * Makefile.in: Conform to current GNU build standards.
2021 Redo dependencies. Use library getopt_long if available.
2022 Use `&&' instead of `;' inside shell commands where applicable;
2023 GNU make requires this.
2024 Use double-colon rules for actions that do not build files.
2025 (@SET_MAKE@): Added.
2026 (CFLAGS, LDFLAGS, prefix, exec_prefix): Base on @ versions of symbols.
2027 (COMPILE, CPPFLAGS, DEFS, ED_PROGRAM, LIBOBJS, LIBSRCS, PACKAGE,
2028 VERSION): New symbols.
2029 (SRCS, OBJS, HDRS, MISC): Add new files.
2030 (man1dir): Renamed from mandir.
2031 (man1ext): Renamed from manext.
2032 (patch): Put -o first.
2033 (install): Use $(transform) to allow program to be renamed by configure.
2034 (patchlevel.h): Build from $(VERSION).
2035 (dist): Get version number from $(VERSION) and package name from
2037 (TAGS): Scan $(HDRS).
2038 (maintainer-clean): Renamed from realclean. Remove patchlevel.h.
2040 * backupfile.h (simple_backup_suffix): Now const *.
2041 (find_backup_file_name, base_name, get_version): Args are now const *.
2042 (base_name): New decl.
2043 * backupfile.c (<config.h>): Include only if HAVE_CONFIG_H.
2044 (<argmatch.h>): Include.
2045 (<string.h>): Include if HAVE_STRING_H, not if STDC_HEADERS.
2046 (<strings.h>): Include if !HAVE_STRING_H.
2047 (<unistd.h>): Do not include.
2048 (<dirent.h>): Redo include as per current autoconf standards.
2049 (<limits.h>): Include if HAVE_LIMITS_H. Define CHAR_BIT if not defined.
2050 (NLENGTH): Now returns size_t.
2051 (CLOSEDIR, INT_STRLEN_BOUND): New macros.
2052 (ISDIGIT): Use faster method.
2053 (find_backup_file_name): No longer depends on NODIR.
2054 Remove redundant code.
2055 (make_version_name): Remove; do it more portably.
2056 (max_backup_version): Args are now const *.
2057 (version_number): Simplify digit checking.
2058 (basename, concat, dirname): Remove.
2059 (argmatch, invalid_arg): Move to argmatch.c. Simplify test for
2060 ambiguous args. When reporting an error, use program_name not "patch".
2061 (addext): Move to addext.c. Treat all negative values from pathconf
2062 like -1. Always use long extension if it fits, even if the filesystem
2063 does not support long file names.
2064 (backup_types): Now const.
2066 * common.h, inp.h (XTERN): Renamed from EXT to avoid collision
2067 with errno.h reserved name space.
2069 * common.h (DEBUGGING): Now an integer; default is 1.
2070 (enum diff): New type.
2071 (diff_type): Use it instead of small integers.
2072 (CONTEXT_DIFF, NORMAL_DIFF, ED_DIFF, NEW_CONTEXT_DIFF, UNI_DIFF):
2073 Now enumerated values instead of macros.
2074 (NO_DIFF): New enumerated value (used instead of 0).
2075 (volatile): Default to the empty string if __STDC__ is not defined.
2076 (<signal.h>): Do not include.
2077 (Chmod, Close, Fclose, Fflush, Fputc, Signal, Sprintf, Strcat,
2078 Strcpy, Unlink, Write): Remove these macros; casts to void are
2079 not needed for GNU coding standards.
2080 (INITHUNKMAX): Move to pch.c.
2081 (malloc, realloc, INT_MIN, MAXLINELEN, strNE, strnNE,
2082 Reg1, Reg2, Reg3, Reg4, Reg5, Reg6, Reg7, Reg8, Reg9, Reg10, Reg11,
2083 Reg12, Reg13, Reg14, Reg15, Reg16): Remove these macros.
2084 (S_IXOTH, S_IWOTH, S_IROTH, S_IXGRP, S_IWGRP,
2085 S_IRGRP, S_IXUSR, S_IWUSR, S_IRUSR, O_RDONLY, O_RDWR):
2086 Define these macros, if not defined.
2087 (CTYPE_DOMAIN, ISLOWER, ISSPACE, ISDIGIT, PARAMS): New macros.
2088 (instat): Renamed from filestat; used for input file now.
2089 (bufsize, using_plan_a, debug, strippath): Not statically initialized.
2090 (debug): #define to 0 if not DEBUGGING, so that users of `debug'
2091 no longer need to be surrounded by `#if DEBUGGING'.
2092 (out_of_mem, filec, filearg, outname, toutkeep, trejkeep): Remove.
2093 (inname, inerrno, dry_run, origbase): New variables.
2094 (origprae): Now const*.
2095 (TMPOUTNAME, TMPINNAME, TMPPATNAME): Now const*volatile.
2096 (verbosity): New variable; subsumes `verbose'.
2097 (DEFAULT_VERBOSITY, SILENT, VERBOSE): Values in a new enum.
2099 (VOID): Use `#ifdef __STDC__' instead of`#if __STDC__',
2100 for consistency elsewhere.
2101 (__attribute__): New macro (empty if not a recent GCC).
2102 (fatal_exit): Renamed from my_exit.
2103 (errno): Don't define if STDC_HEADERS.
2104 (<string.h>): Include if either STDC_HEADERS or HAVE_STRING_H.
2105 (memcmp, memcpy): Define if !STDC_HEADERS && !HAVE_STRING_H
2107 (<stdlib.h>): Include if HAVE_STDLIB_H, not if STDC_HEADERS.
2108 (atol, getenv, malloc, realloc, lseek): Declare only if not defined
2110 (popen, strcpy, strcat, mktemp): Do not declare.
2111 (lseek): Declare to yield off_t, not long.
2112 (<fcntl.h>): Include only if HAVE_FCNTL_H.
2114 * inp.h (get_input_file): New decl.
2115 * inp.c (SCCSPREFIX, GET, GET_LOCKED, SCCSDIFF, RCSSUFFIX, CHECKOUT,
2116 CHECKOUT_LOCKED, RCSDIFF): Moved here from common.h.
2117 (i_ptr): Now char const **.
2119 (TIBUFSIZE_MINIMUM): Define only if not already defined.
2120 (plan_a, plan_b): Arg is now const *.
2121 (report_revision): Declare before use. It's now the caller's
2122 responsibility to test whether revision is 0.
2123 (scan_input, report_revision, get_input_file):
2124 Be less chatty unless --verbose.
2125 (get_input_file): New function, split off from plan_a.
2126 Reuse file status gotten by pch if possible. Allow for dry run.
2127 Use POSIX bits for creat, not number. Check for creation and
2128 close failure, and use fstat not stat. Use memcpy not strncpy.
2129 (plan_a): Rewrite for speed.
2130 Caller now assigns result to using_plan_a.
2131 Don't bother reading empty files; during dry runs they might not exist.
2132 Use ISSPACE, not isspace.
2133 (plan_b): Allow for dry runs. Use ISSPACE, and handle sign extension
2134 correctly on arg. Use POSIX symbol for open arg.
2136 * patch.c (backup, output, patchname, program_name): New vars.
2137 (last_frozen_line): Moved here from inp.h.
2138 (TMPREJNAME): Moved here from common.h.
2139 (optind_last): Removed.
2140 (do_defines, if_defined, not_defined, else_defined, end_defined):
2141 Now char const. Prepend with \n (except for not_defined) to
2142 allow for files ending in non-newline.
2143 (Argv): Now char*const*.
2144 (main, get_some_switches): Exit status 0 means success,
2145 1 means hunks were rejected, 2 means trouble.
2146 (main, locate_hunk, patch_match): Keep track of patch prefix context
2147 separately from suffix context; this fixes several bugs.
2148 (main): Initialize bufsize, strippath.
2149 Be less chatty unless --verbose.
2150 No more NODIR; always have version control available.
2151 Require environment variables to be nonempty to have effect.
2152 Add support for --dry-run, --output, --verbose.
2153 Invoke get_input_file first, before deciding among do_ed_script,
2155 Clear ofp after closing it, to keep discipline that ofp is either
2156 0 or open, to avoid file descriptor leaks. Conversely, rejfp doesn't
2157 need this trick since static analysis is enough to show when it
2159 Don't allow file-creation patches to be applied to existing files.
2160 Misordered hunks are now not fatal errors; just go on to the next file.
2161 It's a fatal error to fall back on plan B when --output is given,
2162 since the moving hand has writ.
2163 Add support for binary files.
2164 Check for I/O errors.
2165 chmod output file ourselves, rather than letting move_file do it;
2166 this saves global state.
2167 Use better grammar when outputting hunks messages, e.g. avoid
2169 (main, reinitialize_almost_everything):
2170 Remove support for multiple file arguments.
2171 Move get_some_switches call from reinitialize_almost_everything
2173 (reinitialize_almost_everything): No need to reinitialize things
2174 that are no longer global variables, e.g. outname.
2175 (shortopts): Remove leading "-"; it's no longer important to
2176 return options and arguments in order. '-b' no longer takes operand.
2177 -p's operand is no longer optional. Add -i, -Y, -z. Remove -S.
2178 (longopts): --suffix is now pared with -z, not -b. --backup now
2179 means -b. Add --input, --basename-prefix, --dry-run, --verbose.
2180 Remove --skip. --strip's operand is now required.
2181 (option_help): New variable. Use style of current coding standards.
2182 Change to match current option set.
2184 (get_some_switches): Get all switches, since `+' is defunct.
2185 New options -i, -Y, -z, --verbose, --dry-run.
2187 -b now means backup (backup_type == simple), not simple_backup_suffix.
2188 -B now implies backup, and requires nonempty operand.
2189 -D no longer requires first char of argument to be an identifier.
2190 `-o -' is now disallowed (formerly output to regular file named "-").
2191 -p operand is now required.
2192 -v no longer needs to cleanup (no temp files can exist at that point).
2193 -V now implies backup.
2194 Set inname, patchname from file name arguments, if any;
2195 do not set filearg. It's now an error if extra operands are given.
2196 (abort_junk): Check for write errors in reject file.
2197 (apply_hunk, copy_till): Return error flag, so that failure to apply
2198 out-of-order hunk is no longer fatal.
2199 (apply_hunk): New arg after_newline,
2200 for patching files not ending in newline.
2201 Cache ofp for speed. Check for write errors.
2202 (OUTSIDE, IN_IFNDEF, IN_IFDEF, IN_ELSE): Now part of an enumerated type
2203 instead of being #defined to small integers.
2204 Change while-do to do-while when copying !-part for R_do_defines,
2205 since condition is always true the first time through the loop.
2206 (init_output, init_reject): Arg is now const *.
2207 (copy_till, spew_output): Do not insert ``missing'' newlines;
2208 propagate them via new after_newline argument.
2209 (spew_output): Nothing to copy if last_frozen_line == input lines.
2210 Do not close (ofp) if it's null.
2211 (dump_line): Remove.
2212 (similar): Ignore presence or absence of trailing newlines.
2213 Check for only ' ' or '\t', not isspace (as per POSIX.2).
2214 (make_temp): Use tmpnam if mktemp is not available.
2215 (cleanup): New function.
2216 (fatal_exit): Use it. Renamed from my_exit.
2217 Take signal to exit with, not exit status (which is now always 2).
2219 * pch.h, pch.c (pch_prefix_context, pch_suffix_context):
2220 New fns replacing pch_context.
2221 (another_hunk): Now yields int, not bool; -1 means out of memory.
2222 Now takes difftype as argument.
2223 (pch_write_line): Now returns boolean indicating whether we're after
2224 a newline just after the write, for supporting non-text files.
2225 * pch.c (isdigit): Remove; use ISDIGIT instead.
2226 (INITHUNKMAX): Moved here from common.h.
2227 (p_context): Removed. We need to keep track of the pre- and post-
2228 context separately, in:
2229 (p_prefix_context, p_suffix_context): New variables.
2230 (bestguess): Remove.
2231 (open_patch_file): Arg is now char const *.
2232 Copy file a buffer at a time, not a char at a time, for speed.
2233 (grow_hunkmax): Now returns success indicator.
2234 (there_is_another_patch, skip_to, another_hunk, do_ed_script):
2235 Be less chatty unless --verbose.
2236 (there_is_another_patch):
2237 Avoid infinite loop if user input keeps yielding EOF.
2238 (intuit_diff_type): New returns enum diff, not int.
2239 Strip paths as they're being fetched.
2240 Set ok_to_create_file correctly even if patch is reversed.
2241 Set up file names correctly with unidiff output.
2242 Use algorithm specified by POSIX 1003.2b/D11 to deduce
2243 name of file to patch, with the exception of patches
2244 that can create files.
2245 (skip_to): Be verbose if !inname, since we're about to ask the
2246 user for a file name and the context will help the user choose.
2247 (another_hunk): Keep context as LINENUM, not int.
2248 If the replacement is missing, calculate its context correctly.
2249 Don't assume input ends in newline.
2250 Keep track of patch prefix context separately from suffix context;
2251 this fixes several bugs.
2252 Don't assume blank lines got chopped if the replacement is missing.
2253 Report poorly-formed hunks instead of aborting.
2254 Do not use strcpy on overlapping strings; it's not portable.
2255 Work even if lines are incomplete.
2256 Fix bugs associated with context-less context hunks,
2257 particularly when patching in reverse.
2258 (pget_line): Now takes just 1 arg; instead of second arg,
2259 just examine using_plan_a global. Return -1 if we ran out
2261 (do_ed_script): Now takes output FILE * argument.
2262 Take name of editor from ED_PROGRAM instead of hardwiring /bin/ed.
2263 Don't bother unlinking TMPOUTNAME.
2264 Check for popen failure.
2265 Flush pipe to check for output errors.
2266 If ofp is nonzero, copy result to it, instead of trying to
2269 * util.h, util.c (say1, say2, say3, say4, fatal1, fatal2, fatal3,
2270 fatal4, pfatal1, pfatal2, pfatal3, pfatal4, ask1, ask2, ask3, ask4):
2271 Remove; replaced with following.
2272 (ask, say, fatal, pfatal): New stdarg functions.
2273 (fetchname): Remove last, `assume_exists' parameter.
2274 (savebuf, savestr, move_file, copy_file): Args are now const *.
2275 (exit_with_signal): New function, for proper process status if
2276 a signal is received as per POSIX.2.
2277 (basename): Rename to `base_name' and move to backupfile.
2278 * util.c (<signal.h>): Include here, not in common.h.
2279 (vararg_start): New macro.
2280 (va_dcl, va_start, va_arg, va_end): Define if neither <stdarg.h>
2281 nor <varargs.h> are available.
2282 (SIGCHLD): Define to SIGCLD if SIGCLD is defined and
2284 (private_strerror): Remove.
2285 (move_file): Remove option of moving to stdout.
2286 Add support for -Y, -z.
2287 Don't assume chars in file name are nonnegative.
2288 Use copy_file if rename fails due to EXDEV;
2289 report failure if rename fails for any other reason.
2290 (copy_file, makedirs): Use POSIX symbols for permissions.
2291 (copy_file): Open source before destination.
2292 (remove_prefix): New function.
2293 (vfprintf): New function, if !HAVE_VPRINTF.
2294 (afatal, apfatal, zfatal, zpfatal, errnum): Remove.
2295 (fatal, pfatal, say): New functions that use stdarg.
2296 All callers changed.
2297 (zask): Renamed from `ask'. Now uses stdarg. Output to stdout,
2298 and read from /dev/tty, or if that cannot be opened, from
2299 stderr, stdout, stdin, whichever is first a tty.
2300 Print "EOF" when an EOF is read. Do not echo input.
2302 (sigset_t, sigemptyset, sigmask, sigaddset, sigismember, SIG_BLOCK,
2303 SIG_UNBLOCK, SIG_SETMASK, sigprocmask, sigblock, sigsetmask):
2304 Define substitutes if not available.
2305 (initial_signal_mask, signals_to_block): New vars.
2306 (fatal_exit_handler): New function, if !HAVE_SIGACTION.
2307 (set_signals, ignore_signals): Use sigaction and sigprocmask style
2308 signal-handling if possible; it doesn't lose signals.
2309 (set_signals): Default SIGCHLD to work around SysV fork+wait bug.
2310 (mkdir): First arg is now const *.
2311 (makedirs): Handle multiple adjacent slashes correctly.
2312 (fetchname): Do not worry about whether the file exists
2313 (that is now the caller's responsibility).
2314 Treat a sequence of one or more slashes like one slash.
2315 Do not unstrip leading directories if they all exist and if
2316 no -p option was given; POSIX doesn't allow this.
2317 (memcmp): Remove (now a macro in common.h).
2319 * version.c (copyright_string, free_software_msgid, authorship_msgid):
2321 (version): Use them. Use program_name instead of hardwiring it.
2323 * patch.man: Generate date from RCS Id.
2324 Rewrite to match the above changes.
2326 Fri Jul 30 02:02:51 1993 Paul Eggert (eggert@twinsun.com)
2328 * configure.in (AC_HAVE_FUNCS): Add mkdir.
2330 * common.h (Chmod, Fputc, Write, VOID): New macros.
2331 (malloc, realloc): Yield `VOID *', not `char *'.
2333 * util.h (makedirs): Omit `striplast' argument. Remove `aask'.
2335 * inp.c (plan_a): Remove fixed internal buffer. Remove lint.
2337 * util.c (set_signals, ignore_signals): Trap SIGTERM, too.
2338 (makedirs): Removed fixed internal buffer. Omit `striplast' argument.
2339 (mkdir): New function, if !HAVE_MKDIR.
2340 (fetchname): Remove fixed internal buffer.
2341 Remove lint from various functions.
2343 * patch.c, pch.c: Remove lint.
2345 Thu Jul 29 20:52:07 1993 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu)
2347 * Makefile.in (config.status): Run config.status --recheck, not
2348 configure, to get the right args passed.
2350 Thu Jul 29 07:46:16 1993 Paul Eggert (eggert@twinsun.com)
2352 * The following changes remove all remaining fixed limits on memory,
2353 and fix bugs in patch's handling of null bytes and files that do not
2354 end in newline. `Patch' now works on binary files.
2356 * backupfile.c (find_backup_file_name): Don't dump core if malloc fails.
2358 * EXTERN.h, INTERN.h (EXITING): New macro.
2359 * backupfile.[ch], patch.c, pch.c: Add PARAMS to function declarations.
2361 * common.h (bool): Change to int, so ANSI C prototype promotion works.
2362 (CANVARARG): Remove varargs hack; it wasn't portable.
2363 (filearg): Now a pointer, not an array, so that it can be reallocated.
2364 (GET*, SCCSDIFF, CHECKOUT*, RCSDIFF): Quote operands to commands.
2365 (my_exit): Declare here.
2366 (BUFFERSIZE, Ctl, filemode, Fseek, Fstat, Lseek, MAXFILEC, MAXHUNKSIZE,
2367 Mktemp, myuid, Null, Nullch, Nullfp, Nulline, Pclose, VOIDUSED): Remove.
2368 All invokers changed.
2369 (Argc, Argv, *define[sd], last_offset, maxfuzz, noreverse, ofp,
2370 optind_last, rejfp, rejname): No longer externally visible; all
2372 (INT_MAX, INT_MIN, STD*_FILENO, SEEK_SET): Define if the underlying
2373 system doesn't. Include <limits.h> for this.
2375 * configure.in: Add limits.h, memcmp. Delete getline.
2377 * inp.c (tibufsize): New variable; buffers grow as needed.
2378 (TIBUFSIZE_MINIMUM): New macro.
2379 (report_revision): New function.
2380 (plan_a): Do not search patch as a big string, since that fails
2381 if it contains null bytes.
2382 Prepend `./' to filenames starting with `-', for RCS and SCCS.
2383 If file does not match default RCS/SCCS version, go ahead and patch
2384 it anyway; warn about the problem but do not report a fatal error.
2385 (plan_b): Do not use a fixed buffer to read lines; read byte by byte
2386 instead, so that the lines can be arbitrarily long. Do not search
2387 lines as strings, since they may contain null bytes.
2388 (plan_a, plan_b): Report I/O errors.
2390 * inp.c, inp.h (rev_in_string): Remove.
2391 (ifetch): Yield size of line too, since strlen no longer applies.
2392 (plan_a, plan_b): No longer exported.
2394 * patch.c (abort_hunk, apply_hunk, patch_match, similar):
2395 Lines may contain NUL and need not end in newline.
2396 (copy_till, dump_line): Insert newline if appending after partial line.
2397 All invokers changed.
2398 (main, get_some_switches, apply_hunk): Allocate *_define[ds], filearg,
2399 rejname dynamically.
2400 (make_temp): New function.
2402 (main, spew_output, dump_line) Check for I/O errors.
2404 * pch.c (open_patch_file): Don't copy stdin to a temporary file if
2405 it's a regular file, since we can seek on it directly.
2406 (open_patch_file, skip_to, another_hunk): The patch file may contain
2408 (another_hunk): The patch file may contain lines starting with '\',
2409 which means the preceding line lacked a trailing newline.
2410 (pgetline): Rename to pget_line.
2411 (get_line, incomplete_line, pch_write_line): New functions.
2412 (pch_line_len): Return size_t, not short; lines may be very long.
2413 (do_ed_script): Check for I/O errors. Allow scripts to contain
2414 'i' and 's' commands, too.
2416 * pch.h (pfp, grow_hunkmax, intuit_diff_type, next_intuit_at, skip_to,
2417 pfetch, pgetline): No longer exported.
2418 (pch_write_line): New declaration.
2421 * util.c (move_file, fetchname): Use private stat buffer, so that
2422 filestat isn't lost. Check for I/O errors.
2423 (savestr): Use savebuf.
2424 (zask): Use STD*_FILENO instead of 0, 1, 2.
2425 (fetchname): strip_leading defaults to INT_MAX instead of 957 (!).
2426 (memcmp): Define if !HAVE_MEMCMP.
2428 * util.c, util.h (say*, fatal*, pfatal*, ask*): Delete; these
2429 pseudo-varargs functions weren't ANSI C. Replace by macros
2430 that invoke [fs]printf directly, and invoke new functions
2431 [az]{say,fatal,pfatal,ask} before and after.
2432 (savebuf, read_fatal, write_fatal, memory_fatal, Fseek): New functions.
2433 (fatal*): Output trailing newline after message. All invokers changed.
2435 * version.c (version): Don't exit.
2437 * Makefile.in (SRCS): Remove getline.c.
2439 Thu Jul 22 15:24:24 1993 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
2441 * EXTERN.h, INTERN.h (PARAMS): Define.
2442 * backupfile.h, common.h, inp.h, pch.h, util.h: Use.
2443 * backupfile.c: Include EXTERN.h.
2445 Wed Jul 21 13:14:05 1993 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
2447 * getline.c: New file.
2448 * configure.in: Check for getline (GNU libc has it).
2449 * pch.c: Use it instead of fgets.
2450 (pgetline): Renamed from pgets. Change callers.
2451 * pch.h: Change decl.
2453 * pch.c (pgets): Tab adjusts by 8 - (indent % 8), not % 7.
2454 Be consistent with similar code in pch.c::intuit_diff_type.
2456 * common.h (MEM): Typedef removed.
2457 inp.c, pch.c, util.c: Use size_t instead of MEM.
2458 inp.c, pch.c: Use off_t.
2459 configure.in: Add AC_SIZE_T and AC_OFF_T.
2461 * common.h: Make buf a pointer and add a bufsize variable.
2462 * util.c, pch.c, inp.c: Replace sizeof buf with bufsize.
2463 * patch.c: malloc buf to bufsize bytes.
2465 Tue Jul 20 20:40:03 1993 Paul Eggert (eggert@twinsun.com)
2467 * common.h (BUFFERSIZE): Grow it to 8k too, just in case.
2468 (buf): Turn `buf' back into an array; making it a pointer broke
2470 * patch.c (main): Likewise.
2472 Tue Jul 20 20:02:40 1993 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
2474 * Move Reg[1-16] and CANVARARG decls from config.h.in to common.h.
2475 * acconfig.h: New file.
2476 * Makefile (HDRS): Add it.
2478 Tue Jul 20 16:35:27 1993 Paul Eggert (eggert@twinsun.com)
2480 * Makefile.in: Remove alloca.[co]; getopt no longer needs it.
2481 * configure.in (AC_ALLOCA): Remove.
2483 * util.c (set_signals, ignore_signals): Do nothing if SIGHUP
2484 and SIGINT aren't defined.
2486 Tue Jul 20 17:59:56 1993 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
2488 * patch.c (main): Call xmalloc, not malloc. xmalloc buf.
2489 * common.h: Declare xmalloc. Make buf a pointer, not an array.
2491 * util.c (xmalloc): Call fatal1, not fatal.
2493 * common.h [MAXLINELEN]: Bump from 1k to 8k.
2495 Thu Jul 8 19:56:16 1993 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
2497 * Makefile.in (installdirs): New target.
2499 (Makefile, config.status, configure): New targets.
2501 Wed Jul 7 13:25:40 1993 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
2503 * patch.c (get_some_switches, longopts): Recognize --help
2504 option, and call usage.
2505 (usage): New function.
2507 Fri Jun 25 07:49:45 1993 Paul Eggert (eggert@twinsun.com)
2509 * backupfile.c (find_backup_file_name): Don't use .orig if
2510 numbered_existing with no existing numbered backup.
2511 (addext): Don't use ext if !HAVE_LONG_FILE_NAMES,
2512 even if it would fit. This matches patch's historical behavior.
2513 (simple_backup_suffix): Default to ".orig".
2514 * patch.c (main): Just use that default.
2516 Tue Jun 15 22:32:14 1993 Paul Eggert (eggert@twinsun.com)
2518 * config.h.in (HAVE_ALLOCA_H): This #undef was missing.
2519 * Makefile.in (info, check, installcheck): New rules.
2521 Sun Jun 13 14:31:29 1993 Paul Eggert (eggert@twinsun.com)
2523 * config.h.in (index, rindex): Remove unused macro
2524 definitions; they get in the way when porting to AIX.
2525 * config.h.in, configure.in (HAVE_STRING_H): Remove unused defn.
2527 Thu Jun 10 21:13:47 1993 Paul Eggert (eggert@twinsun.com)
2529 * patchlevel.h: PATCH_VERSION 2.1.
2530 (The name `patch-2.0.12g12' is too long for traditional Unix.)
2532 * patchlevel.h (PATCH_VERSION): Renamed from PATCHLEVEL.
2533 Now contains the entire patch version number.
2534 * version.c (version): Use it.
2536 Wed Jun 9 21:43:23 1993 Paul Eggert (eggert@twinsun.com)
2538 * common.h: Remove declarations of index and rindex.
2539 * backupfile.c: Likewise.
2540 (addext, basename, dirname): Avoid rindex.
2542 Tue Jun 8 15:24:14 1993 Paul Eggert (eggert@twinsun.com)
2544 * inp.c (plan_a): Check that RCS and working files are not the
2545 same. This check is needed on hosts that do not report file
2546 name length limits and have short limits.
2548 Sat Jun 5 22:56:07 1993 Paul Eggert (eggert@twinsun.com)
2550 * Makefile.in (.c.o): Put $(CFLAGS) after other options.
2551 (dist): Switch from .z to .gz.
2553 Wed Jun 2 10:37:15 1993 Paul Eggert (eggert@twinsun.com)
2555 * backupfile.c (find_backup_file_name): Initialize copy of
2558 Mon May 31 21:55:21 1993 Paul Eggert (eggert@twinsun.com)
2560 * patchlevel.h: Patch level 12g11.
2562 * pch.c (p_Char): Renamed from p_char, which is a system type
2563 in Tex XD88's <sys/types.h>.
2565 * backupfile.c: Include "config.h" first, so that `const' is
2566 treated consistently in system headers.
2568 Mon May 31 16:06:23 1993 Paul Eggert (eggert@twinsun.com)
2570 * patchlevel.h: Patch level 12g10.
2572 * configure.in: Add AC_CONST.
2573 * config.h.in: Add `const'.
2574 * Makefile.in (.c.o): Add -DHAVE_CONFIG_H.
2575 (getopt.o getopt1.o): Depend on config.h.
2577 * util.c (xmalloc): New function; alloca.c needs this.
2579 Mon May 31 00:49:40 1993 Paul Eggert (eggert@twinsun.com)
2581 * patchlevel.h: PATCHLEVEL 12g9.
2583 * backupfile.c, backupfile.h (addext): New function.
2584 It uses pathconf(), if available, to determine maximum file
2586 * patch.c (main): Use it for reject file name.
2587 * common.h (ORIGEXT): Moved to patch.c.
2588 * config.h.in (HAVE_PATHCONF): New macro.
2589 * configure.in: Define it.
2591 * Makefile.in (dist): Use gzip, not compress.
2593 Sat May 29 09:42:18 1993 Paul Eggert (eggert@twinsun.com)
2595 * patch.c (main): Use pathconf to decide reject file name.
2596 * common.h (REJEXT): Remove.
2598 * inp.c (plan_a): Don't lock the checked-out file if `patch -o'
2599 redirected the output elsewhere.
2600 * common.h (CHECKOUT_LOCKED, GET_LOCKED): New macros. GET and
2601 CHECKOUT now just checkout unlocked copies.
2603 Fri May 28 08:44:50 1993 Paul Eggert (eggert@twinsun.com)
2605 * backupfile.c (basename): Define even if NODIR isn't defined.
2606 * patch.c (main): Ask just once to apply a reversed patch.
2608 Tue Nov 24 08:09:04 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
2610 * config.h.in, common.h: Use HAVE_FCNTL_H and HAVE_STRING_H
2613 * backupfile.c: Use SYSDIR and NDIR instead of USG.
2614 Define direct as dirent, not vice-versa.
2616 Wed Sep 16 17:11:48 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
2618 * patch.c (get_some_switches): optc should be int, not char.
2620 Tue Sep 15 00:36:46 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
2622 * patchlevel.h: PATCHLEVEL 12g8.
2624 Mon Sep 14 22:01:23 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
2626 * Makefile.in: Add uninstall target.
2628 * util.c (fatal, pfatal): Add some asterisks to make fatal
2629 messages stand out more.
2631 Tue Aug 25 22:13:36 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
2633 * patch.c (main, get_some_switches), common.h, inp.c (plan_a,
2634 plan_b), pch.c (there_is_another_patch): Add -t --batch
2635 option, similar to -f --force.
2637 Mon Jul 27 11:27:07 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
2639 * common.h: Define SCCSDIFF and RCSDIFF.
2640 * inp.c (plan_a): Use them to make sure it's safe to check out
2641 the default RCS or SCCS version.
2644 Mon Jul 20 14:10:32 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
2646 * util.h: Declare basename.
2647 * inp.c (plan_a), util.c (fetchname): Use it to isolate the
2648 leading path when testing for RCS and SCCS files.
2650 Fri Jul 10 16:03:23 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
2652 * util.c (makedirs): Only make the directories that don't exist.
2653 From chip@tct.com (Chip Salzenberg).
2655 Wed Jul 8 01:20:56 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
2657 * patch.c (main): Open ofp after checking for ed script.
2658 Close ofp and rejfp before trying plan B.
2659 From epang@sfu.ca (Eugene Pang).
2661 * util.c (fatal, pfatal): Print "patch: " before message.
2662 * pch.c, inp.c, patch.c, util.c: Remove "patch: " from the
2663 callers that had it.
2665 * common.h (myuid): New variable.
2666 * patch.c (main): Initialize it.
2667 * inp.c (myuid): Function removed.
2668 (plan_a): Use the variable, not the function.
2670 * patch.c: Add back -E --remove-empty-files option.
2672 Tue Jul 7 23:19:28 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
2674 * inp.c (myuid): New function.
2675 (plan_a): Call it. Optimize stat calls. Be smarter about
2676 detecting checked out RCS and SCCS files.
2677 From Paul Eggert (eggert@twinsun.com).
2679 * inp.c, util.c, patch.c: Don't bother checking for stat() > 0.
2681 Mon Jul 6 13:01:52 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
2683 * util.c (move_file): Use rename instead of link and copying.
2685 * util.c (pfatal): New function.
2686 * util.h: Declare it and pfatal[1-4] macros.
2687 * various files: Use it instead of fatal where appropriate.
2689 * common.h, patch.c: Replace Arg[cv]_last with optind_last.
2691 * patch.c (main, get_some_switches): Use getopt_long. Update
2693 (nextarg): Function removed.
2695 * Rename FLEXFILENAMES to HAVE_LONG_FILE_NAMES,
2696 VOIDSIG to RETSIGTYPE.
2698 * backupfile.c, common.h: Use STDC header files if available.
2699 backupfile.h: Declare get_version.
2701 * COPYING, COPYING.LIB, INSTALL, Makefile.in, alloca.c,
2702 config.h.in, configure, configure.in, getopt.[ch], getopt1.c,
2703 rename.c: New files.
2704 * Configure, MANIFEST, Makefile.SH, config.H, config.h.SH,
2705 malloc.c: Files removed.
2707 * version.c (version): Don't print the RCS stuff, since we're
2708 not updating it regularly.
2710 * patchlevel.h: PATCHLEVEL 12u7.
2712 * Makefile.SH (dist): New target.
2713 Makedist: File removed.
2715 * inp.c (plan_a): Check whether the user can write to the
2716 file, not whether anyone can write to the file.
2718 Sat Jul 4 00:06:58 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
2720 * inp.c (plan_a): Try to check out read-only files from RCS or SCCS.
2722 * util.c (move_file): If backing up by linking fails, try copying.
2723 From cek@sdc.boeing.com (Conrad Kimball).
2725 * patch.c (get_some_switches): Eliminate -E option; always
2726 remove empty output files.
2728 * util.c (fetchname): Only undo slash removal for relative
2729 paths if -p was not given.
2731 * Makefile.sh: Add mostlyclean target.
2733 Fri Jul 3 23:48:14 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu)
2735 * util.c (fetchname): Accept whitespace between `Index:' and filename.
2736 Also plug a small memory leak for diffs against /dev/null.
2737 From eggert@twinsun.com (Paul Eggert).
2739 * common.h: Don't define TRUE and FALSE if already defined.
2740 From phk@data.fls.dk (Poul-Henning Kamp).
2742 Wed Apr 29 10:19:33 1992 David J. MacKenzie (djm@churchy.gnu.ai.mit.edu)
2744 * backupfile.c (get_version): Exit if given a bad backup type.
2746 Fri Mar 27 09:57:14 1992 Karl Berry (karl at hayley)
2748 * common.h (S_ISDIR, S_ISREG): define these.
2749 * inp.c (plan_a): use S_ISREG, not S_IFREG.
2750 * util.c (fetchname): use S_ISDIR, not S_IFDIR.
2752 Mon Mar 16 14:10:42 1992 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu)
2754 * patchlevel.h: PATCHLEVEL 12u6.
2756 Sat Mar 14 13:13:29 1992 David J. MacKenzie (djm at frob.eng.umd.edu)
2758 * Configure, config.h.SH: Check for directory header and unistd.h.
2760 * patch.c (main): If -E was given and output file is empty after
2761 patching, remove it.
2762 (get_some_switches): Recognize -E option.
2764 * patch.c (copy_till): Make garbled output an error, not a warning
2765 that doesn't change the exit status.
2767 * common.h: Protect against system declarations of malloc and realloc.
2769 * Makedist: Add backupfile.[ch].
2771 * Configure: Look for C library where NeXT and SVR4 put it.
2772 Look in /usr/ucb after /bin and /usr/bin for utilities,
2773 and look in /usr/ccs/bin, to make SVR4 happier.
2774 Recognize m68k predefine.
2776 * util.c (fetchname): Test of stat return value was backward.
2777 From csss@scheme.cs.ubc.ca.
2779 * version.c (version): Exit with status 0, not 1.
2781 * Makefile.SH: Add backupfile.[cho].
2782 * patch.c (main): Initialize backup file generation.
2783 (get_some_switches): Add -V option.
2784 * common.h, util,c, patch.c: Replace origext with simple_backup_suffix.
2785 * util.c (move_file): Use find_backup_file_name.
2787 Tue Dec 3 11:27:16 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu)
2789 * patchlevel.h: PATCHLEVEL 12u5.
2791 * Makefile.SH: Change clean, distclean, and realclean targets a
2792 little so they agree with the GNU coding standards.
2793 Add Makefile to addedbyconf, so distclean removes it.
2795 * Configure: Recognize Domain/OS C library in /lib/libc.
2796 From mmuegel@mot.com (Michael S. Muegel).
2798 * pch.c: Fixes from Wayne Davison:
2799 Patch now accepts no-context context diffs that are
2800 specified with an assumed one line hunk (e.g. "*** 10 ****").
2801 Fixed a bug in both context and unified diff processing that would
2802 put a zero-context hunk in the wrong place (one line too soon).
2803 Fixed a minor problem with p_max in unified diffs where it would
2804 set p_max to hunkmax unnecessarily (the only adverse effect was to
2805 not supply empty lines at eof by assuming they were truncated).
2807 Tue Jul 2 03:25:51 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu)
2809 * Configure: Check for signal declaration in
2810 /usr/include/sys/signal.h as well as /usr/include/signal.h.
2812 * Configure, common.h, config.h.SH: Comment out the sprintf
2813 declaration and tests to determine its return value type. It
2814 conflicts with ANSI C systems' prototypes in stdio.h and the
2815 return value of sprintf is never used anyway -- it's always cast
2818 Thu Jun 27 13:05:32 1991 David J. MacKenzie (djm at churchy.gnu.ai.mit.edu)
2820 * patchlevel.h: PATCHLEVEL 12u4.
2822 Thu Feb 21 15:18:14 1991 David J. MacKenzie (djm at geech.ai.mit.edu)
2824 * pch.c (another_hunk): Fix off by 1 error. From
2825 iverson@xstor.com (Tim Iverson).
2827 Sun Jan 20 20:18:58 1991 David J. MacKenzie (djm at geech.ai.mit.edu)
2829 * Makefile.SH (all): Don't make a dummy `all' file.
2831 * patchlevel.h: PATCHLEVEL 12u3.
2833 * patch.c (nextarg): New function.
2834 (get_some_switches): Use it, to prevent dereferencing a null
2835 pointer if an option that takes an arg is not given one (is last
2836 on the command line). From Paul Eggert.
2838 * pch.c (another_hunk): Fix from Wayne Davison to recognize
2839 single-line hunks in unified diffs (with a single line number
2840 instead of a range).
2842 * inp.c (rev_in_string): Don't use `s' before defining it. From
2845 Mon Jan 7 06:25:11 1991 David J. MacKenzie (djm at geech.ai.mit.edu)
2847 * patchlevel.h: PATCHLEVEL 12u2.
2849 * pch.c (intuit_diff_type): Recognize `+++' in diff headers, for
2850 unified diff format. From unidiff patch 1.
2852 Mon Dec 3 00:14:25 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
2854 * patch.c (get_some_switches): Make the usage message more
2857 Sun Dec 2 23:20:18 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
2859 * Configure: When checking for C preprocessor, look for 'abc.*xyz'
2860 instead of 'abc.xyz', so ANSI C preprocessors work.
2862 * Apply fix for -D from ksb@mentor.cc.purdue.edu (Kevin Braunsdorf).
2864 1990-05-01 Wayne Davison <davison@dri.com>
2865 * patch.c, pch.c: unidiff support added
2867 Wed Mar 7 23:47:25 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
2869 * pch.c: Call malformed instead of goto malformed
2870 (just allows easier debugging).
2872 Tue Jan 23 21:27:00 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
2874 * common.h (TMP*NAME): Make these char *, not char [].
2875 patch.c (main): Use TMPDIR (if present) to set TMP*NAME.
2876 common.h: Declare getenv.
2878 Sun Dec 17 17:29:48 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu)
2880 * patch.c (reverse_flag_specified): New variable.
2881 (get_some_switches, reinitialize_almost_everything): Use it.
2883 1988-06-22 Larry Wall <sdcrdcf!lwall>
2885 * common.h: sprintf was declared wrong
2886 * patch.c: rindex() wasn't declared
2887 * patch.man: now avoids Bell System Logo
2889 1988-06-03 Larry Wall <sdcrdcf!lwall>
2891 * common.h: support for shorter extensions.
2892 * inp.c: made a little smarter about sccs files
2893 * patch.c: exit code improved.
2894 better support for non-flexfilenames.
2895 * patch.man: -B switch was contributed.
2896 * pch.c: Can now find patches in shar scripts.
2897 Hunks that swapped and then swapped back could core dump.
2899 1987-06-04 Larry Wall <sdcrdcf!lwall>
2900 * pch.c: pch_swap didn't swap p_bfake and p_efake.
2902 1987-02-16 Larry Wall <sdcrdcf!lwall>
2903 * patch.c: Short replacement caused spurious "Out of sync" message.
2905 1987-01-30 Larry Wall <sdcrdcf!lwall>
2906 * patch.c: Improved diagnostic on sync error.
2907 Moved do_ed_script() to pch.c.
2908 * pch.c: Improved responses to mangled patches.
2909 * pch.h: Added do_ed_script().
2911 1987-01-05 Larry Wall <sdcrdcf!lwall>
2912 * pch.c: New-style context diffs caused double call to free().
2914 1986-11-21 Larry Wall <sdcrdcf!lwall>
2915 * patch.c: Fuzz factor caused offset of installed lines.
2917 1986-11-14 Larry Wall <sdcrdcf!lwall>
2918 * pch.c: Fixed problem where a long pattern wouldn't grow the hunk.
2919 Also restored p_input_line when backtracking so error messages are
2922 1986-11-03 Larry Wall <sdcrdcf!lwall>
2923 * pch.c: New-style delete triggers spurious assertion error.
2925 1986-10-29 Larry Wall <sdcrdcf!lwall>
2926 * patch.c: Backwards search could terminate prematurely.
2927 * pch.c: Could falsely report new-style context diff.
2929 1986-09-17 Larry Wall <sdcrdcf!lwall>
2930 * common.h, inp.c, inp.h, patch.c, patch.man, pch.c, pch.h,
2931 util.h, version.c, version.h: Baseline for netwide release.
2933 1986-08-01 Larry Wall <sdcrdcf!lwall>
2934 * patch.c: Fixes for machines that can't vararg.
2935 Added fuzz factor. Generalized -p. General cleanup.
2936 Changed some %d's to %ld's. Linted.
2937 * patch.man: Documented -v, -p, -F.
2938 Added notes to patch senders.
2940 1985-08-15 van%ucbmonet@berkeley
2941 Changes for 4.3bsd diff -c.
2943 1985-03-26 Larry Wall <sdcrdcf!lwall>
2945 * patch.man: Frozen.
2947 1985-03-12 Larry Wall <sdcrdcf!lwall>
2948 * patch.c: Now checks for normalness of file to patch.
2949 Check i_ptr and i_womp to make sure they aren't null before freeing.
2950 Also allow ed output to be suppressed.
2951 Changed pfp->_file to fileno(pfp).
2952 Added -p option from jromine@uci-750a.
2953 Added -D (#ifdef) option from joe@fluke.
2954 * patch.man: Documented -p, -D.
2956 1984-12-06 Larry Wall <sdcrdcf!lwall>
2957 * patch.c: Made smarter about SCCS subdirectories.
2959 1984-12-05 Larry Wall <sdcrdcf!lwall>
2960 * patch.c: Added -l switch to do loose string comparison.
2961 * patch.man: Added -l switch, and noted bistability bug.
2963 1984-12-04 Larry Wall <sdcrdcf!lwall>
2964 Branch for sdcrdcf changes.
2965 * patch.c: Failed hunk count not reset on multiple patch file.
2966 * patch.man: Baseline version.
2968 1984-11-29 Larry Wall <sdcrdcf!lwall>
2969 * patch.c: Linted. Identifiers uniquified. Fixed i_ptr malloc() bug.
2970 Fixed multiple calls to mktemp(). Will now work on machines that can
2971 only read 32767 chars. Added -R option for diffs with new and old
2972 swapped. Various cosmetic changes.
2974 1984-11-09 Larry Wall <sdcrdcf!lwall>
2975 * patch.c: Initial revision
2978 Copyright (C) 1984, 1985, 1986, 1987, 1988 Larry Wall.
2980 Copyright (C) 1989, 1990, 1991, 1992, 1993, 1997, 1998, 1999, 2000, 2001,
2981 2002, 2009 Free Software Foundation, Inc.
2983 This file is part of GNU Patch.
2985 This program is free software; you can redistribute it and/or modify
2986 it under the terms of the GNU General Public License as published by
2987 the Free Software Foundation; either version 2, or (at your option)
2990 This program is distributed in the hope that they will be useful,
2991 but WITHOUT ANY WARRANTY; without even the implied warranty of
2992 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2993 GNU General Public License for more details.
2995 You should have received a copy of the GNU General Public License
2996 along with this program; see the file COPYING. If not, write to
2997 the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,