patch/backport-Fix-failed-assertion-outstate-after_newline.patch

37 lines
1.1 KiB
Diff
Raw Normal View History

From 2ab603a64f404d4724a867b8cf9f08ccacbff7c6 Mon Sep 17 00:00:00 2001
From: Andreas Gruenbacher <agruen@gnu.org>
Date: Tue, 16 Jul 2019 01:16:28 +0200
Subject: [PATCH 5/8] 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.
Signed-off-by: Xibo.Wang <wangxb12@chinatelecom.cn>
---
src/patch.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/patch.c b/src/patch.c
index 1e1915d..9684794 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -369,6 +369,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) {
--
1.8.3.1