Commit Graph

18 Commits

Author SHA1 Message Date
Pedro F. Giffuni
fa81223743 patch(1): replace strnlen() with a simpler strlen().
Small style fix with here.

Pointed out by:	kib
2017-01-02 18:27:35 +00:00
Pedro F. Giffuni
4f548c1916 Revert r311106:
patch(1): extend the maximum length of a line from USHRT_MAX to UINT_MAX.

This doesn't really work for 32 bit platforms.

Pointed out by:	kib
2017-01-02 18:23:31 +00:00
Pedro F. Giffuni
ad8469feec patch(1): extend the maximum length of a line from USHRT_MAX to UINT_MAX.
We can handle such "big data" without much trouble.
Try to do a better job at detecting the rejection cause while here.

MFC after:	2 weeks
2017-01-02 17:12:14 +00:00
Pedro F. Giffuni
3548708c47 Adjust a type from r267490.
Independent of the maximum length, the return type for strnlen(3)
is always size_t.
2016-04-24 04:28:04 +00:00
Conrad Meyer
300ca9a86e patch(1): Add -Vnone option to disable backup files
Differential Revision:	https://reviews.freebsd.org/D3146
Reviewed by:	pfg
Approved by:	markj (mentor)
MFC after:	1 week
Relnotes:	yes
Sponsored by:	EMC / Isilon Storage Division
2015-07-21 22:57:27 +00:00
Pedro F. Giffuni
f718bedc4f Fixes to exit status.
Exit with EXIT_FAILURE for invalid arguments.
Fixes NetBSD-PR 43517.

Print version string to stdout instead of stderr;
it is user-requested and not an error.

Obtained from:	NetBSD
MFC after:	5 days
2014-12-31 16:30:33 +00:00
Pedro F. Giffuni
547e0acbec patch: Bring in xstrdup and use it when appropriate.
The function savestr allows NULL return values during Plan A patching so in
case of out of memory conditions, Plan B can step in.  In many cases, NULL
value is not properly handled, so use xstrdup here (it's outside Plan A/B
patching, which means that even Plan B relies on successful operations).

Clean up some whitespaces while here

Obtained from:	OpenBSD
MFC after:	2 weeks
2014-12-25 21:51:28 +00:00
Pedro F. Giffuni
ab761cdbfa Prefer setvbuf() to setlinebuf().
On FreeBSD's libc setlinebuf is a wrapper to setvbuf anyways.

Obtained from:	OpenBSD
MFC after:	5 days
2014-12-07 20:15:07 +00:00
Pedro F. Giffuni
5e64d66ca4 patch: add dry-run alias for compatibility with other implementations.
Other implementations of patch(1), including GNU patch and "svn patch"
have a --dry-run option which does the same as our -C or --check
option.

Add a new alias to make our implementation more compatible.

MFC after:	1 week
2014-06-15 16:38:17 +00:00
Pedro F. Giffuni
c1a08643e3 patch: unsign the line length to avoid overflows.
Patch(1) uses a short int for the line length, which is usually
sufficient for regular diffs, but makes no effort to signal
when there is an overflow.

Change the line length to an unsigned short int to better use
the fact that a length is never negative.  The change is loosely
inspired on a related change in DragonFly, but we avoid spending
more memory than necessary.

While here adjust the messages to be clearer on what is happening.

MFC after:	1 week
2014-06-15 03:54:23 +00:00
Xin LI
e11cd3bc59 Improve bsdpatch usability:
- Ask only once for "Apply anyway". [1]
 - Tell user what file have failed patch rather than just how
   many hunks failed.

Reported by:	jmg via pfg [1]
Tested by:	pfg [1]
Approved by:	re (gjb)
2013-09-26 18:00:45 +00:00
Pedro F. Giffuni
b9740ba1a8 patch: style fix
Submitted by:	gogolok
2013-07-24 15:46:49 +00:00
Glen Barber
ffca5883e8 Revert r250972 to fix build. 2013-05-25 07:17:16 +00:00
Stefan Eßer
2360cb0eea The error handling for writes to the target file could lead to the final
fclose() being skipped. Fix this by using boolean "&" and "|" instead of
short-cut operators "&&" and "||".
While here, increment the last part of the version string. The reason is
the fixed output file selection logic in pch.c, which was committed as
r250943, yesterday.

Reviewed by:	pfg
2013-05-24 18:54:52 +00:00
Xin LI
e56ef7d358 - Refresh code with latest OpenBSD revisions.
- Remove $DragonFly$ tags as they are using git nowadays and VCS tags will
   not help merging.
 - Other changes to Copyright headers to make them consistent with other
   source code, we intend to fork from this point.

Reviewed by:	pfg
2013-01-29 20:05:16 +00:00
Gabor Kovesdan
2dd076b84b - Add a BSD-licensed patch, ported by Pedro F. Giffuni (pfg) from
DragonflyBSD and install it as bsdpatch.  WITH_BSD_PATCH makes it
  default and installs GNU patch as gnupatch.

Submitted by:	pfg
Obtained from:	The DragonflyBSD Project
2013-01-29 17:03:18 +00:00
Peter Wemm
65b3003d2d kill the undead 1997-07-13 14:26:00 +00:00
Bruce Evans
c44252b6e8 Finish importing Lite2's src/usr.bin, except for ex, diff, grep, mail,
pascal and vmstat.sparc.  All changed files on the vendor branch should
already have been imported.
1997-07-06 06:54:14 +00:00