Commit Graph

33 Commits

Author SHA1 Message Date
Kris Kennaway
08c9683bed Prevent stack-smashing buffer overflows in -D and -r options by using
buffer-safe string functions.  The rest of the code is still probably
unsafe.

MFC after:	1 week
2002-10-13 01:18:33 +00:00
Garance A Drosehn
d77254e807 Change parts of the source code to make it closer to style(9), mainly
changing indentation and some comments.  Main goal is not perfect style,
but just to reduce differences with NetBSD.  The object code is exactly
the same after this change as before it (except for assert() statements
which have moved).

Reviewed by:	/sbin/md5 on i386
Obtained from:	NetBSD
2002-05-21 00:44:18 +00:00
Garance A Drosehn
38a1326cad Add many prototypes and ANSI-ize 'patch. Not a complete job of it, but it gets
our patch to look a little more like NetBSD's, and has the nice characteristic
that the object code is exactly the same after the change as before it (even in
patch.c and pch.c, which have pesky 'assert' statements in them).

Reviewed by:	/sbin/md5 on i386, alpha, sparc64
MFC after:	3 days
2002-04-28 01:33:45 +00:00
Garance A Drosehn
a3df8483c8 Add FreeBSD id's to these files, in advance of a separate update.
MFC after:	3 days
2002-04-28 01:26:40 +00:00
Garance A Drosehn
5343608723 Modify our 'patch' utility to recognize the
\ No newline at end of file
line that some versions of diff print out if the last line of the two files
are different, and one of the two files does not have a newline character
on that last line.

This change is still somewhat under discussion in -arch and -standards, but I
want to commit it to -current today so I'd have the chance to MFC it to -stable
before the code freeze for 4.6-release (which would be May 1st).

Note: the related change to 'diff' (so it might *generate* that line) is NOT
expected to be included in 4.6-release.  We can debate that change later.

Obtained from:	NetBSD (1.13 of basesrc/usr.bin/patch/pch.c, by kristerw)
MFC after:	4 days
2002-04-26 19:01:19 +00:00
Mike Barcroft
80db0611da Add -i option (SUSv3) to patch(1). This allows one to specify a
patch file on command line instead of stdin.

