]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
patch: fix locate_hunk in empty files
authorPedro F. Giffuni <pfg@FreeBSD.org>
Sun, 3 Dec 2023 17:33:03 +0000 (12:33 -0500)
committerPedro F. Giffuni <pfg@FreeBSD.org>
Sun, 3 Dec 2023 17:33:03 +0000 (12:33 -0500)
commit7e8afbb6d605006d7cb867362b225d21c4f5ae57
treea31023049e16e4cfff11526487d64e8307880c2e
parent970d73856b626a68597de19d37b68c376e2c0491
patch: fix locate_hunk in empty files

if `first_guess' is zero then main() assumes that locate_hunk has failed
and aborts the patch operation.  Instead, make sure to return 1 (the
line number) so that the patch operation can continue.

Issue originally found by Neels Hofmeyr in the regress suite of the diff
implementation for got, where the tests assume that applying a diff with
`patch' and then again with `patch -R' yields back the original file.

Obtained from: OpenBSD (CVS patch.c,v 1.71)
usr.bin/patch/patch.c