[PATCH 1/4] diff/xdiff: refactor EOF-EOL detection
From: Michael J Gruber <hidden>
Date: 2016-06-15 22:48:54
Subsystem:
the rest · Maintainer:
Linus Torvalds
This puts the "No newline at end of file" warning for both code paths (emit_rewrite_lines for emit_rewrite_diff and fn_out_consume for xdi_diff_outf) into diff.c so that it is easier to adjust later on. Signed-off-by: Michael J Gruber <redacted> --- diff.c | 2 ++ xdiff/xutils.c | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/diff.c b/diff.c
index 4e07744..ff44bcc 100644
--- a/diff.c
+++ b/diff.c@@ -917,6 +917,8 @@ static void fn_out_consume(void *priv, char *line, unsigned long len) ecbdata->lno_in_postimage++; emit_add_line(reset, ecbdata, line + 1, len - 1); } + if (line[len-1] != '\n') + fputs("\n\\ No newline at end of file\n", ecbdata->file); } static char *pprint_rename(const char *a, const char *b)
diff --git a/xdiff/xutils.c b/xdiff/xutils.c
index bc12f29..feb43a9 100644
--- a/xdiff/xutils.c
+++ b/xdiff/xutils.c@@ -51,11 +51,6 @@ int xdl_emit_diffrec(char const *rec, long size, char const *pre, long psize, mb[0].size = psize; mb[1].ptr = (char *) rec; mb[1].size = size; - if (size > 0 && rec[size - 1] != '\n') { - mb[2].ptr = (char *) "\n\\ No newline at end of file\n"; - mb[2].size = strlen(mb[2].ptr); - i++; - } if (ecb->outf(ecb->priv, mb, i) < 0) { return -1;
--
1.7.1.351.ge2633e