Submitted by:	Joseph Mallett <jmallett@xMach.org>
MFC after:	1 month
2002-02-08 02:05:32 +00:00
Ruslan Ermilov
280835fe49 Restore vendor CVS keywords; eliminate troff(1) warnings. 2001-07-12 13:13:37 +00:00
Ruslan Ermilov
e5ac5644e2 MAN[1-9] -> MAN. 2001-03-27 14:59:06 +00:00
David E. O'Brien
1a37aa566b Add `_PATH_DEVZERO'.
Use _PATH_* where where possible.
2000-12-09 09:35:55 +00:00
Kelly Yancey
d2d11ded0f Fix previous commit such that only -S/--skip ignores errors when applying
a patch, returning -f/--force and -t/--batch to their previous semantics.

Pointed out by:	asami
2000-08-02 22:31:34 +00:00
Kelly Yancey
d1b04ce6b7 Fix patch such that skipping files does not count as a failure.
Previously, using -S/--skip, -f/--force, or -t/--batch to skip a patch in
a patchset still registers a failure which causes patch to return a
non-zero exit code. This is particularly undesirable with regards to
ports as there is no way to ignore the non-zero code. (Luckily, we don't
currently have any ports that make use of any of these options.)

The PR (yes, my own) is slightly incorrect: It states that -f does indeed
properly skip patches. It does, but it still sets the failure flag causing
patch to return non-zero.

PR:		19638
Submitted by:	kbyanc@posi.net
2000-08-02 06:54:21 +00:00
Peter Wemm
072ca4aea0 Clean up some $Log$ debris, including some real messes. 1999-09-05 17:31:55 +00:00
Peter Wemm
a1a4f1a0d8 $Header$ -> $FreeBSD$ 1999-08-28 05:11:36 +00:00
Andrey A. Chernov
2aee32e1f8 Add PATCH_INDEX_FIRST environment variable to do the same as -I option 1998-01-22 07:44:04 +00:00
Andrey A. Chernov
0b00e7b2c0 Update usage line with new option 1998-01-21 15:15:39 +00:00
Andrey A. Chernov
8bf2e8c7e2 Add -I or --index-first option to take Index: precedence over context diff,
as it was in hacked FreeBSD version
1998-01-21 15:10:14 +00:00
Andrey A. Chernov
249a716c6c Resurrect patch 2.1 without FreeBSD Index: hack 1998-01-21 14:37:27 +00:00
Andrey A. Chernov
78dd9df206 Upgrade to 2.5 (contrib version) 1998-01-04 21:41:46 +00:00
Andrey A. Chernov
1f374e009f Back out Index over +++/--- precedence.
It maybe right, if patch was FreeBSD-own program, but it break compatibility
with pre-existent patches in other systems.
The example is big ncurses patch which don't apply on FreeBSD
due to "fixed" precedence.
1998-01-03 23:42:56 +00:00
Andrey A. Chernov
5a90c8dbf2 Add (unsigned char) cast to ctype macros 1997-10-23 02:44:23 +00:00
John-Mark Gurney
5e30934038 fix compilation warnings in patch... (with slight modification)
also remove -Wall that I acidentally committed last time I was here...

Submitted-by: Philippe Charnier

Closes PR#2998
1997-03-17 01:44:43 +00:00
John-Mark Gurney
53e3a4a22c Fix a problem with patch in that is will always default, even when the
controlling terminal is closed.  Now the function ask() will return 1 when th
input is known to come from a file or terminal, or it will return 0 when ther
was a read error.

Modified the question "Skip patch?" so that on an error from ask it will skip
the patch instead of looping.

Closes PR#777

2.2 candidate
1997-02-13 21:10:45 +00:00
Mark Murray
01aa0a09a4 Attempt to break a $Log$ snafu where a *** /--- (minus space)
was fouling up a comment in the checked-out code.
1996-04-12 11:37:32 +00:00
Mark Murray
2bff10e8b9 Priorities were broken. If there was an Index: line and ***/--- lines
with valid names, the ***/---names were taken first.
this broke eg:
Index: foo/Makefile
==========
RCS <blah>
Retrieving <blah>
diff <blah>
*** Makefile <blah>
--- Makefile <blah>

By trying to patch the Makefile in the _curent_ directory, rather than
the one in the foo/ directory.
1996-04-11 10:13:40 +00:00
John Polstra
f8b117f1e4 Update the manual page to reflect the fact that an "Index" line
now takes precedence over a context diff header for determining
the name of the file to patch.
1996-02-07 23:47:55 +00:00
Justin T. Gibbs
312b98f6bb Give "Index" specified filenames preference over other filenames specified
in the diff.  This makes it so that diffs containing files in different
subdirectories that have the same name not patch the same file.  For example
a diff with patches to Makefile, des/Makefile, usr.bin/Makefile would attempt
to patch Makefile three times.
1995-09-14 04:33:35 +00:00
Rodney W. Grimes
4399be3cbd Remove trailing whitespace. 1995-05-30 05:05:38 +00:00
Jeffrey Hsu
add65270a0 Fix bug that created new files even when running in -C check mode.
Reviewed by: phk
1995-01-12 22:09:40 +00:00
Poul-Henning Kamp
e70b6ad7a1 added the -C/-check again. 1994-02-25 21:46:07 +00:00
Jordan K. Hubbard
07d2c9fe20 Put this back - I was somehow under the erroneous impression that patch was in
ports, until I saw the the commit messages, that is! :-)  All changed backed out.
1994-02-17 22:20:36 +00:00
Jordan K. Hubbard
3f125aef7a From Poul-Henning Kamp - Implement a -C option to verify the integrity of
a patch before actually applying it.
1994-02-17 22:16:05 +00:00
Rich Murphey
931407698e Increaed the fixed static buffer sizes and maximum hunk size that
otherwise causes the XFree86 1.3 patch set to fail.
1993-09-22 16:51:03 +00:00
Paul Richards
36e3306c74 b-maked patch-2.10 1993-06-19 14:21:53 +00:00