Package: patch / 2.7.6-7

0009-Fix_failed_assertion_outstate-after_newline.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From 76e775847f4954b63dc72afe34d9d921c6688b31 Mon Sep 17 00:00:00 2001
From: Andreas Gruenbacher <agruen@gnu.org>
Date: Tue, 16 Jul 2019 01:16:28 +0200
Subject: Fix failed assertion 'outstate->after_newline'

The assertion triggers when the -o FILE option is used, more than one output
file is written into FILE, and one of those files (except the last one) ends in
the middle of a line.
* src/patch.c (main): Fix the case described above.
---
 src/patch.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/patch.c b/src/patch.c
index 02fd982..3794319 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -365,6 +365,13 @@ main (int argc, char **argv)
 	    /* outstate.ofp now owns the file descriptor */
 	    outfd = -1;
 	  }
+	else
+	  {
+	    /* When writing to a single output file (-o FILE), always pretend
+	       that the output file ends in a newline.  Otherwise, when another
+	       file is written to the same output file, apply_hunk will fail.  */
+	    outstate.after_newline = true;
+	  }
 
 	/* find out where all the lines are */
 	if (!skip_rest_of_patch) {
-- 
cgit v1.2.1