summaryrefslogtreecommitdiff
path: root/src/diff.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-10-31 22:57:26 +0100
committerBram Moolenaar <Bram@vim.org>2018-10-31 22:57:26 +0100
commitf080d70a82f3a4477f346d9efcdfaec1bc1e1d58 (patch)
tree026984ece20253103637569f07b3f8f1e8d23895 /src/diff.c
parenta9a8e04eab106c1d21381f79f8965fe50b94e235 (diff)
downloadvim-git-f080d70a82f3a4477f346d9efcdfaec1bc1e1d58.tar.gz
patch 8.1.0502: internal diff fails when diffing a context diffv8.1.0502
Problem: Internal diff fails when diffing a context diff. (Hirohito Higashi) Solution: Only use callback calls with one line. (closes #3581)
Diffstat (limited to 'src/diff.c')
-rw-r--r--src/diff.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/diff.c b/src/diff.c
index 23503d826..c00176134 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -3206,21 +3206,23 @@ parse_diff_unified(
xdiff_out(void *priv, mmbuffer_t *mb, int nbuf)
{
diffout_T *dout = (diffout_T *)priv;
- int i;
char_u *p;
- for (i = 0; i < nbuf; i++)
- {
- // We are only interested in the header lines, skip text lines.
- if (STRNCMP(mb[i].ptr, "@@ ", 3) != 0)
- continue;
- if (ga_grow(&dout->dout_ga, 1) == FAIL)
- return -1;
- p = vim_strnsave((char_u *)mb[i].ptr, mb[i].size);
- if (p == NULL)
- return -1;
- ((char_u **)dout->dout_ga.ga_data)[dout->dout_ga.ga_len++] = p;
- }
+ // The header line always comes by itself, text lines in at least two
+ // parts. We drop the text part.
+ if (nbuf > 1)
+ return 0;
+
+ // sanity check
+ if (STRNCMP(mb[0].ptr, "@@ ", 3) != 0)
+ return 0;
+
+ if (ga_grow(&dout->dout_ga, 1) == FAIL)
+ return -1;
+ p = vim_strnsave((char_u *)mb[0].ptr, mb[0].size);
+ if (p == NULL)
+ return -1;
+ ((char_u **)dout->dout_ga.ga_data)[dout->dout_ga.ga_len++] = p;
return 0;
}