comparison src/diff.c @ 14982:d56f14540dda v8.1.0502

patch 8.1.0502: internal diff fails when diffing a context diff commit https://github.com/vim/vim/commit/f080d70a82f3a4477f346d9efcdfaec1bc1e1d58 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Oct 31 22:57:26 2018 +0100 patch 8.1.0502: internal diff fails when diffing a context diff Problem: Internal diff fails when diffing a context diff. (Hirohito Higashi) Solution: Only use callback calls with one line. (closes https://github.com/vim/vim/issues/3581)
author Bram Moolenaar <Bram@vim.org>
date Wed, 31 Oct 2018 23:00:08 +0100
parents 5d52b21b2e7f
children 9c2352253376
comparison
equal deleted inserted replaced
14981:1c12ef803c7d 14982:d56f14540dda
3204 */ 3204 */
3205 static int 3205 static int
3206 xdiff_out(void *priv, mmbuffer_t *mb, int nbuf) 3206 xdiff_out(void *priv, mmbuffer_t *mb, int nbuf)
3207 { 3207 {
3208 diffout_T *dout = (diffout_T *)priv; 3208 diffout_T *dout = (diffout_T *)priv;
3209 int i;
3210 char_u *p; 3209 char_u *p;
3211 3210
3212 for (i = 0; i < nbuf; i++) 3211 // The header line always comes by itself, text lines in at least two
3213 { 3212 // parts. We drop the text part.
3214 // We are only interested in the header lines, skip text lines. 3213 if (nbuf > 1)
3215 if (STRNCMP(mb[i].ptr, "@@ ", 3) != 0) 3214 return 0;
3216 continue; 3215
3217 if (ga_grow(&dout->dout_ga, 1) == FAIL) 3216 // sanity check
3218 return -1; 3217 if (STRNCMP(mb[0].ptr, "@@ ", 3) != 0)
3219 p = vim_strnsave((char_u *)mb[i].ptr, mb[i].size); 3218 return 0;
3220 if (p == NULL) 3219
3221 return -1; 3220 if (ga_grow(&dout->dout_ga, 1) == FAIL)
3222 ((char_u **)dout->dout_ga.ga_data)[dout->dout_ga.ga_len++] = p; 3221 return -1;
3223 } 3222 p = vim_strnsave((char_u *)mb[0].ptr, mb[0].size);
3223 if (p == NULL)
3224 return -1;
3225 ((char_u **)dout->dout_ga.ga_data)[dout->dout_ga.ga_len++] = p;
3224 return 0; 3226 return 0;
3225 } 3227 }
3226 3228
3227 #endif /* FEAT_DIFF */ 3229 #endif /* FEAT_DIFF */