1From 76e775847f4954b63dc72afe34d9d921c6688b31 Mon Sep 17 00:00:00 2001 2From: Andreas Gruenbacher <agruen@gnu.org> 3Date: Tue, 16 Jul 2019 01:16:28 +0200 4Subject: Fix failed assertion 'outstate->after_newline' 5 6The assertion triggers when the -o FILE option is used, more than one output 7file is written into FILE, and one of those files (except the last one) ends in 8the middle of a line. 9* src/patch.c (main): Fix the case described above. 10--- 11 src/patch.c | 7 +++++++ 12 1 file changed, 7 insertions(+) 13 14diff --git a/src/patch.c b/src/patch.c 15index 02fd982..3794319 100644 16--- a/src/patch.c 17+++ b/src/patch.c 18@@ -365,6 +365,13 @@ main (int argc, char **argv) 19 /* outstate.ofp now owns the file descriptor */ 20 outfd = -1; 21 } 22+ else 23+ { 24+ /* When writing to a single output file (-o FILE), always pretend 25+ that the output file ends in a newline. Otherwise, when another 26+ file is written to the same output file, apply_hunk will fail. */ 27+ outstate.after_newline = true; 28+ } 29 30 /* find out where all the lines are */ 31 if (!skip_rest_of_patch) { 32-- 33cgit v1.2.1 34 35